kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: add browserbase example and update deps
rodzic
efa568f54d
commit
2ff3065b47
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env node
|
||||
import 'dotenv/config'
|
||||
|
||||
import { openai } from '@ai-sdk/openai'
|
||||
import { Browserbase, BrowserbaseAISDK } from '@browserbasehq/sdk'
|
||||
import { generateText } from 'ai'
|
||||
|
||||
async function main() {
|
||||
const browserbase = new Browserbase()
|
||||
|
||||
const browserTool = BrowserbaseAISDK(browserbase, { textContent: true })
|
||||
console.log(browserTool.parameters)
|
||||
|
||||
const result = await generateText({
|
||||
model: openai('gpt-4o'),
|
||||
tools: { browserTool },
|
||||
toolChoice: 'required',
|
||||
temperature: 0,
|
||||
system: 'You are a helpful assistant. Be as concise as possible.',
|
||||
prompt: 'What is the weather in San Francisco?'
|
||||
})
|
||||
|
||||
console.log(result.toolResults[0])
|
||||
}
|
||||
|
||||
await main()
|
21
package.json
21
package.json
|
@ -69,7 +69,7 @@
|
|||
],
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
"build": "tsc",
|
||||
"build": "tsup",
|
||||
"clean": "del dist",
|
||||
"prebuild": "run-s clean",
|
||||
"predev": "run-s clean",
|
||||
|
@ -83,7 +83,7 @@
|
|||
"test:unit": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nangohq/node": "^0.39.32",
|
||||
"@nangohq/node": "^0.39.33",
|
||||
"dedent": "^1.5.3",
|
||||
"delay": "^6.0.0",
|
||||
"hash-object": "^5.0.1",
|
||||
|
@ -94,36 +94,37 @@
|
|||
"p-map": "^7.0.2",
|
||||
"p-throttle": "^6.1.0",
|
||||
"quick-lru": "^7.0.0",
|
||||
"type-fest": "^4.18.3",
|
||||
"type-fest": "^4.19.0",
|
||||
"zod": "^3.23.3",
|
||||
"zod-to-json-schema": "^3.23.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@browserbasehq/sdk": "^1.2.1",
|
||||
"@dexaai/dexter": "^2.0.3",
|
||||
"@e2b/code-interpreter": "^0.0.7",
|
||||
"@fisch0920/eslint-config": "^1.3.3",
|
||||
"@genkit-ai/ai": "^0.5.2",
|
||||
"@instructor-ai/instructor": "^1.3.0",
|
||||
"@langchain/core": "^0.2.5",
|
||||
"@langchain/core": "^0.2.6",
|
||||
"@total-typescript/ts-reset": "^0.5.1",
|
||||
"@types/node": "^20.13.0",
|
||||
"ai": "^3.1.22",
|
||||
"@types/node": "^20.14.2",
|
||||
"ai": "^3.1.30",
|
||||
"del-cli": "^5.1.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"eslint": "^8.57.0",
|
||||
"expr-eval": "^2.0.2",
|
||||
"husky": "^9.0.11",
|
||||
"lint-staged": "^15.2.5",
|
||||
"llamaindex": "^0.3.15",
|
||||
"llamaindex": "^0.3.16",
|
||||
"np": "^10.0.5",
|
||||
"npm-run-all2": "^6.2.0",
|
||||
"only-allow": "^1.2.1",
|
||||
"openai-fetch": "^2.0.3",
|
||||
"prettier": "^3.2.5",
|
||||
"prettier": "^3.3.1",
|
||||
"restore-cursor": "^5.0.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsup": "^8.0.2",
|
||||
"tsx": "^4.11.0",
|
||||
"tsup": "^8.1.0",
|
||||
"tsx": "^4.13.0",
|
||||
"twitter-api-sdk": "^1.2.1",
|
||||
"typescript": "^5.4.5",
|
||||
"vitest": "2.0.0-beta.3"
|
||||
|
|
1739
pnpm-lock.yaml
1739
pnpm-lock.yaml
Plik diff jest za duży
Load Diff
17
readme.md
17
readme.md
|
@ -175,6 +175,7 @@ Note that many of these clients expose multiple AI functions.
|
|||
- sdks
|
||||
- modelfusion
|
||||
- services
|
||||
- browserbase
|
||||
- [phantombuster](https://phantombuster.com)
|
||||
- perplexity
|
||||
- valtown
|
||||
|
@ -186,14 +187,22 @@ Note that many of these clients expose multiple AI functions.
|
|||
- pull from [nango](https://docs.nango.dev/integrations/overview)
|
||||
- pull from [activepieces](https://github.com/activepieces/activepieces/tree/main/packages/pieces/community)
|
||||
- general openapi support ala [workgpt](https://github.com/team-openpm/workgpt)
|
||||
- tools / chains / flows / runnables
|
||||
- compound tools / chains / flows / runnables
|
||||
- market maps
|
||||
- https://github.com/causaly/zod-validation-error
|
||||
- incorporate [zod-validation-error](https://github.com/causaly/zod-validation-error)
|
||||
- investigate [autotool](https://github.com/run-llama/LlamaIndexTS/tree/main/packages/autotool)
|
||||
- investigate [data connectors](https://github.com/mendableai/data-connectors)
|
||||
|
||||
## Contributors
|
||||
|
||||
- [Travis Fischer](https://x.com/transitive_bs)
|
||||
- [Kevin Raheja](https://x.com/crabfisher)
|
||||
- [David Zhang](https://x.com/dzhng)
|
||||
- [Philipp Burckhardt](https://x.com/burckhap)
|
||||
- [Riley Tomasek](https://x.com/rileytomasek)
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Travis Fischer](https://twitter.com/transitive_bs)
|
||||
MIT © [Travis Fischer](https://x.com/transitive_bs)
|
||||
|
||||
To stay up to date or learn more, follow [@transitive_bs](https://twitter.com/transitive_bs) on Twitter.
|
||||
To stay up to date or learn more, follow [@transitive_bs](https://x.com/transitive_bs) on Twitter.
|
||||
|
|
30
src/fns.ts
30
src/fns.ts
|
@ -1,5 +1,3 @@
|
|||
import './symbol-polyfill.js'
|
||||
|
||||
import type { z } from 'zod'
|
||||
|
||||
import type * as types from './types.js'
|
||||
|
@ -14,6 +12,27 @@ export interface PrivateAIFunctionMetadata {
|
|||
methodName: string
|
||||
}
|
||||
|
||||
// Polyfill for `Symbol.metadata`
|
||||
// https://github.com/microsoft/TypeScript/issues/53461
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly metadata: unique symbol
|
||||
}
|
||||
}
|
||||
|
||||
;(Symbol as any).metadata ??= Symbol.for('Symbol.metadata')
|
||||
|
||||
const _metadata = Object.create(null)
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.metadata) {
|
||||
Object.defineProperty(globalThis, Symbol.metadata, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _metadata
|
||||
})
|
||||
}
|
||||
|
||||
export abstract class AIFunctionsProvider {
|
||||
private _functions?: AIFunctionSet
|
||||
|
||||
|
@ -72,6 +91,7 @@ export function aiFunction<
|
|||
if (!context.metadata.invocables) {
|
||||
context.metadata.invocables = []
|
||||
}
|
||||
|
||||
;(context.metadata.invocables as PrivateAIFunctionMetadata[]).push({
|
||||
name: name ?? methodName,
|
||||
description,
|
||||
|
@ -79,12 +99,6 @@ export function aiFunction<
|
|||
methodName
|
||||
})
|
||||
|
||||
// console.log({
|
||||
// name,
|
||||
// methodName,
|
||||
// context
|
||||
// })
|
||||
|
||||
context.addInitializer(function () {
|
||||
;(this as any)[methodName] = (this as any)[methodName].bind(this)
|
||||
})
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
// https://github.com/microsoft/TypeScript/issues/53461
|
||||
// symbol-polyfill.ts
|
||||
|
||||
declare global {
|
||||
interface SymbolConstructor {
|
||||
readonly metadata: unique symbol
|
||||
}
|
||||
}
|
||||
|
||||
;(Symbol as any).metadata ??= Symbol.for('Symbol.metadata')
|
||||
|
||||
const _metadata = Object.create(null)
|
||||
|
||||
if (typeof Symbol === 'function' && Symbol.metadata) {
|
||||
Object.defineProperty(globalThis, Symbol.metadata, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: _metadata
|
||||
})
|
||||
}
|
||||
|
||||
// export {};
|
||||
// declare global {
|
||||
// interface SymbolConstructor {
|
||||
// readonly metadata: unique symbol
|
||||
// }
|
||||
// }
|
||||
// (Symbol as any).metadata ??= Symbol.for("Symbol.metadata")
|
|
@ -122,7 +122,7 @@ export function sanitizeSearchParams(
|
|||
}
|
||||
|
||||
return [[key, String(value)]]
|
||||
})
|
||||
}) as [string, string][]
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue