kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/710/head
rodzic
cc8401e464
commit
c044e9e4b0
|
@ -12,15 +12,15 @@ description: Agentic adapter for the LlamaIndex TS SDK.
|
||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```bash npm
|
```bash npm
|
||||||
npm install @agentic/llamaindex llamaindex
|
npm install @agentic/llamaindex llamaindex @llamaindex/openai @llamaindex/workflow
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash yarn
|
```bash yarn
|
||||||
yarn add @agentic/llamaindex llamaindex
|
yarn add @agentic/llamaindex llamaindex @llamaindex/openai @llamaindex/workflow
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash pnpm
|
```bash pnpm
|
||||||
pnpm add @agentic/llamaindex llamaindex
|
pnpm add @agentic/llamaindex llamaindex @llamaindex/openai @llamaindex/workflow
|
||||||
```
|
```
|
||||||
|
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
@ -32,23 +32,25 @@ import 'dotenv/config'
|
||||||
|
|
||||||
import { createLlamaIndexTools } from '@agentic/llamaindex'
|
import { createLlamaIndexTools } from '@agentic/llamaindex'
|
||||||
import { WeatherClient } from '@agentic/stdlib'
|
import { WeatherClient } from '@agentic/stdlib'
|
||||||
import { OpenAI, OpenAIAgent } from 'llamaindex'
|
import { openai } from '@llamaindex/openai'
|
||||||
|
import { agent } from '@llamaindex/workflow'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const weather = new WeatherClient()
|
const weather = new WeatherClient()
|
||||||
|
|
||||||
const tools = createLlamaIndexTools(weather)
|
const tools = createLlamaIndexTools(weather)
|
||||||
const agent = new OpenAIAgent({
|
const weatherAgent = agent({
|
||||||
llm: new OpenAI({ model: 'gpt-4o-mini', temperature: 0 }),
|
name: 'Weather Agent',
|
||||||
|
llm: openai({ model: 'gpt-4o-mini', temperature: 0 }),
|
||||||
systemPrompt: 'You are a helpful assistant. Be as concise as possible.',
|
systemPrompt: 'You are a helpful assistant. Be as concise as possible.',
|
||||||
tools
|
tools
|
||||||
})
|
})
|
||||||
|
|
||||||
const response = await agent.chat({
|
const response = await weatherAgent.run(
|
||||||
message: 'What is the weather in San Francisco?'
|
'What is the weather in San Francisco?'
|
||||||
})
|
)
|
||||||
|
|
||||||
console.log(response.message.content)
|
console.log(response.data.result)
|
||||||
}
|
}
|
||||||
|
|
||||||
await main()
|
await main()
|
||||||
|
|
Ładowanie…
Reference in New Issue