1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Hono } from "https://deno.land/x/hono@v3.11.7/mod.ts";
import Exa from "npm:exa-js"
const exa = new Exa(Deno.env.get("EXA_API_KEY"));
export const exaSearch = async ({ query, type, useAutoprompt, numResults, text, summary=true, highlights }) => {
const result = await exa.searchAndContents(
query,
{
type: type || "auto" || "neural",
useAutoprompt: useAutoprompt || true,
numResults: 10,
highlights: highlights || {
numSentences: 3,
highlightsPerUrl: 1,
},
text,
summary,
}
)
return result.results
}
export const search = async (query) => {
return await exaSearch({query})
}
// console.log(await search('banana'))
// console.log(await search('top 10 fun, quirky, cheap bars in sf / bay area?'))
// console.log(await search(`<query>top 10 fun, quirky, cheap bars in sf / bay area?</query><formatting>Only return a JSON object where the results are stored in an ARRAY OF STRINGS with 'list' as the key: { list: [result1, result2, result3]}. Start with {
// const app = new Hono();
// export default app.fetch;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 17, 2024