kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
Rename `createXSAISDKTools` to `createXSAITools`
rodzic
96d7ddeecb
commit
4ba87047a1
|
@ -4,7 +4,7 @@ description: Agentic adapter for the xsAI SDK.
|
||||||
---
|
---
|
||||||
|
|
||||||
- package: `@agentic/xsai`
|
- package: `@agentic/xsai`
|
||||||
- exports: `function createXSAISDKTools`
|
- exports: `function createXSAITools`
|
||||||
- [source](https://github.com/transitive-bullshit/agentic/blob/main/packages/xsai/src/xsai.ts)
|
- [source](https://github.com/transitive-bullshit/agentic/blob/main/packages/xsai/src/xsai.ts)
|
||||||
- [xsAI SDK docs](https://xsai.js.org)
|
- [xsAI SDK docs](https://xsai.js.org)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ pnpm add @agentic/xsai xsai @xsai/tool
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
<Note>
|
<Note>
|
||||||
Note that `createXSAISDKTools` is `async` because `xsai`'s underlying
|
Note that `createXSAITools` is `async` because `xsai`'s underlying
|
||||||
`xsschema.toJsonSchema` is async.
|
`xsschema.toJsonSchema` is async.
|
||||||
</Note>
|
</Note>
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ pnpm add @agentic/xsai xsai @xsai/tool
|
||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
|
|
||||||
import { WeatherClient } from '@agentic/weather'
|
import { WeatherClient } from '@agentic/weather'
|
||||||
import { createXSAISDKTools } from '@agentic/xsai'
|
import { createXSAITools } from '@agentic/xsai'
|
||||||
import { generateText } from 'xsai'
|
import { generateText } from 'xsai'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
@ -46,7 +46,7 @@ async function main() {
|
||||||
apiKey: process.env.OPENAI_API_KEY!,
|
apiKey: process.env.OPENAI_API_KEY!,
|
||||||
baseURL: 'https://api.openai.com/v1/',
|
baseURL: 'https://api.openai.com/v1/',
|
||||||
model: 'gpt-4o-mini',
|
model: 'gpt-4o-mini',
|
||||||
tools: await createXSAISDKTools(weather),
|
tools: await createXSAITools(weather),
|
||||||
toolChoice: 'required',
|
toolChoice: 'required',
|
||||||
temperature: 0,
|
temperature: 0,
|
||||||
messages: [
|
messages: [
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import 'dotenv/config'
|
import 'dotenv/config'
|
||||||
|
|
||||||
import { WeatherClient } from '@agentic/weather'
|
import { WeatherClient } from '@agentic/weather'
|
||||||
import { createXSAISDKTools } from '@agentic/xsai'
|
import { createXSAITools } from '@agentic/xsai'
|
||||||
import { generateText } from 'xsai'
|
import { generateText } from 'xsai'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
@ -12,7 +12,7 @@ async function main() {
|
||||||
apiKey: process.env.OPENAI_API_KEY!,
|
apiKey: process.env.OPENAI_API_KEY!,
|
||||||
baseURL: 'https://api.openai.com/v1/',
|
baseURL: 'https://api.openai.com/v1/',
|
||||||
model: 'gpt-4o-mini',
|
model: 'gpt-4o-mini',
|
||||||
tools: await createXSAISDKTools(weather),
|
tools: await createXSAITools(weather),
|
||||||
toolChoice: 'required',
|
toolChoice: 'required',
|
||||||
temperature: 0,
|
temperature: 0,
|
||||||
messages: [
|
messages: [
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { EchoAITool } from '@agentic/core'
|
import { EchoAITool } from '@agentic/core'
|
||||||
import { describe, expect, test } from 'vitest'
|
import { describe, expect, test } from 'vitest'
|
||||||
|
|
||||||
import { createXSAISDKTools } from './xsai'
|
import { createXSAITools } from './xsai'
|
||||||
|
|
||||||
describe('xsai', () => {
|
describe('xsai', () => {
|
||||||
test('createXSAISDKTools', async () => {
|
test('createXSAITools', async () => {
|
||||||
const tools = await createXSAISDKTools(new EchoAITool())
|
const tools = await createXSAITools(new EchoAITool())
|
||||||
expect(tools).toHaveLength(1)
|
expect(tools).toHaveLength(1)
|
||||||
expect(tools[0]!.function.name).toBe('echo')
|
expect(tools[0]!.function.name).toBe('echo')
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { tool, type ToolResult } from '@xsai/tool'
|
||||||
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
* Converts a set of Agentic stdlib AI functions to an object compatible with
|
||||||
* [the xsAI SDK's](https://github.com/moeru-ai/xsai) `tools` parameter.
|
* [the xsAI SDK's](https://github.com/moeru-ai/xsai) `tools` parameter.
|
||||||
*/
|
*/
|
||||||
export function createXSAISDKTools(
|
export function createXSAITools(
|
||||||
...aiFunctionLikeTools: AIFunctionLike[]
|
...aiFunctionLikeTools: AIFunctionLike[]
|
||||||
): Promise<ToolResult[]> {
|
): Promise<ToolResult[]> {
|
||||||
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
const fns = new AIFunctionSet(aiFunctionLikeTools)
|
||||||
|
|
Ładowanie…
Reference in New Issue