kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/643/head^2
rodzic
7731ca09bc
commit
3caa185fbe
|
@ -8,7 +8,8 @@ import restoreCursor from 'restore-cursor'
|
|||
// import { ProxycurlClient } from '../src/services/proxycurl-client.js'
|
||||
// import { WikipediaClient } from '../src/index.js'
|
||||
// import { PerigonClient } from '../src/index.js'
|
||||
import { FirecrawlClient } from '../src/index.js'
|
||||
// import { FirecrawlClient } from '../src/index.js'
|
||||
import { ExaClient } from '../src/index.js'
|
||||
|
||||
/**
|
||||
* Scratch pad for testing.
|
||||
|
@ -49,10 +50,19 @@ async function main() {
|
|||
// })
|
||||
// console.log(JSON.stringify(res, null, 2))
|
||||
|
||||
const firecrawl = new FirecrawlClient()
|
||||
const res = await firecrawl.scrapeUrl({
|
||||
// url: 'https://www.bbc.com/news/articles/cp4475gwny1o'
|
||||
url: 'https://www.firecrawl.dev'
|
||||
// const firecrawl = new FirecrawlClient()
|
||||
// const res = await firecrawl.scrapeUrl({
|
||||
// // url: 'https://www.bbc.com/news/articles/cp4475gwny1o'
|
||||
// url: 'https://www.firecrawl.dev'
|
||||
// })
|
||||
// console.log(JSON.stringify(res, null, 2))
|
||||
|
||||
const exa = new ExaClient()
|
||||
const res = await exa.search({
|
||||
query: 'OpenAI',
|
||||
contents: {
|
||||
text: true
|
||||
}
|
||||
})
|
||||
console.log(JSON.stringify(res, null, 2))
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import defaultKy, { type KyInstance } from 'ky'
|
|||
import { z } from 'zod'
|
||||
|
||||
import { aiFunction, AIFunctionsProvider } from '../fns.js'
|
||||
import { assert, getEnv } from '../utils.js'
|
||||
import { assert, getEnv, pruneUndefined } from '../utils.js'
|
||||
|
||||
export namespace exa {
|
||||
export const TextContentsOptionsSchema = z.object({
|
||||
|
@ -151,6 +151,9 @@ export namespace exa {
|
|||
|
||||
/** The autoprompt string, if applicable. */
|
||||
autopromptString?: string
|
||||
|
||||
/** Internal ID of this request. */
|
||||
requestId?: string
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,8 +212,18 @@ export class ExaClient extends AIFunctionsProvider {
|
|||
inputSchema: exa.FindSimilarOptionsSchema
|
||||
})
|
||||
async findSimilar(opts: exa.FindSimilarOptions) {
|
||||
const { excludeSourceDomain, ...rest } = opts
|
||||
const excludeDomains = (opts.excludeDomains ?? []).concat(
|
||||
excludeSourceDomain ? [new URL(opts.url).hostname] : []
|
||||
)
|
||||
|
||||
return this.ky
|
||||
.post('findSimilar', { json: opts })
|
||||
.post('findSimilar', {
|
||||
json: pruneUndefined({
|
||||
...rest,
|
||||
excludeDomains: excludeDomains.length ? excludeDomains : undefined
|
||||
})
|
||||
})
|
||||
.json<exa.SearchResponse>()
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue