mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-01 22:14:03 -04:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37dcf37625 | |||
| a8c0637d11 | |||
| 387a19284d | |||
| a654f580cf | |||
| 68ea7ec6a5 | |||
| 2d11ffbaea | |||
| 1587e48a14 | |||
| bd239aaf2d | |||
| 98eebf7277 |
+46
-13
@@ -14,13 +14,14 @@ There are some important folders in the repository:
|
||||
all JS runtime environments.
|
||||
- `env`: The environment package of LlamaIndex.TS, which contains the environment-specific classes and interfaces. It
|
||||
includes compatibility layers for Node.js, Deno, Vercel Edge Runtime, Cloudflare Workers...
|
||||
- `providers/*`: The providers package of LlamaIndex.TS, which contains the providers for LLM and other services.
|
||||
- `apps/*`: The applications based on LlamaIndex.TS.
|
||||
- `next`: Our documentation website based on Next.js.
|
||||
- `examples`: The code examples of LlamaIndex.TS using Node.js.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Make sure you have Node.js LIS (Long-term Support) installed. You can check your Node.js version by running:
|
||||
Make sure you have Node.js LTS (Long-term Support) installed. You can check your Node.js version by running:
|
||||
|
||||
```shell
|
||||
node -v
|
||||
@@ -30,7 +31,7 @@ node -v
|
||||
### Use pnpm
|
||||
|
||||
```shell
|
||||
corepack enable
|
||||
npm install -g pnpm
|
||||
```
|
||||
|
||||
### Install dependencies
|
||||
@@ -41,33 +42,65 @@ pnpm install
|
||||
|
||||
### Build the packages
|
||||
|
||||
You'll need Turbo to build the packages. If you don't have it, you can run it with `pnpx`.
|
||||
|
||||
To build all packages, run:
|
||||
|
||||
```shell
|
||||
# Build all packages
|
||||
pnpx turbo build --filter "./packages/*"
|
||||
|
||||
# Or if you have turbo installed, you can run:
|
||||
turbo build --filter "./packages/*"
|
||||
pnpm build
|
||||
```
|
||||
|
||||
### Run tests
|
||||
|
||||
#### Unit tests
|
||||
|
||||
After build, to run all unit tests, call:
|
||||
|
||||
```shell
|
||||
pnpm test
|
||||
```
|
||||
|
||||
Unit tests are located in the `tests` folder of each package. They are using their own package (e.g. `@llamaindex/core-tests` for `@llamaindex/core`). The tests are importing the package under test and the test package is not published.
|
||||
|
||||
#### E2E tests
|
||||
|
||||
To run all E2E tests, call:
|
||||
|
||||
```shell
|
||||
pnpm e2e
|
||||
```
|
||||
|
||||
All E2E tests are in the `e2e` folder.
|
||||
|
||||
### Docs
|
||||
|
||||
See the [docs](./apps/next/README.md) for more information.
|
||||
|
||||
## Changeset
|
||||
## Adding a new package
|
||||
|
||||
Please follow these steps to add a new package:
|
||||
|
||||
1. Only add new packages to the `packages/providers` folder.
|
||||
2. Use the `package.json` and `tsconfig.json` of an existing packages as template.
|
||||
3. Reference your new package in the root `tsconfig.json` file
|
||||
4. Add your package to the `examples/package.json` file if you add a new example.
|
||||
|
||||
## Before sending a PR
|
||||
|
||||
Before sending a PR, make sure of the following:
|
||||
|
||||
1. Tests are all running and you added meaningful tests for your change.
|
||||
2. If you have a new feature, document it in the `apps/next` docs folder.
|
||||
3. If you have a new feature, add a new example in the `examples` folder.
|
||||
4. You have a descriptive changeset for each PR:
|
||||
|
||||
### Changesets
|
||||
|
||||
We use [changesets](https://github.com/changesets/changesets) for managing versions and changelogs. To create a new
|
||||
changeset, run in the root folder:
|
||||
|
||||
```
|
||||
```shell
|
||||
pnpm changeset
|
||||
```
|
||||
|
||||
Please send a descriptive changeset for each PR.
|
||||
|
||||
## Publishing (maintainers only)
|
||||
|
||||
The [Release Github Action](.github/workflows/release.yml) is automatically generating and updating a
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# @llamaindex/doc
|
||||
|
||||
## 0.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a8c0637: feat: simplify to provide base URL to OpenAI
|
||||
- a654f58: Added docs for using perplexity
|
||||
- 98eebf7: Add RequestOptions parameter passing to support Gemini proxy calls.
|
||||
Add a usage example for the RequestOptions parameter.
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 0.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+1
-2
@@ -6,8 +6,7 @@ This is a Next.js application generated with
|
||||
Run development server:
|
||||
|
||||
```bash
|
||||
turbo run dev
|
||||
# turbo will build all required packages before running the dev server
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
## Learn More
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/doc",
|
||||
"version": "0.1.10",
|
||||
"version": "0.1.11",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"postinstall": "fumadocs-mdx",
|
||||
|
||||
@@ -60,7 +60,7 @@ export default function HomePage() {
|
||||
icon={Footprints}
|
||||
subheading="Progressive"
|
||||
heading="From the simplest to the most complex"
|
||||
description="LlamaIndex.TS is designed to be simple to get started, but powerful enough to build complex, agentic AI applications."
|
||||
description="LlamaIndex.TS is designed to be simple to get started, but powerful enough to build complex, agentic AI applications using multi-agents."
|
||||
>
|
||||
<Suspense
|
||||
fallback={
|
||||
@@ -76,44 +76,48 @@ export default function HomePage() {
|
||||
>
|
||||
<MagicMove
|
||||
code={[
|
||||
`import { OpenAI } from "@llamaindex/openai";
|
||||
`import { openai } from "@llamaindex/openai";
|
||||
|
||||
const llm = new OpenAI();
|
||||
const llm = openai();
|
||||
const response = await llm.complete({ prompt: "How are you?" });`,
|
||||
`import { OpenAI } from "@llamaindex/openai";
|
||||
`import { openai } from "@llamaindex/openai";
|
||||
|
||||
const llm = new OpenAI();
|
||||
const llm = openai();
|
||||
const response = await llm.chat({
|
||||
messages: [{ content: "Tell me a joke.", role: "user" }],
|
||||
});`,
|
||||
`import { ChatMemoryBuffer } from "llamaindex";
|
||||
import { OpenAI } from "@llamaindex/openai";
|
||||
`import { agent } from "llamaindex";
|
||||
import { openai } from "@llamaindex/openai";
|
||||
|
||||
const llm = new OpenAI({ model: 'gpt4o-turbo' });
|
||||
const buffer = new ChatMemoryBuffer({
|
||||
tokenLimit: 128_000,
|
||||
})
|
||||
buffer.put({ content: "Tell me a joke.", role: "user" })
|
||||
const response = await llm.chat({
|
||||
messages: buffer.getMessages(),
|
||||
stream: true
|
||||
});`,
|
||||
`import { ChatMemoryBuffer } from "llamaindex";
|
||||
import { OpenAIAgent } from "@llamaindex/openai";
|
||||
|
||||
const agent = new OpenAIAgent({
|
||||
llm,
|
||||
tools: [...myTools]
|
||||
const analyseAgent = agent({
|
||||
llm: openai({ model: "gpt-4o" }),
|
||||
tools: [analyseTools],
|
||||
systemPrompt,
|
||||
});
|
||||
const buffer = new ChatMemoryBuffer({
|
||||
tokenLimit: 128_000,
|
||||
})
|
||||
buffer.put({ content: "Analysis the data based on the given data.", role: "user" })
|
||||
buffer.put({ content: \`\${data}\`, role: "user" })
|
||||
const response = await agent.chat({
|
||||
message: buffer.getMessages(),
|
||||
});`,
|
||||
const response = await analyseAgent.run(\`Analyse the given data:
|
||||
\${data}\`);`,
|
||||
`import { agent, multiAgent } from "llamaindex";
|
||||
import { openai } from "@llamaindex/openai";
|
||||
|
||||
const analyseAgent = agent({
|
||||
name: "AnalyseAgent",
|
||||
llm: openai({ model: "gpt-4o" }),
|
||||
tools: [analyseTools],
|
||||
});
|
||||
const reporterAgent = agent({
|
||||
name: "ReporterAgent",
|
||||
llm: openai({ model: "gpt-4o" }),
|
||||
tools: [reporterTools],
|
||||
canHandoffTo: [analyseAgent],
|
||||
});
|
||||
|
||||
const agents = multiAgent({
|
||||
agents: [analyseAgent, reporterAgent],
|
||||
rootAgent: reporterAgent,
|
||||
});
|
||||
|
||||
const response = await agents.run(\`Analyse the given data:
|
||||
\${data}\`);`,
|
||||
]}
|
||||
/>
|
||||
</Suspense>
|
||||
@@ -125,20 +129,20 @@ const response = await agent.chat({
|
||||
description="Truly powerful retrieval-augmented generation applications use agentic techniques, and LlamaIndex.TS makes it easy to build them."
|
||||
>
|
||||
<CodeBlock
|
||||
code={`import { agent } from "llamaindex";
|
||||
import { OpenAI } from "@llamaindex/openai";
|
||||
code={`import { agent, SimpleDirectoryReader, VectorStoreIndex } from "llamaindex";
|
||||
import { openai } from "@llamaindex/openai";
|
||||
|
||||
// using a previously created LlamaIndex index to query information from
|
||||
const queryTool = index.queryTool();
|
||||
// load documents from current directoy into an index
|
||||
const reader = new SimpleDirectoryReader();
|
||||
const documents = await reader.loadData(currentDir);
|
||||
const index = await VectorStoreIndex.fromDocuments(documents);
|
||||
|
||||
const agent = agent({
|
||||
llm: new OpenAI({
|
||||
model: "gpt-4o",
|
||||
}),
|
||||
tools: [queryTool],
|
||||
const myAgent = agent({
|
||||
llm: openai({ model: "gpt-4o" }),
|
||||
tools: [index.queryTool()],
|
||||
});
|
||||
|
||||
await agent.run('...');`}
|
||||
await myAgent.run('...');`}
|
||||
lang="ts"
|
||||
/>
|
||||
</Feature>
|
||||
|
||||
@@ -7,7 +7,7 @@ import CodeSource from "!raw-loader!../../../../../../../examples/mistral";
|
||||
|
||||
By default LlamaIndex.TS uses OpenAI's LLMs and embedding models, but we support [lots of other LLMs](../modules/llms) including models from Mistral (Mistral, Mixtral), Anthropic (Claude) and Google (Gemini).
|
||||
|
||||
If you don't want to use an API at all you can [run a local model](../../examples/local_llm).
|
||||
If you don't want to use an API at all you can [run a local model](./local_llm).
|
||||
|
||||
This example runs you through the process of setting up a Mistral model:
|
||||
|
||||
|
||||
@@ -106,21 +106,38 @@ Some modules uses `Web Stream` API like `ReadableStream` and `WritableStream`, y
|
||||
}
|
||||
```
|
||||
|
||||
```ts twoslash
|
||||
import { OpenAIAgent } from '@llamaindex/openai'
|
||||
```typescript
|
||||
import { agent, tool } from 'llamaindex'
|
||||
import { openai } from "@llamaindex/openai";
|
||||
|
||||
const agent = new OpenAIAgent({
|
||||
tools: []
|
||||
})
|
||||
Settings.llm = openai({
|
||||
model: "gpt-4o-mini",
|
||||
});
|
||||
|
||||
const response = await agent.chat({
|
||||
message: 'Hello, how are you?',
|
||||
stream: true
|
||||
})
|
||||
for await (const _ of response) {
|
||||
//^?
|
||||
// ...
|
||||
const addTool = tool({
|
||||
name: "add",
|
||||
description: "Adds two numbers",
|
||||
parameters: z.object({x: z.number(), y: z.number()}),
|
||||
execute: ({ x, y }) => x + y,
|
||||
});
|
||||
|
||||
const myAgent = agent({
|
||||
tools: [addTool],
|
||||
});
|
||||
|
||||
// Chat with the agent
|
||||
const context = myAgent.run("Hello, how are you?");
|
||||
|
||||
for await (const event of context) {
|
||||
if (event instanceof AgentStream) {
|
||||
for (const chunk of event.data.delta) {
|
||||
process.stdout.write(chunk); // stream response
|
||||
}
|
||||
} else {
|
||||
console.log(event); // other events
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Run TypeScript Script in Node.js
|
||||
|
||||
@@ -25,15 +25,21 @@ npx tsx example.ts
|
||||
First we'll need to pull in our dependencies. These are:
|
||||
|
||||
- The OpenAI class to use the OpenAI LLM
|
||||
- FunctionTool to provide tools to our agent
|
||||
- OpenAIAgent to create the agent itself
|
||||
- tool to provide tools to our agent
|
||||
- agent to create the single agent
|
||||
- Settings to define some global settings for the library
|
||||
- Dotenv to load our API key from the .env file
|
||||
- Zod to define the schema for our tool
|
||||
|
||||
```javascript
|
||||
import { FunctionTool, Settings } from "llamaindex";
|
||||
import { OpenAI, OpenAIAgent } from "@llamaindex/openai";
|
||||
import "dotenv/config";
|
||||
import {
|
||||
agent,
|
||||
AgentStream,
|
||||
tool,
|
||||
openai,
|
||||
Settings,
|
||||
} from "llamaindex";
|
||||
import { z } from "zod";
|
||||
```
|
||||
|
||||
@@ -42,25 +48,12 @@ import { z } from "zod";
|
||||
We need to tell our OpenAI class where its API key is, and which of OpenAI's models to use. We'll be using `gpt-4o`, which is capable while still being pretty cheap. This is a global setting, so anywhere an LLM is needed will use the same model.
|
||||
|
||||
```javascript
|
||||
Settings.llm = new OpenAI({
|
||||
Settings.llm = openai({
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
model: "gpt-4o",
|
||||
});
|
||||
```
|
||||
|
||||
### Turn on logging
|
||||
|
||||
We want to see what our agent is up to, so we're going to hook into some events that the library generates and print them out. There are several events possible, but we'll specifically tune in to `llm-tool-call` (when a tool is called) and `llm-tool-result` (when it responds).
|
||||
|
||||
```javascript
|
||||
Settings.callbackManager.on("llm-tool-call", (event) => {
|
||||
console.log(event.detail);
|
||||
});
|
||||
Settings.callbackManager.on("llm-tool-result", (event) => {
|
||||
console.log(event.detail);
|
||||
});
|
||||
```
|
||||
|
||||
### Create a function
|
||||
|
||||
We're going to create a very simple function that adds two numbers together. This will be the tool we ask our agent to use.
|
||||
@@ -75,7 +68,7 @@ Note that we're passing in an object with two named parameters, `a` and `b`. Thi
|
||||
|
||||
### Turn the function into a tool for the agent
|
||||
|
||||
This is the most complicated part of creating an agent. We need to define a `FunctionTool`. We have to pass in:
|
||||
This is the most complicated part of creating an agent. We need to define a `tool`. We have to pass in:
|
||||
|
||||
- The function itself (`sumNumbers`)
|
||||
- A name for the function, which the LLM will use to call it
|
||||
@@ -84,7 +77,7 @@ This is the most complicated part of creating an agent. We need to define a `Fun
|
||||
- You can see [more examples of function schemas](https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models).
|
||||
|
||||
```javascript
|
||||
const tool = FunctionTool.from(sumNumbers, {
|
||||
const addTool = tool({
|
||||
name: "sumNumbers",
|
||||
description: "Use this function to sum two numbers",
|
||||
parameters: z.object({
|
||||
@@ -95,13 +88,14 @@ const tool = FunctionTool.from(sumNumbers, {
|
||||
description: "Second number to sum",
|
||||
}),
|
||||
}),
|
||||
execute: sumNumbers,
|
||||
});
|
||||
```
|
||||
|
||||
We then wrap up the tools into an array. We could provide lots of tools this way, but for this example we're just using the one.
|
||||
|
||||
```javascript
|
||||
const tools = [tool];
|
||||
const tools = [addTool];
|
||||
```
|
||||
|
||||
### Create the agent
|
||||
@@ -109,7 +103,7 @@ const tools = [tool];
|
||||
With your LLM already set up and your tools defined, creating an agent is simple:
|
||||
|
||||
```javascript
|
||||
const agent = new OpenAIAgent({ tools });
|
||||
const myAgent = agent({ tools });
|
||||
```
|
||||
|
||||
### Ask the agent a question
|
||||
@@ -117,61 +111,109 @@ const agent = new OpenAIAgent({ tools });
|
||||
We can use the `chat` interface to ask our agent a question, and it will use the tools we've defined to find an answer.
|
||||
|
||||
```javascript
|
||||
let response = await agent.chat({
|
||||
message: "Add 101 and 303",
|
||||
});
|
||||
const context = myAgent.run("Sum 101 and 303");
|
||||
const result = await context;
|
||||
console.log(result.data);
|
||||
```
|
||||
You will see the following output:
|
||||
|
||||
console.log(response);
|
||||
**_Output_**
|
||||
|
||||
```
|
||||
{ result: 'The sum of 101 and 303 is 404.' }
|
||||
```
|
||||
|
||||
To stream the response, you can use the `AgentStream` event which provides chunks of the response as they become available. This allows you to display the response incrementally rather than waiting for the full response:
|
||||
|
||||
```javascript
|
||||
const context = myAgent.run("Add 101 and 303");
|
||||
for await (const event of context) {
|
||||
if (event instanceof AgentStream) {
|
||||
process.stdout.write(event.data.delta);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**_Streaming Output_**
|
||||
|
||||
```
|
||||
The sum of 101 and 303 is 404.
|
||||
```
|
||||
|
||||
### Logging workflow events
|
||||
|
||||
To log the workflow events, you can check the event type and log the event data.
|
||||
|
||||
```javascript
|
||||
const context = myAgent.run("Sum 202 and 404");
|
||||
for await (const event of context) {
|
||||
if (event instanceof AgentStream) {
|
||||
// Stream the response
|
||||
for (const chunk of event.data.delta) {
|
||||
process.stdout.write(chunk);
|
||||
}
|
||||
} else {
|
||||
// Log other events
|
||||
console.log("\nWorkflow event:", JSON.stringify(event, null, 2));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Let's see what running this looks like using `npx tsx agent.ts`
|
||||
|
||||
**_Output_**
|
||||
|
||||
```javascript
|
||||
{
|
||||
toolCall: {
|
||||
id: 'call_ze6A8C3mOUBG4zmXO8Z4CPB5',
|
||||
name: 'sumNumbers',
|
||||
input: { a: 101, b: 303 }
|
||||
```
|
||||
Workflow event: {
|
||||
"data": {
|
||||
"userInput": "Sum 202 and 404"
|
||||
},
|
||||
toolResult: {
|
||||
tool: FunctionTool { _fn: [Function: sumNumbers], _metadata: [Object] },
|
||||
input: { a: 101, b: 303 },
|
||||
output: '404',
|
||||
isError: false
|
||||
}
|
||||
"displayName": "StartEvent"
|
||||
}
|
||||
|
||||
Workflow event: {
|
||||
"data": {
|
||||
"input": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Sum 202 and 404"
|
||||
}
|
||||
],
|
||||
"currentAgentName": "Agent"
|
||||
},
|
||||
"displayName": "AgentInput"
|
||||
}
|
||||
|
||||
Workflow event: {
|
||||
"data": {
|
||||
"input": [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a helpful assistant. Use the provided tools to answer questions."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Sum 202 and 404"
|
||||
}
|
||||
],
|
||||
"currentAgentName": "Agent"
|
||||
},
|
||||
"displayName": "AgentSetup"
|
||||
}
|
||||
|
||||
....
|
||||
|
||||
```
|
||||
|
||||
```javascript
|
||||
{
|
||||
response: {
|
||||
raw: {
|
||||
id: 'chatcmpl-9KwauZku3QOvH78MNvxJs81mDvQYK',
|
||||
object: 'chat.completion',
|
||||
created: 1714778824,
|
||||
model: 'gpt-4-turbo-2024-04-09',
|
||||
choices: [Array],
|
||||
usage: [Object],
|
||||
system_fingerprint: 'fp_ea6eb70039'
|
||||
},
|
||||
message: {
|
||||
content: 'The sum of 101 and 303 is 404.',
|
||||
role: 'assistant',
|
||||
options: {}
|
||||
}
|
||||
},
|
||||
sources: [Getter]
|
||||
}
|
||||
```
|
||||
We're seeing several workflow events being logged:
|
||||
|
||||
We're seeing two pieces of output here. The first is our callback firing when the tool is called. You can see in `toolResult` that the LLM has correctly passed `101` and `303` to our `sumNumbers` function, which adds them up and returns `404`.
|
||||
1. `AgentToolCall` - Shows the agent preparing to call our tool with the numbers 202 and 404
|
||||
2. `AgentToolCallResult` - Shows the result of calling the tool, which returned "606"
|
||||
3. `AgentInput` - Shows the original user input
|
||||
4. `AgentOutput` - Shows the agent's response
|
||||
|
||||
The second piece of output is the response from the LLM itself, where the `message.content` key is giving us the answer.
|
||||
Great! We've built an agent that can understand requests and use tools to fulfill them. Next you can:
|
||||
|
||||
Great! We've built an agent with tool use! Next you can:
|
||||
|
||||
- [See the full code](https://github.com/run-llama/ts-agents/blob/main/1_agent/agent.ts)
|
||||
- [See the full code](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/agentworkflow/blog-writer.ts)
|
||||
- [Switch to a local LLM](3_local_model)
|
||||
- Move on to [add Retrieval-Augmented Generation to your agent](4_agentic_rag)
|
||||
|
||||
@@ -23,70 +23,27 @@ The first time you run it will also automatically download and install the model
|
||||
There are two changes you need to make to the code we already wrote in `1_agent` to get Mixtral 8x7b to work. First, you need to switch to that model. Replace the call to `Settings.llm` with this:
|
||||
|
||||
```javascript
|
||||
Settings.llm = new Ollama({
|
||||
Settings.llm = ollama({
|
||||
model: "mixtral:8x7b",
|
||||
});
|
||||
```
|
||||
|
||||
### Swap to a ReActAgent
|
||||
### Run local agent
|
||||
|
||||
In our original code we used a specific OpenAIAgent, so we'll need to switch to a more generic agent pattern, the ReAct pattern. This is simple: change the `const agent` line in your code to read
|
||||
You can also create local agent by importing `agent` from `llamaindex`.
|
||||
|
||||
```javascript
|
||||
const agent = new ReActAgent({ tools });
|
||||
import { agent } from "llamaindex";
|
||||
|
||||
const workflow = agent({
|
||||
tools: [getWeatherTool],
|
||||
});
|
||||
|
||||
const workflowContext = workflow.run(
|
||||
"What's the weather like in San Francisco?",
|
||||
);
|
||||
```
|
||||
|
||||
(You will also need to bring in `Ollama` and `ReActAgent` in your imports)
|
||||
|
||||
### Run your totally local agent
|
||||
|
||||
Because your embeddings were already local, your agent can now run entirely locally without making any API calls.
|
||||
|
||||
```bash
|
||||
node agent.mjs
|
||||
```
|
||||
|
||||
Note that your model will probably run a lot slower than OpenAI, so be prepared to wait a while!
|
||||
|
||||
**_Output_**
|
||||
|
||||
```javascript
|
||||
{
|
||||
response: {
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: ' Thought: I need to use a tool to add the numbers 101 and 303.\n' +
|
||||
'Action: sumNumbers\n' +
|
||||
'Action Input: {"a": 101, "b": 303}\n' +
|
||||
'\n' +
|
||||
'Observation: 404\n' +
|
||||
'\n' +
|
||||
'Thought: I can answer without using any more tools.\n' +
|
||||
'Answer: The sum of 101 and 303 is 404.'
|
||||
},
|
||||
raw: {
|
||||
model: 'mixtral:8x7b',
|
||||
created_at: '2024-05-09T00:24:30.339473Z',
|
||||
message: [Object],
|
||||
done: true,
|
||||
total_duration: 64678371209,
|
||||
load_duration: 57394551334,
|
||||
prompt_eval_count: 475,
|
||||
prompt_eval_duration: 4163981000,
|
||||
eval_count: 94,
|
||||
eval_duration: 3116692000
|
||||
}
|
||||
},
|
||||
sources: [Getter]
|
||||
}
|
||||
```
|
||||
|
||||
Tada! You can see all of this in the folder `1a_mixtral`.
|
||||
|
||||
### Extending to other examples
|
||||
|
||||
You can use a ReActAgent instead of an OpenAIAgent in any of the further examples below, but keep in mind that GPT-4 is a lot more capable than Mixtral 8x7b, so you may see more errors or failures in reasoning if you are using an entirely local setup.
|
||||
|
||||
### Next steps
|
||||
|
||||
Now you've got a local agent, you can [add Retrieval-Augmented Generation to your agent](4_agentic_rag).
|
||||
|
||||
@@ -37,7 +37,7 @@ import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
||||
We'll be bringing in `SimpleDirectoryReader`, `HuggingFaceEmbedding`, `VectorStoreIndex`, and `QueryEngineTool`, `OpenAIContextAwareAgent` from LlamaIndex.TS, as well as the dependencies we previously used.
|
||||
|
||||
```javascript
|
||||
import { FunctionTool, QueryEngineTool, Settings, VectorStoreIndex } from "llamaindex";
|
||||
import { QueryEngineTool, Settings, VectorStoreIndex } from "llamaindex";
|
||||
import { OpenAI, OpenAIAgent } from "@llamaindex/openai";
|
||||
import { HuggingFaceEmbedding } from "@llamaindex/huggingface";
|
||||
import { SimpleDirectoryReader } from "@llamaindex/readers/directory";
|
||||
@@ -115,10 +115,8 @@ The total budget for the City and County of San Francisco for the fiscal year 20
|
||||
If you prefer more flexibility and don't mind additional complexity, you can create a `QueryEngineTool`. This approach allows you to define the query logic, providing a more tailored way to interact with the data, but note that it introduces a delay due to the extra tool call.
|
||||
|
||||
```javascript
|
||||
const queryEngine = await index.asQueryEngine({ retriever });
|
||||
const tools = [
|
||||
new QueryEngineTool({
|
||||
queryEngine: queryEngine,
|
||||
index.queryTool({
|
||||
metadata: {
|
||||
name: "san_francisco_budget_tool",
|
||||
description: `This tool can answer detailed questions about the individual components of the budget of San Francisco in 2023-2024.`,
|
||||
@@ -127,11 +125,9 @@ const tools = [
|
||||
];
|
||||
|
||||
// Create an agent using the tools array
|
||||
const agent = new OpenAIAgent({ tools });
|
||||
const myAgent = agent({ tools });
|
||||
|
||||
let toolResponse = await agent.chat({
|
||||
message: "What's the budget of San Francisco in 2023-2024?",
|
||||
});
|
||||
let toolResponse = await myAgent.run("What's the budget of San Francisco in 2023-2024?");
|
||||
|
||||
console.log(toolResponse);
|
||||
```
|
||||
|
||||
@@ -7,14 +7,13 @@ In [our third iteration of the agent](https://github.com/run-llama/ts-agents/blo
|
||||
```javascript
|
||||
// define the query engine as a tool
|
||||
const tools = [
|
||||
new QueryEngineTool({
|
||||
queryEngine: queryEngine,
|
||||
index.queryTool({
|
||||
metadata: {
|
||||
name: "san_francisco_budget_tool",
|
||||
description: `This tool can answer detailed questions about the individual components of the budget of San Francisco in 2023-2024.`,
|
||||
},
|
||||
}),
|
||||
FunctionTool.from(sumNumbers, {
|
||||
tool({
|
||||
name: "sumNumbers",
|
||||
description: "Use this function to sum two numbers",
|
||||
parameters: z.object({
|
||||
@@ -25,14 +24,15 @@ const tools = [
|
||||
description: "Second number to sum",
|
||||
}),
|
||||
}),
|
||||
execute: ({ a, b }) => `${a + b}`,
|
||||
}),
|
||||
];
|
||||
```
|
||||
|
||||
You can also use JSON Schema to define the tool parameters as an alternative to Zod.
|
||||
You can also use JSON Schema to define the tool parameters as an alternative to Zod.
|
||||
|
||||
```javascript
|
||||
FunctionTool.from(sumNumbers, {
|
||||
tool(sumNumbers, {
|
||||
name: "sumNumbers",
|
||||
description: "Use this function to sum two numbers",
|
||||
parameters: {
|
||||
@@ -56,22 +56,13 @@ FunctionTool.from(sumNumbers, {
|
||||
These tool descriptions are identical to the ones we previously defined. Now let's ask it 3 questions in a row:
|
||||
|
||||
```javascript
|
||||
let response = await agent.chat({
|
||||
message:
|
||||
"What's the budget of San Francisco for community health in 2023-24?",
|
||||
});
|
||||
let response = await agent.run("What's the budget of San Francisco for community health in 2023-24?");
|
||||
console.log(response);
|
||||
|
||||
let response2 = await agent.chat({
|
||||
message:
|
||||
"What's the budget of San Francisco for public protection in 2023-24?",
|
||||
});
|
||||
let response2 = await agent.run("What's the budget of San Francisco for public protection in 2023-24?");
|
||||
console.log(response2);
|
||||
|
||||
let response3 = await agent.chat({
|
||||
message:
|
||||
"What's the combined budget of San Francisco for community health and public protection in 2023-24?",
|
||||
});
|
||||
let response3 = await agent.run("What's the combined budget of San Francisco for community health and public protection in 2023-24?");
|
||||
console.log(response3);
|
||||
```
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
title: Agent Workflow
|
||||
---
|
||||
|
||||
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
|
||||
import CodeSource from "!raw-loader!../../../../../../../examples/agentworkflow/blog-writer.ts";
|
||||
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
||||
|
||||
Agent Workflows are a powerful system that enables you to create and orchestrate one or multiple agents with tools to perform specific tasks. It's built on top of the base `Workflow` system and provides a streamlined interface for agent interactions.
|
||||
|
||||
@@ -15,11 +12,11 @@ Agent Workflows are a powerful system that enables you to create and orchestrate
|
||||
The simplest use case is creating a single agent with specific tools. Here's an example of creating an assistant that tells jokes:
|
||||
|
||||
```typescript
|
||||
import { agent, FunctionTool } from "llamaindex";
|
||||
import { OpenAI } from "@llamaindex/openai";
|
||||
import { agent, tool } from "llamaindex";
|
||||
import { openai } from "@llamaindex/openai";
|
||||
|
||||
// Define a joke-telling tool
|
||||
const jokeTool = FunctionTool.from(
|
||||
const jokeTool = tool(
|
||||
() => "Baby Llama is called cria",
|
||||
{
|
||||
name: "joke",
|
||||
@@ -28,15 +25,13 @@ const jokeTool = FunctionTool.from(
|
||||
);
|
||||
|
||||
// Create an single agent workflow with the tool
|
||||
const workflow = agent({
|
||||
const jokeAgent = agent({
|
||||
tools: [jokeTool],
|
||||
llm: new OpenAI({
|
||||
model: "gpt-4o-mini",
|
||||
}),
|
||||
llm: openai({ model: "gpt-4o-mini" }),
|
||||
});
|
||||
|
||||
// Run the workflow
|
||||
const result = await workflow.run("Tell me something funny");
|
||||
const result = await jokeAgent.run("Tell me something funny");
|
||||
console.log(result); // Baby Llama is called cria
|
||||
```
|
||||
|
||||
@@ -73,8 +68,8 @@ An Agent Workflow can orchestrate multiple agents, enabling complex interactions
|
||||
Here's an example of a multi-agent system that combines joke-telling and weather information:
|
||||
|
||||
```typescript
|
||||
import { multiAgent, agent, FunctionTool } from "llamaindex";
|
||||
import { OpenAI } from "@llamaindex/openai";
|
||||
import { multiAgent, agent, tool } from "llamaindex";
|
||||
import { openai } from "@llamaindex/openai";
|
||||
import { z } from "zod";
|
||||
|
||||
// Create a weather agent
|
||||
@@ -82,18 +77,18 @@ const weatherAgent = agent({
|
||||
name: "WeatherAgent",
|
||||
description: "Provides weather information for any city",
|
||||
tools: [
|
||||
FunctionTool.from(
|
||||
({ city }: { city: string }) => `The weather in ${city} is sunny`,
|
||||
tool(
|
||||
{
|
||||
name: "fetchWeather",
|
||||
description: "Get weather information for a city",
|
||||
parameters: z.object({
|
||||
city: z.string(),
|
||||
}),
|
||||
execute: ({ city }) => `The weather in ${city} is sunny`,
|
||||
}
|
||||
),
|
||||
],
|
||||
llm: new OpenAI({ model: "gpt-4o-mini" }),
|
||||
llm: openai({ model: "gpt-4o-mini" }),
|
||||
});
|
||||
|
||||
// Create a joke-telling agent
|
||||
@@ -101,18 +96,18 @@ const jokeAgent = agent({
|
||||
name: "JokeAgent",
|
||||
description: "Tells jokes and funny stories",
|
||||
tools: [jokeTool], // Using the joke tool defined earlier
|
||||
llm: new OpenAI({ model: "gpt-4o-mini" }),
|
||||
llm: openai({ model: "gpt-4o-mini" }),
|
||||
canHandoffTo: [weatherAgent], // Can hand off to the weather agent
|
||||
});
|
||||
|
||||
// Create the multi-agent workflow
|
||||
const workflow = multiAgent({
|
||||
const agents = multiAgent({
|
||||
agents: [jokeAgent, weatherAgent],
|
||||
rootAgent: jokeAgent, // Start with the joke agent
|
||||
});
|
||||
|
||||
// Run the workflow
|
||||
const result = await workflow.run(
|
||||
const result = await agents.run(
|
||||
"Give me a morning greeting with a joke and the weather in San Francisco"
|
||||
);
|
||||
```
|
||||
|
||||
@@ -31,6 +31,20 @@ Settings.llm = new Gemini({
|
||||
});
|
||||
```
|
||||
|
||||
## Usage with Proxy
|
||||
|
||||
```ts
|
||||
import { Gemini, GEMINI_MODEL } from "@llamaindex/google";
|
||||
import { Settings } from "llamaindex";
|
||||
|
||||
Settings.llm = new Gemini({
|
||||
model: GEMINI_MODEL.GEMINI_PRO,
|
||||
requestOptions: {
|
||||
baseUrl: <YOUR_PROXY_URL> // optional, but useful for custom endpoints
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Usage with Vertex AI
|
||||
|
||||
To use Gemini via Vertex AI you can use `GeminiVertexSession`.
|
||||
|
||||
@@ -34,6 +34,18 @@ You can setup the apiKey on the environment variables, like:
|
||||
export OPENAI_API_KEY="<YOUR_API_KEY>"
|
||||
```
|
||||
|
||||
You can optionally set a custom base URL, like:
|
||||
|
||||
```bash
|
||||
export OPENAI_BASE_URL="https://api.scaleway.ai/v1"
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```ts
|
||||
Settings.llm = new OpenAI({ model: "gpt-3.5-turbo", temperature: 0, apiKey: <YOUR_API_KEY>, baseURL: "https://api.scaleway.ai/v1" });
|
||||
```
|
||||
|
||||
## Load and index documents
|
||||
|
||||
For this example, we will use a single document. In a real-world scenario, you would have multiple documents to index.
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
---
|
||||
title: Perplexity LLM
|
||||
---
|
||||
## Usage
|
||||
|
||||
|
||||
```ts
|
||||
import { Settings } from "llamaindex";
|
||||
import { perplexity } from "@llamaindex/perplexity";
|
||||
Settings.llm = perplexity({
|
||||
apiKey: "<YOUR_API_KEY>",
|
||||
model: "sonar", // or available models
|
||||
});
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import { perplexity } from "@llamaindex/perplexity";
|
||||
|
||||
const perplexityLlm = perplexity({
|
||||
apiKey: "<YOUR_API_KEY>",
|
||||
model: "sonar", // or avaiable models
|
||||
});
|
||||
|
||||
async function main() {
|
||||
const response = await perplexityLlm.chat({
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: "You are an AI assistant",
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: "Tell me about San Francisco",
|
||||
},
|
||||
],
|
||||
stream: false,
|
||||
});
|
||||
console.log(response);
|
||||
|
||||
const stream = await perplexityLlm.chat({
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: "You are a creative AI assistant that tells engaging stories",
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: "Tell me a short story",
|
||||
},
|
||||
],
|
||||
stream: true,
|
||||
});
|
||||
|
||||
console.log("\nStreaming response:");
|
||||
for await (const chunk of stream) {
|
||||
process.stdout.write(chunk.delta);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Full Example
|
||||
|
||||
```ts
|
||||
import { perplexity } from "@llamaindex/perplexity";
|
||||
import { Document, Settings, VectorStoreIndex } from "llamaindex";
|
||||
|
||||
// Use the perplexity LLM
|
||||
Settings.llm = perplexity({ model: "sonar", apiKey: "<YOUR_API_KEY>" });
|
||||
|
||||
async function main() {
|
||||
const document = new Document({ text: essay, id_: "essay" });
|
||||
|
||||
// Load and index documents
|
||||
const index = await VectorStoreIndex.fromDocuments([document]);
|
||||
|
||||
// get retriever
|
||||
const retriever = index.asRetriever();
|
||||
|
||||
// Create a query engine
|
||||
const queryEngine = index.asQueryEngine({
|
||||
retriever,
|
||||
});
|
||||
|
||||
const query = "What is the meaning of life?";
|
||||
|
||||
// Query
|
||||
const response = await queryEngine.query({
|
||||
query,
|
||||
});
|
||||
|
||||
// Log the response
|
||||
console.log(response.response);
|
||||
}
|
||||
```
|
||||
|
||||
## Available Models
|
||||
|
||||
The following models are available:
|
||||
|
||||
- `sonar`: 128k context window
|
||||
- `sonar-pro`: 200k context window
|
||||
- `sonar-deep-research`: 128k context window
|
||||
- `sonar-reasoning`: 128k context window
|
||||
- `sonar-reasoning-pro`: 128k context window
|
||||
- `r1-1776`: 128k context window
|
||||
|
||||
|
||||
# Limitations
|
||||
|
||||
Currently does not support function calling.
|
||||
|
||||
## API Reference
|
||||
|
||||
- [Perplexity](/docs/api/classes/Perplexity)
|
||||
@@ -29,6 +29,8 @@ Note: calling the `bind` method will return a new `FunctionTool` instance, witho
|
||||
|
||||
Example to pass a `userToken` as additional argument:
|
||||
```ts
|
||||
import { agent, tool } from "llamaindex";
|
||||
|
||||
// first arg is LLM input, second is bound arg
|
||||
const queryKnowledgeBase = async ({ question }, { userToken }) => {
|
||||
const response = await fetch(`https://knowledge-base.com?token=${userToken}&query=${question}`);
|
||||
@@ -36,7 +38,7 @@ const queryKnowledgeBase = async ({ question }, { userToken }) => {
|
||||
};
|
||||
|
||||
// define tool as usual
|
||||
const kbTool = FunctionTool.from(queryKnowledgeBase, {
|
||||
const kbTool = tool(queryKnowledgeBase, {
|
||||
name: 'queryKnowledgeBase',
|
||||
description: 'Query knowledge base',
|
||||
parameters: z.object({
|
||||
@@ -48,7 +50,7 @@ const kbTool = FunctionTool.from(queryKnowledgeBase, {
|
||||
|
||||
// create an agent
|
||||
const additionalArg = { userToken: 'abcd1234' };
|
||||
const kbAgent = new LLMAgent({
|
||||
const workflow = agent({
|
||||
tools: [kbTool.bind(additionalArg)],
|
||||
// llm, systemPrompt etc
|
||||
})
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/cloudflare-worker-agent-test
|
||||
|
||||
## 0.0.145
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 0.0.144
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/cloudflare-worker-agent-test",
|
||||
"version": "0.0.144",
|
||||
"version": "0.0.145",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/next-agent-test
|
||||
|
||||
## 0.1.145
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 0.1.144
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-agent-test",
|
||||
"version": "0.1.144",
|
||||
"version": "0.1.145",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# test-edge-runtime
|
||||
|
||||
## 0.1.144
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 0.1.143
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/nextjs-edge-runtime-test",
|
||||
"version": "0.1.143",
|
||||
"version": "0.1.144",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/next-node-runtime
|
||||
|
||||
## 0.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
- @llamaindex/huggingface@0.0.45
|
||||
|
||||
## 0.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-node-runtime-test",
|
||||
"version": "0.1.10",
|
||||
"version": "0.1.11",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# vite-import-llamaindex
|
||||
|
||||
## 0.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 0.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-import-llamaindex",
|
||||
"private": true,
|
||||
"version": "0.0.10",
|
||||
"version": "0.0.11",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/waku-query-engine-test
|
||||
|
||||
## 0.0.145
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 0.0.144
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/waku-query-engine-test",
|
||||
"version": "0.0.144",
|
||||
"version": "0.0.145",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
# examples
|
||||
|
||||
## 0.2.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1587e48: Added support for Perplexity api
|
||||
- Updated dependencies [387a192]
|
||||
- Updated dependencies [a8c0637]
|
||||
- Updated dependencies [1587e48]
|
||||
- Updated dependencies [98eebf7]
|
||||
- @llamaindex/mistral@0.0.14
|
||||
- @llamaindex/openai@0.1.61
|
||||
- @llamaindex/perplexity@0.0.2
|
||||
- @llamaindex/google@0.1.2
|
||||
- llamaindex@0.9.11
|
||||
- @llamaindex/clip@0.0.45
|
||||
- @llamaindex/deepinfra@0.0.45
|
||||
- @llamaindex/deepseek@0.0.5
|
||||
- @llamaindex/fireworks@0.0.5
|
||||
- @llamaindex/groq@0.0.60
|
||||
- @llamaindex/huggingface@0.0.45
|
||||
- @llamaindex/jinaai@0.0.5
|
||||
- @llamaindex/together@0.0.5
|
||||
- @llamaindex/vllm@0.0.31
|
||||
|
||||
## 0.2.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,41 +1,31 @@
|
||||
import { FunctionTool } from "llamaindex";
|
||||
import { tool } from "llamaindex";
|
||||
import { z } from "zod";
|
||||
|
||||
export const getCurrentIDTool = FunctionTool.from(
|
||||
() => {
|
||||
export const getCurrentIDTool = tool({
|
||||
name: "get_user_id",
|
||||
description: "Get a random user id",
|
||||
parameters: z.object({}),
|
||||
execute: () => {
|
||||
console.log("Getting user id...");
|
||||
return crypto.randomUUID();
|
||||
},
|
||||
{
|
||||
name: "get_user_id",
|
||||
description: "Get a random user id",
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
export const getUserInfoTool = FunctionTool.from(
|
||||
({ userId }: { userId: string }) => {
|
||||
console.log("Getting user info...", userId);
|
||||
return `Name: Alex; Address: 1234 Main St, CA; User ID: ${userId}`;
|
||||
},
|
||||
{
|
||||
name: "get_user_info",
|
||||
description: "Get user info",
|
||||
parameters: z.object({
|
||||
userId: z.string().describe("The user id"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
export const getUserInfoTool = tool({
|
||||
name: "get_user_info",
|
||||
description: "Get user info",
|
||||
parameters: z.object({
|
||||
userId: z.string().describe("The user id"),
|
||||
}),
|
||||
execute: ({ userId }) =>
|
||||
`Name: Alex; Address: 1234 Main St, CA; User ID: ${userId}`,
|
||||
});
|
||||
|
||||
export const getWeatherTool = FunctionTool.from(
|
||||
({ address }: { address: string }) => {
|
||||
console.log("Getting weather...", address);
|
||||
return `${address} is in a sunny location!`;
|
||||
},
|
||||
{
|
||||
name: "get_weather",
|
||||
description: "Get the current weather for a location",
|
||||
parameters: z.object({
|
||||
address: z.string().describe("The address"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
export const getWeatherTool = tool({
|
||||
name: "get_weather",
|
||||
description: "Get the current weather for a location",
|
||||
parameters: z.object({
|
||||
address: z.string().describe("The address"),
|
||||
}),
|
||||
execute: ({ address }) => `${address} is in a sunny location!`,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { ollama } from "@llamaindex/ollama";
|
||||
import { agent } from "llamaindex";
|
||||
import { getWeatherTool } from "../agent/utils/tools";
|
||||
|
||||
async function main() {
|
||||
const myAgent = agent({
|
||||
tools: [getWeatherTool],
|
||||
verbose: false,
|
||||
llm: ollama({ model: "granite3.2:2b" }),
|
||||
});
|
||||
|
||||
const sfResult = await myAgent.run(
|
||||
"What's the weather like in San Francisco?",
|
||||
);
|
||||
// The weather in San Francisco, CA is currently sunny.
|
||||
console.log(`${JSON.stringify(sfResult, null, 2)}`);
|
||||
|
||||
// Reuse the context from the previous run
|
||||
const caResult = await myAgent.run("Compare it with California?");
|
||||
|
||||
// Both San Francisco and California are currently experiencing sunny weather.
|
||||
console.log(`${JSON.stringify(caResult, null, 2)}`);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
+19
-31
@@ -1,43 +1,31 @@
|
||||
import { Anthropic, AnthropicAgent } from "@llamaindex/anthropic";
|
||||
import { FunctionTool, Settings } from "llamaindex";
|
||||
import { anthropic } from "@llamaindex/anthropic";
|
||||
import { agent, tool } from "llamaindex";
|
||||
import { z } from "zod";
|
||||
import { WikipediaTool } from "../wiki";
|
||||
|
||||
Settings.callbackManager.on("llm-tool-call", (event) => {
|
||||
console.log("llm-tool-call", event.detail.toolCall);
|
||||
});
|
||||
|
||||
const anthropic = new Anthropic({
|
||||
apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
model: "claude-3-7-sonnet",
|
||||
});
|
||||
|
||||
const agent = new AnthropicAgent({
|
||||
llm: anthropic,
|
||||
const workflow = agent({
|
||||
tools: [
|
||||
FunctionTool.from(
|
||||
(query) => {
|
||||
return `The weather in ${query.location} is sunny`;
|
||||
},
|
||||
{
|
||||
name: "weather",
|
||||
description: "Get the weather",
|
||||
parameters: z.object({
|
||||
location: z.string().describe("The location to get the weather for"),
|
||||
}),
|
||||
},
|
||||
),
|
||||
tool({
|
||||
name: "weather",
|
||||
description: "Get the weather",
|
||||
parameters: z.object({
|
||||
location: z.string().describe("The location to get the weather for"),
|
||||
}),
|
||||
execute: ({ location }) => `The weather in ${location} is sunny`,
|
||||
}),
|
||||
new WikipediaTool(),
|
||||
],
|
||||
llm: anthropic({
|
||||
apiKey: process.env.ANTHROPIC_API_KEY,
|
||||
model: "claude-3-7-sonnet",
|
||||
}),
|
||||
});
|
||||
|
||||
async function main() {
|
||||
const { message } = await agent.chat({
|
||||
message:
|
||||
"What is the weather in New York? What's the history of New York from Wikipedia in 3 sentences?",
|
||||
});
|
||||
|
||||
console.log(message.content);
|
||||
const result = await workflow.run(
|
||||
"What is the weather in New York? What's the history of New York from Wikipedia in 3 sentences?",
|
||||
);
|
||||
console.log(result.data);
|
||||
}
|
||||
|
||||
void main();
|
||||
|
||||
+33
-51
@@ -1,65 +1,47 @@
|
||||
import { Gemini, GEMINI_MODEL } from "@llamaindex/google";
|
||||
import { FunctionTool, LLMAgent, Settings } from "llamaindex";
|
||||
import { gemini, GEMINI_MODEL } from "@llamaindex/google";
|
||||
import { agent, tool } from "llamaindex";
|
||||
import { z } from "zod";
|
||||
|
||||
Settings.callbackManager.on("llm-tool-call", (event) => {
|
||||
console.log(event.detail);
|
||||
const sumNumbers = tool({
|
||||
name: "sumNumbers",
|
||||
description: "Use this function to sum two numbers",
|
||||
parameters: z.object({
|
||||
a: z.number().describe("The first number"),
|
||||
b: z.number().describe("The second number"),
|
||||
}),
|
||||
execute: ({ a, b }) => `${a + b}`,
|
||||
});
|
||||
|
||||
Settings.callbackManager.on("llm-tool-result", (event) => {
|
||||
console.log(event.detail);
|
||||
const divideNumbers = tool({
|
||||
name: "divideNumbers",
|
||||
description: "Use this function to divide two numbers",
|
||||
parameters: z.object({
|
||||
a: z.number().describe("The dividend a to divide"),
|
||||
b: z.number().describe("The divisor b to divide by"),
|
||||
}),
|
||||
execute: ({ a, b }) => `${a / b}`,
|
||||
});
|
||||
|
||||
const sumNumbers = FunctionTool.from(
|
||||
({ a, b }: { a: number; b: number }) => `${a + b}`,
|
||||
{
|
||||
name: "sumNumbers",
|
||||
description: "Use this function to sum two numbers",
|
||||
parameters: z.object({
|
||||
a: z.number().describe("The first number"),
|
||||
b: z.number().describe("The second number"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
const divideNumbers = FunctionTool.from(
|
||||
({ a, b }: { a: number; b: number }) => `${a / b}`,
|
||||
{
|
||||
name: "divideNumbers",
|
||||
description: "Use this function to divide two numbers",
|
||||
parameters: z.object({
|
||||
a: z.number().describe("The dividend a to divide"),
|
||||
b: z.number().describe("The divisor b to divide by"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
const subtractNumbers = FunctionTool.from(
|
||||
({ a, b }: { a: number; b: number }) => `${a - b}`,
|
||||
{
|
||||
name: "subtractNumbers",
|
||||
description: "Use this function to subtract two numbers",
|
||||
parameters: z.object({
|
||||
a: z.number().describe("The number to subtract from"),
|
||||
b: z.number().describe("The number to subtract"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
const subtractNumbers = tool({
|
||||
name: "subtractNumbers",
|
||||
description: "Use this function to subtract two numbers",
|
||||
parameters: z.object({
|
||||
a: z.number().describe("The number to subtract from"),
|
||||
b: z.number().describe("The number to subtract"),
|
||||
}),
|
||||
execute: ({ a, b }) => `${a - b}`,
|
||||
});
|
||||
|
||||
async function main() {
|
||||
const gemini = new Gemini({
|
||||
model: GEMINI_MODEL.GEMINI_PRO,
|
||||
});
|
||||
const agent = new LLMAgent({
|
||||
llm: gemini,
|
||||
const myAgent = agent({
|
||||
tools: [sumNumbers, divideNumbers, subtractNumbers],
|
||||
llm: gemini({ model: GEMINI_MODEL.GEMINI_PRO }),
|
||||
});
|
||||
|
||||
const response = await agent.chat({
|
||||
message: "How much is 5 + 5? then divide by 2 then subtract 1",
|
||||
});
|
||||
|
||||
console.log(response.message);
|
||||
const result = await myAgent.run(
|
||||
"How much is 5 + 5? then divide by 2 then subtract 1",
|
||||
);
|
||||
console.log(result.data);
|
||||
}
|
||||
|
||||
void main().then(() => {
|
||||
|
||||
+15
-14
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/examples",
|
||||
"version": "0.2.9",
|
||||
"version": "0.2.10",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
@@ -15,23 +15,23 @@
|
||||
"@llamaindex/astra": "^0.0.13",
|
||||
"@llamaindex/azure": "^0.1.8",
|
||||
"@llamaindex/chroma": "^0.0.13",
|
||||
"@llamaindex/clip": "^0.0.44",
|
||||
"@llamaindex/clip": "^0.0.45",
|
||||
"@llamaindex/cloud": "^3.0.9",
|
||||
"@llamaindex/cohere": "^0.0.13",
|
||||
"@llamaindex/core": "^0.5.8",
|
||||
"@llamaindex/deepinfra": "^0.0.44",
|
||||
"@llamaindex/deepinfra": "^0.0.45",
|
||||
"@llamaindex/env": "^0.1.29",
|
||||
"@llamaindex/firestore": "^1.0.6",
|
||||
"@llamaindex/google": "^0.1.1",
|
||||
"@llamaindex/groq": "^0.0.59",
|
||||
"@llamaindex/huggingface": "^0.0.44",
|
||||
"@llamaindex/google": "^0.1.2",
|
||||
"@llamaindex/groq": "^0.0.60",
|
||||
"@llamaindex/huggingface": "^0.0.45",
|
||||
"@llamaindex/milvus": "^0.1.8",
|
||||
"@llamaindex/mistral": "^0.0.13",
|
||||
"@llamaindex/mistral": "^0.0.14",
|
||||
"@llamaindex/mixedbread": "^0.0.13",
|
||||
"@llamaindex/mongodb": "^0.0.13",
|
||||
"@llamaindex/node-parser": "^1.0.8",
|
||||
"@llamaindex/ollama": "^0.0.48",
|
||||
"@llamaindex/openai": "^0.1.60",
|
||||
"@llamaindex/openai": "^0.1.61",
|
||||
"@llamaindex/pinecone": "^0.0.13",
|
||||
"@llamaindex/portkey-ai": "^0.0.41",
|
||||
"@llamaindex/postgres": "^0.0.41",
|
||||
@@ -40,14 +40,15 @@
|
||||
"@llamaindex/replicate": "^0.0.41",
|
||||
"@llamaindex/upstash": "^0.0.13",
|
||||
"@llamaindex/vercel": "^0.0.19",
|
||||
"@llamaindex/vllm": "^0.0.30",
|
||||
"@llamaindex/vllm": "^0.0.31",
|
||||
"@llamaindex/voyage-ai": "^1.0.5",
|
||||
"@llamaindex/weaviate": "^0.0.13",
|
||||
"@llamaindex/workflow": "^0.0.16",
|
||||
"@llamaindex/deepseek": "^0.0.4",
|
||||
"@llamaindex/fireworks": "^0.0.4",
|
||||
"@llamaindex/together": "^0.0.4",
|
||||
"@llamaindex/jinaai": "^0.0.4",
|
||||
"@llamaindex/deepseek": "^0.0.5",
|
||||
"@llamaindex/fireworks": "^0.0.5",
|
||||
"@llamaindex/together": "^0.0.5",
|
||||
"@llamaindex/jinaai": "^0.0.5",
|
||||
"@llamaindex/perplexity": "^0.0.2",
|
||||
"@notionhq/client": "^2.2.15",
|
||||
"@pinecone-database/pinecone": "^4.0.0",
|
||||
"@vercel/postgres": "^0.10.0",
|
||||
@@ -56,7 +57,7 @@
|
||||
"commander": "^12.1.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"js-tiktoken": "^1.0.14",
|
||||
"llamaindex": "^0.9.10",
|
||||
"llamaindex": "^0.9.11",
|
||||
"mongodb": "6.7.0",
|
||||
"postgres": "^3.4.4",
|
||||
"wikipedia": "^2.1.2",
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { perplexity } from "@llamaindex/perplexity";
|
||||
|
||||
(async () => {
|
||||
const perplexityLLM = perplexity({
|
||||
apiKey: process.env.PERPLEXITY_API_KEY!,
|
||||
model: "sonar",
|
||||
});
|
||||
|
||||
// Chat API example
|
||||
const response = await perplexityLLM.chat({
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content:
|
||||
"You are a helpful AI assistant that provides accurate and concise answers",
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: "What is the capital of France?",
|
||||
},
|
||||
],
|
||||
});
|
||||
console.log("Chat response:", response.message.content);
|
||||
|
||||
// Streaming example
|
||||
const stream = await perplexityLLM.chat({
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: "You are a creative AI assistant that tells engaging stories",
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: "Tell me a short story",
|
||||
},
|
||||
],
|
||||
stream: true,
|
||||
});
|
||||
|
||||
console.log("\nStreaming response:");
|
||||
for await (const chunk of stream) {
|
||||
process.stdout.write(chunk.delta);
|
||||
}
|
||||
})();
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/autotool
|
||||
|
||||
## 6.0.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 6.0.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/autotool-01-node-example
|
||||
|
||||
## 0.0.92
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
- @llamaindex/autotool@6.0.11
|
||||
|
||||
## 0.0.91
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
"scripts": {
|
||||
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
|
||||
},
|
||||
"version": "0.0.91"
|
||||
"version": "0.0.92"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
|
||||
"directory": "packages/autotool"
|
||||
},
|
||||
"version": "6.0.10",
|
||||
"version": "6.0.11",
|
||||
"description": "auto transpile your JS function to LLM Agent compatible",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/experimental
|
||||
|
||||
## 0.0.161
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 0.0.160
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/experimental",
|
||||
"description": "Experimental package for LlamaIndexTS",
|
||||
"version": "0.0.160",
|
||||
"version": "0.0.161",
|
||||
"type": "module",
|
||||
"types": "dist/type/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# llamaindex
|
||||
|
||||
## 0.9.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.9.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "llamaindex",
|
||||
"version": "0.9.10",
|
||||
"version": "0.9.11",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/clip
|
||||
|
||||
## 0.0.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/clip",
|
||||
"description": "Clip Embedding Adapter for LlamaIndex",
|
||||
"version": "0.0.44",
|
||||
"version": "0.0.45",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/deepinfra
|
||||
|
||||
## 0.0.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/deepinfra",
|
||||
"description": "Deepinfra Adapter for LlamaIndex",
|
||||
"version": "0.0.44",
|
||||
"version": "0.0.45",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/deepseek
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/deepseek",
|
||||
"description": "DeepSeek Adapter for LlamaIndex",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/fireworks
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/fireworks",
|
||||
"description": "Fireworks Adapter for LlamaIndex",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/google
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 98eebf7: Add RequestOptions parameter passing to support Gemini proxy calls.
|
||||
Add a usage example for the RequestOptions parameter.
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/google",
|
||||
"description": "Google Adapter for LlamaIndex",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
type EnhancedGenerateContentResponse,
|
||||
type FunctionCall,
|
||||
type ModelParams as GoogleModelParams,
|
||||
type RequestOptions as GoogleRequestOptions,
|
||||
type GenerateContentStreamResult as GoogleStreamGenerateContentResult,
|
||||
} from "@google/generative-ai";
|
||||
|
||||
@@ -86,6 +87,7 @@ const DEFAULT_GEMINI_PARAMS = {
|
||||
|
||||
export type GeminiConfig = Partial<typeof DEFAULT_GEMINI_PARAMS> & {
|
||||
session?: IGeminiSession;
|
||||
requestOptions?: GoogleRequestOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -104,11 +106,17 @@ export class GeminiSession implements IGeminiSession {
|
||||
this.gemini = new GoogleGenerativeAI(options.apiKey);
|
||||
}
|
||||
|
||||
getGenerativeModel(metadata: GoogleModelParams): GoogleGenerativeModel {
|
||||
return this.gemini.getGenerativeModel({
|
||||
safetySettings: DEFAULT_SAFETY_SETTINGS,
|
||||
...metadata,
|
||||
});
|
||||
getGenerativeModel(
|
||||
metadata: GoogleModelParams,
|
||||
requestOpts?: GoogleRequestOptions,
|
||||
): GoogleGenerativeModel {
|
||||
return this.gemini.getGenerativeModel(
|
||||
{
|
||||
safetySettings: DEFAULT_SAFETY_SETTINGS,
|
||||
...metadata,
|
||||
},
|
||||
requestOpts,
|
||||
);
|
||||
}
|
||||
|
||||
getResponseText(response: EnhancedGenerateContentResponse): string {
|
||||
@@ -173,6 +181,9 @@ export class GeminiSessionStore {
|
||||
o1: GeminiSessionOptions,
|
||||
o2: GeminiSessionOptions,
|
||||
): boolean {
|
||||
// #TODO: check if the session is matched
|
||||
// Q: should we check the requestOptions?
|
||||
// A: wait for confirmation from author
|
||||
return (
|
||||
GeminiSessionStore.getSessionId(o1) ===
|
||||
GeminiSessionStore.getSessionId(o2)
|
||||
@@ -205,6 +216,7 @@ export class Gemini extends ToolCallLLM<GeminiAdditionalChatOptions> {
|
||||
temperature: number;
|
||||
topP: number;
|
||||
maxTokens?: number | undefined;
|
||||
#requestOptions?: GoogleRequestOptions | undefined;
|
||||
session: IGeminiSession;
|
||||
|
||||
constructor(init?: GeminiConfig) {
|
||||
@@ -214,6 +226,7 @@ export class Gemini extends ToolCallLLM<GeminiAdditionalChatOptions> {
|
||||
this.topP = init?.topP ?? 1;
|
||||
this.maxTokens = init?.maxTokens ?? undefined;
|
||||
this.session = init?.session ?? GeminiSessionStore.get();
|
||||
this.#requestOptions = init?.requestOptions ?? undefined;
|
||||
}
|
||||
|
||||
get supportToolCall(): boolean {
|
||||
@@ -260,7 +273,10 @@ export class Gemini extends ToolCallLLM<GeminiAdditionalChatOptions> {
|
||||
params: GeminiChatParamsNonStreaming,
|
||||
): Promise<GeminiChatNonStreamResponse> {
|
||||
const context = getChatContext(params);
|
||||
const client = this.session.getGenerativeModel(this.metadata);
|
||||
const client = this.session.getGenerativeModel(
|
||||
this.metadata,
|
||||
this.#requestOptions,
|
||||
);
|
||||
const chat = client.startChat(this.createStartChatParams(params));
|
||||
const { response } = await chat.sendMessage(context.message);
|
||||
const topCandidate = response.candidates![0]!;
|
||||
@@ -286,7 +302,10 @@ export class Gemini extends ToolCallLLM<GeminiAdditionalChatOptions> {
|
||||
params: GeminiChatParamsStreaming,
|
||||
): GeminiChatStreamResponse {
|
||||
const context = getChatContext(params);
|
||||
const client = this.session.getGenerativeModel(this.metadata);
|
||||
const client = this.session.getGenerativeModel(
|
||||
this.metadata,
|
||||
this.#requestOptions,
|
||||
);
|
||||
const chat = client.startChat(this.createStartChatParams(params));
|
||||
const result = await chat.sendMessageStream(context.message);
|
||||
yield* this.session.getChatStream(result);
|
||||
@@ -314,8 +333,10 @@ export class Gemini extends ToolCallLLM<GeminiAdditionalChatOptions> {
|
||||
params: LLMCompletionParamsStreaming | LLMCompletionParamsNonStreaming,
|
||||
): Promise<CompletionResponse | AsyncIterable<CompletionResponse>> {
|
||||
const { prompt, stream } = params;
|
||||
const client = this.session.getGenerativeModel(this.metadata);
|
||||
|
||||
const client = this.session.getGenerativeModel(
|
||||
this.metadata,
|
||||
this.#requestOptions,
|
||||
);
|
||||
if (stream) {
|
||||
const result = await client.generateContentStream(
|
||||
getPartsText(
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
type InlineDataPart as GoogleInlineFileDataPart,
|
||||
type ModelParams as GoogleModelParams,
|
||||
type Part as GooglePart,
|
||||
type RequestOptions as GoogleRequestOptions,
|
||||
type GenerateContentStreamResult as GoogleStreamGenerateContentResult,
|
||||
} from "@google/generative-ai";
|
||||
|
||||
@@ -35,6 +36,8 @@ import type {
|
||||
ToolCallLLMMessageOptions,
|
||||
} from "@llamaindex/core/llms";
|
||||
|
||||
export { type RequestOptions as GoogleRequestOptions } from "@google/generative-ai";
|
||||
|
||||
export enum GEMINI_BACKENDS {
|
||||
GOOGLE = "google",
|
||||
VERTEX = "vertex",
|
||||
@@ -121,7 +124,10 @@ export type GeminiChatNonStreamResponse =
|
||||
ChatResponse<ToolCallLLMMessageOptions>;
|
||||
|
||||
export interface IGeminiSession {
|
||||
getGenerativeModel(metadata: ModelParams): GenerativeModel;
|
||||
getGenerativeModel(
|
||||
metadata: ModelParams,
|
||||
requestOptions?: GoogleRequestOptions,
|
||||
): GenerativeModel;
|
||||
getResponseText(
|
||||
response: EnhancedGenerateContentResponse | GenerateContentResponse,
|
||||
): string;
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/groq
|
||||
|
||||
## 0.0.60
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.59
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/groq",
|
||||
"description": "Groq Adapter for LlamaIndex",
|
||||
"version": "0.0.59",
|
||||
"version": "0.0.60",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/huggingface
|
||||
|
||||
## 0.0.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.44
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/huggingface",
|
||||
"description": "Huggingface Adapter for LlamaIndex",
|
||||
"version": "0.0.44",
|
||||
"version": "0.0.45",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/jinaai
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/jinaai",
|
||||
"description": "JinaAI Adapter for LlamaIndex",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/mistral
|
||||
|
||||
## 0.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 387a192: Update mistral package for mistral API 1.5.1
|
||||
|
||||
## 0.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/mistral",
|
||||
"description": "Mistral Adapter for LlamaIndex",
|
||||
"version": "0.0.13",
|
||||
"version": "0.0.14",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
@@ -35,6 +35,6 @@
|
||||
"dependencies": {
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"@mistralai/mistralai": "^1.3.4"
|
||||
"@mistralai/mistralai": "^1.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ export class MistralAIEmbedding extends BaseEmbedding {
|
||||
|
||||
private async getMistralAIEmbedding(input: string) {
|
||||
const client = await this.session.getClient();
|
||||
const { data } = await client.embeddings({
|
||||
const { data } = await client.embeddings.create({
|
||||
model: this.model,
|
||||
input: [input],
|
||||
inputs: [input],
|
||||
});
|
||||
|
||||
return data[0].embedding;
|
||||
return data[0]?.embedding ?? [];
|
||||
}
|
||||
|
||||
async getTextEmbedding(text: string): Promise<number[]> {
|
||||
|
||||
@@ -7,6 +7,8 @@ import {
|
||||
type LLMChatParamsStreaming,
|
||||
} from "@llamaindex/core/llms";
|
||||
import { getEnv } from "@llamaindex/env";
|
||||
import { type Mistral } from "@mistralai/mistralai";
|
||||
import type { ContentChunk } from "@mistralai/mistralai/models/components";
|
||||
|
||||
export const ALL_AVAILABLE_MISTRAL_MODELS = {
|
||||
"mistral-tiny": { contextWindow: 32000 },
|
||||
@@ -30,7 +32,7 @@ export class MistralAISession {
|
||||
}
|
||||
}
|
||||
|
||||
async getClient() {
|
||||
async getClient(): Promise<Mistral> {
|
||||
const { Mistral } = await import("@mistralai/mistralai");
|
||||
if (!this.client) {
|
||||
this.client = new Mistral({
|
||||
@@ -105,11 +107,21 @@ export class MistralAI extends BaseLLM {
|
||||
}
|
||||
// Non-streaming
|
||||
const client = await this.session.getClient();
|
||||
const response = await client.chat(this.buildParams(messages));
|
||||
const message = response.choices[0].message;
|
||||
const response = await client.chat.complete(this.buildParams(messages));
|
||||
|
||||
if (!response || !response.choices || !response.choices[0]) {
|
||||
throw new Error("Unexpected response format from Mistral API");
|
||||
}
|
||||
|
||||
// Extract the content from the message response
|
||||
const content = response.choices[0].message.content;
|
||||
|
||||
return {
|
||||
raw: response,
|
||||
message,
|
||||
message: {
|
||||
role: "assistant",
|
||||
content: this.extractContentAsString(content),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -117,23 +129,32 @@ export class MistralAI extends BaseLLM {
|
||||
messages,
|
||||
}: LLMChatParamsStreaming): AsyncIterable<ChatResponseChunk> {
|
||||
const client = await this.session.getClient();
|
||||
const chunkStream = await client.chatStream(this.buildParams(messages));
|
||||
const chunkStream = await client.chat.stream(this.buildParams(messages));
|
||||
|
||||
//Indices
|
||||
let idx_counter: number = 0;
|
||||
for await (const part of chunkStream) {
|
||||
if (!part.choices.length) continue;
|
||||
for await (const chunk of chunkStream) {
|
||||
if (!chunk.data || !chunk.data.choices || !chunk.data.choices.length)
|
||||
continue;
|
||||
|
||||
part.choices[0].index = idx_counter;
|
||||
|
||||
idx_counter++;
|
||||
const choice = chunk.data.choices[0];
|
||||
if (!choice) continue;
|
||||
|
||||
yield {
|
||||
raw: part,
|
||||
delta: part.choices[0].delta.content ?? "",
|
||||
raw: chunk.data,
|
||||
delta: this.extractContentAsString(choice.delta.content),
|
||||
};
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private extractContentAsString(
|
||||
content: string | ContentChunk[] | null | undefined,
|
||||
): string {
|
||||
if (Array.isArray(content)) {
|
||||
return content
|
||||
.map((chunk) => (chunk.type === "text" ? chunk.text : undefined))
|
||||
.filter(Boolean)
|
||||
.join("");
|
||||
}
|
||||
return content ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/openai
|
||||
|
||||
## 0.1.61
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a8c0637: feat: simplify to provide base URL to OpenAI
|
||||
|
||||
## 0.1.60
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/openai",
|
||||
"description": "OpenAI Adapter for LlamaIndex",
|
||||
"version": "0.1.60",
|
||||
"version": "0.1.61",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -36,7 +36,10 @@ export const ALL_OPENAI_EMBEDDING_MODELS = {
|
||||
|
||||
type ModelKeys = keyof typeof ALL_OPENAI_EMBEDDING_MODELS;
|
||||
|
||||
type LLMInstance = Pick<AzureOpenAILLM | OpenAILLM, "embeddings" | "apiKey">;
|
||||
type LLMInstance = Pick<
|
||||
AzureOpenAILLM | OpenAILLM,
|
||||
"embeddings" | "apiKey" | "baseURL"
|
||||
>;
|
||||
|
||||
export class OpenAIEmbedding extends BaseEmbedding {
|
||||
/** embeddding model. defaults to "text-embedding-ada-002" */
|
||||
@@ -48,6 +51,8 @@ export class OpenAIEmbedding extends BaseEmbedding {
|
||||
|
||||
/** api key */
|
||||
apiKey?: string | undefined = undefined;
|
||||
/** base url */
|
||||
baseURL?: string | undefined = undefined;
|
||||
/** maximum number of retries, default 10 */
|
||||
maxRetries: number;
|
||||
/** timeout in ms, default 60 seconds */
|
||||
@@ -104,6 +109,10 @@ export class OpenAIEmbedding extends BaseEmbedding {
|
||||
};
|
||||
this.apiKey =
|
||||
init?.session?.apiKey ?? azureConfig.apiKey ?? getEnv("OPENAI_API_KEY");
|
||||
this.baseURL =
|
||||
init?.session?.baseURL ??
|
||||
azureConfig.baseURL ??
|
||||
getEnv("OPENAI_BASE_URL");
|
||||
this.lazySession = async () =>
|
||||
import("openai").then(async ({ AzureOpenAI }) => {
|
||||
AzureOpenAI = AzureOpenAIWithUserAgent(AzureOpenAI);
|
||||
@@ -121,12 +130,15 @@ export class OpenAIEmbedding extends BaseEmbedding {
|
||||
} else {
|
||||
this.apiKey =
|
||||
init?.session?.apiKey ?? init?.apiKey ?? getEnv("OPENAI_API_KEY");
|
||||
this.baseURL =
|
||||
init?.session?.baseURL ?? init?.baseURL ?? getEnv("OPENAI_BASE_URL");
|
||||
this.lazySession = async () =>
|
||||
import("openai").then(({ OpenAI }) => {
|
||||
return (
|
||||
init?.session ??
|
||||
new OpenAI({
|
||||
apiKey: this.apiKey,
|
||||
baseURL: this.baseURL,
|
||||
maxRetries: this.maxRetries,
|
||||
timeout: this.timeout!,
|
||||
...this.additionalSessionOptions,
|
||||
|
||||
@@ -182,7 +182,10 @@ export type OpenAIAdditionalChatOptions = Omit<
|
||||
| "toolChoice"
|
||||
>;
|
||||
|
||||
type LLMInstance = Pick<AzureOpenAILLM | OpenAILLM, "chat" | "apiKey">;
|
||||
type LLMInstance = Pick<
|
||||
AzureOpenAILLM | OpenAILLM,
|
||||
"chat" | "apiKey" | "baseURL"
|
||||
>;
|
||||
|
||||
export class OpenAI extends ToolCallLLM<OpenAIAdditionalChatOptions> {
|
||||
model:
|
||||
@@ -197,6 +200,7 @@ export class OpenAI extends ToolCallLLM<OpenAIAdditionalChatOptions> {
|
||||
|
||||
// OpenAI session params
|
||||
apiKey?: string | undefined = undefined;
|
||||
baseURL?: string | undefined = undefined;
|
||||
maxRetries: number;
|
||||
timeout?: number;
|
||||
additionalSessionOptions?:
|
||||
@@ -234,6 +238,8 @@ export class OpenAI extends ToolCallLLM<OpenAIAdditionalChatOptions> {
|
||||
this.additionalSessionOptions = init?.additionalSessionOptions;
|
||||
this.apiKey =
|
||||
init?.session?.apiKey ?? init?.apiKey ?? getEnv("OPENAI_API_KEY");
|
||||
this.baseURL =
|
||||
init?.session?.baseURL ?? init?.baseURL ?? getEnv("OPENAI_BASE_URL");
|
||||
|
||||
if (init?.azure || shouldUseAzure()) {
|
||||
const azureConfig = {
|
||||
@@ -261,6 +267,7 @@ export class OpenAI extends ToolCallLLM<OpenAIAdditionalChatOptions> {
|
||||
import("openai").then(({ OpenAI }) => {
|
||||
return new OpenAI({
|
||||
apiKey: this.apiKey,
|
||||
baseURL: this.baseURL,
|
||||
maxRetries: this.maxRetries,
|
||||
timeout: this.timeout!,
|
||||
...this.additionalSessionOptions,
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
# @llamaindex/perplexity
|
||||
|
||||
## 0.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 1587e48: Added support for Perplexity api
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@llamaindex/perplexity",
|
||||
"description": "Perplexity Adapter for LlamaIndex",
|
||||
"version": "0.0.2",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": {
|
||||
"types": "./dist/index.d.cts",
|
||||
"default": "./dist/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "bunchee",
|
||||
"dev": "bunchee --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bunchee": "6.4.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"@llamaindex/openai": "workspace:*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./llm";
|
||||
@@ -0,0 +1,78 @@
|
||||
import { getEnv } from "@llamaindex/env";
|
||||
import { Tokenizers } from "@llamaindex/env/tokenizers";
|
||||
import { OpenAI } from "@llamaindex/openai";
|
||||
|
||||
export const PERPLEXITY_MODELS = {
|
||||
"sonar-deep-research": {
|
||||
contextWindow: 128000,
|
||||
},
|
||||
"sonar-reasoning-pro": {
|
||||
contextWindow: 128000,
|
||||
},
|
||||
"sonar-reasoning": {
|
||||
contextWindow: 128000,
|
||||
},
|
||||
"sonar-pro": {
|
||||
contextWindow: 200000,
|
||||
},
|
||||
sonar: {
|
||||
contextWindow: 128000,
|
||||
},
|
||||
"r1-1776": {
|
||||
contextWindow: 128000,
|
||||
},
|
||||
};
|
||||
|
||||
type PerplexityModelName = keyof typeof PERPLEXITY_MODELS;
|
||||
const DEFAULT_MODEL: PerplexityModelName = "sonar";
|
||||
|
||||
export class Perplexity extends OpenAI {
|
||||
constructor(
|
||||
init?: Omit<Partial<OpenAI>, "session"> & { model?: PerplexityModelName },
|
||||
) {
|
||||
const {
|
||||
apiKey = getEnv("PERPLEXITY_API_KEY"),
|
||||
additionalSessionOptions = {},
|
||||
model = DEFAULT_MODEL,
|
||||
...rest
|
||||
} = init ?? {};
|
||||
|
||||
if (!apiKey) {
|
||||
throw new Error("Perplexity API key is required");
|
||||
}
|
||||
|
||||
additionalSessionOptions.baseURL =
|
||||
additionalSessionOptions.baseURL ?? "https://api.perplexity.ai/";
|
||||
|
||||
super({
|
||||
apiKey,
|
||||
additionalSessionOptions,
|
||||
model,
|
||||
...rest,
|
||||
});
|
||||
}
|
||||
|
||||
get supportToolCall() {
|
||||
return false;
|
||||
}
|
||||
|
||||
get metadata() {
|
||||
return {
|
||||
model: this.model,
|
||||
temperature: this.temperature,
|
||||
topP: this.topP,
|
||||
contextWindow:
|
||||
PERPLEXITY_MODELS[this.model as PerplexityModelName]?.contextWindow,
|
||||
tokenizer: Tokenizers.CL100K_BASE,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function to create a new Perplexity instance.
|
||||
* @param init - Optional initialization parameters for the Perplexity instance.
|
||||
* @returns A new Perplexity instance.
|
||||
*/
|
||||
export const perplexity = (
|
||||
init?: ConstructorParameters<typeof Perplexity>[0],
|
||||
) => new Perplexity(init);
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"outDir": "./lib",
|
||||
"tsBuildInfoFile": "./lib/.tsbuildinfo"
|
||||
},
|
||||
"include": ["./src", "package.json"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../core/tsconfig.json"
|
||||
},
|
||||
{
|
||||
"path": "../../env/tsconfig.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/together
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/together",
|
||||
"description": "Together Adapter for LlamaIndex",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.5",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/vllm
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
|
||||
## 0.0.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/vllm",
|
||||
"description": "vLLM Adapter for LlamaIndex",
|
||||
"version": "0.0.30",
|
||||
"version": "0.0.31",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
Generated
+37
-18
@@ -597,7 +597,7 @@ importers:
|
||||
specifier: ^0.0.13
|
||||
version: link:../packages/providers/storage/chroma
|
||||
'@llamaindex/clip':
|
||||
specifier: ^0.0.44
|
||||
specifier: ^0.0.45
|
||||
version: link:../packages/providers/clip
|
||||
'@llamaindex/cloud':
|
||||
specifier: ^3.0.9
|
||||
@@ -609,10 +609,10 @@ importers:
|
||||
specifier: ^0.5.8
|
||||
version: link:../packages/core
|
||||
'@llamaindex/deepinfra':
|
||||
specifier: ^0.0.44
|
||||
specifier: ^0.0.45
|
||||
version: link:../packages/providers/deepinfra
|
||||
'@llamaindex/deepseek':
|
||||
specifier: ^0.0.4
|
||||
specifier: ^0.0.5
|
||||
version: link:../packages/providers/deepseek
|
||||
'@llamaindex/env':
|
||||
specifier: ^0.1.29
|
||||
@@ -621,25 +621,25 @@ importers:
|
||||
specifier: ^1.0.6
|
||||
version: link:../packages/providers/storage/firestore
|
||||
'@llamaindex/fireworks':
|
||||
specifier: ^0.0.4
|
||||
specifier: ^0.0.5
|
||||
version: link:../packages/providers/fireworks
|
||||
'@llamaindex/google':
|
||||
specifier: ^0.1.1
|
||||
specifier: ^0.1.2
|
||||
version: link:../packages/providers/google
|
||||
'@llamaindex/groq':
|
||||
specifier: ^0.0.59
|
||||
specifier: ^0.0.60
|
||||
version: link:../packages/providers/groq
|
||||
'@llamaindex/huggingface':
|
||||
specifier: ^0.0.44
|
||||
specifier: ^0.0.45
|
||||
version: link:../packages/providers/huggingface
|
||||
'@llamaindex/jinaai':
|
||||
specifier: ^0.0.4
|
||||
specifier: ^0.0.5
|
||||
version: link:../packages/providers/jinaai
|
||||
'@llamaindex/milvus':
|
||||
specifier: ^0.1.8
|
||||
version: link:../packages/providers/storage/milvus
|
||||
'@llamaindex/mistral':
|
||||
specifier: ^0.0.13
|
||||
specifier: ^0.0.14
|
||||
version: link:../packages/providers/mistral
|
||||
'@llamaindex/mixedbread':
|
||||
specifier: ^0.0.13
|
||||
@@ -654,8 +654,11 @@ importers:
|
||||
specifier: ^0.0.48
|
||||
version: link:../packages/providers/ollama
|
||||
'@llamaindex/openai':
|
||||
specifier: ^0.1.60
|
||||
specifier: ^0.1.61
|
||||
version: link:../packages/providers/openai
|
||||
'@llamaindex/perplexity':
|
||||
specifier: ^0.0.2
|
||||
version: link:../packages/providers/perplexity
|
||||
'@llamaindex/pinecone':
|
||||
specifier: ^0.0.13
|
||||
version: link:../packages/providers/storage/pinecone
|
||||
@@ -675,7 +678,7 @@ importers:
|
||||
specifier: ^0.0.41
|
||||
version: link:../packages/providers/replicate
|
||||
'@llamaindex/together':
|
||||
specifier: ^0.0.4
|
||||
specifier: ^0.0.5
|
||||
version: link:../packages/providers/together
|
||||
'@llamaindex/upstash':
|
||||
specifier: ^0.0.13
|
||||
@@ -684,7 +687,7 @@ importers:
|
||||
specifier: ^0.0.19
|
||||
version: link:../packages/providers/vercel
|
||||
'@llamaindex/vllm':
|
||||
specifier: ^0.0.30
|
||||
specifier: ^0.0.31
|
||||
version: link:../packages/providers/vllm
|
||||
'@llamaindex/voyage-ai':
|
||||
specifier: ^1.0.5
|
||||
@@ -720,7 +723,7 @@ importers:
|
||||
specifier: ^1.0.14
|
||||
version: 1.0.18
|
||||
llamaindex:
|
||||
specifier: ^0.9.10
|
||||
specifier: ^0.9.11
|
||||
version: link:../packages/llamaindex
|
||||
mongodb:
|
||||
specifier: 6.7.0
|
||||
@@ -1257,8 +1260,8 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../../env
|
||||
'@mistralai/mistralai':
|
||||
specifier: ^1.3.4
|
||||
version: 1.5.0(zod@3.24.2)
|
||||
specifier: ^1.5.1
|
||||
version: 1.5.1(zod@3.24.2)
|
||||
devDependencies:
|
||||
bunchee:
|
||||
specifier: 6.4.0
|
||||
@@ -1315,6 +1318,22 @@ importers:
|
||||
specifier: 6.4.0
|
||||
version: 6.4.0(typescript@5.7.3)
|
||||
|
||||
packages/providers/perplexity:
|
||||
dependencies:
|
||||
'@llamaindex/core':
|
||||
specifier: workspace:*
|
||||
version: link:../../core
|
||||
'@llamaindex/env':
|
||||
specifier: workspace:*
|
||||
version: link:../../env
|
||||
'@llamaindex/openai':
|
||||
specifier: workspace:*
|
||||
version: link:../openai
|
||||
devDependencies:
|
||||
bunchee:
|
||||
specifier: 6.4.0
|
||||
version: 6.4.0(typescript@5.7.3)
|
||||
|
||||
packages/providers/portkey-ai:
|
||||
dependencies:
|
||||
'@llamaindex/core':
|
||||
@@ -3484,8 +3503,8 @@ packages:
|
||||
'@mdx-js/mdx@3.1.0':
|
||||
resolution: {integrity: sha512-/QxEhPAvGwbQmy1Px8F899L5Uc2KZ6JtXwlCgJmjSTBedwOZkByYcBG4GceIGPXRDsmfxhHazuS+hlOShRLeDw==}
|
||||
|
||||
'@mistralai/mistralai@1.5.0':
|
||||
resolution: {integrity: sha512-AIn8pwAwA/fDvEUvmkt+40zH1ZmfaG3Q7oUWl17GUEC1tU7ZPwYz8Cv9P59lyS1SisHdDSu81oknO7f1ywkz8Q==}
|
||||
'@mistralai/mistralai@1.5.1':
|
||||
resolution: {integrity: sha512-Ie0EH4dAO11MEXR5N2kS2cgr+ycTWvqN/yP9bKrtmUEqjdcF4i7DLxtrFMUw5l2dOPhrkX93G4SziFiATPWu2w==}
|
||||
peerDependencies:
|
||||
zod: '>= 3'
|
||||
|
||||
@@ -14273,7 +14292,7 @@ snapshots:
|
||||
- acorn
|
||||
- supports-color
|
||||
|
||||
'@mistralai/mistralai@1.5.0(zod@3.24.2)':
|
||||
'@mistralai/mistralai@1.5.1(zod@3.24.2)':
|
||||
dependencies:
|
||||
zod: 3.24.2
|
||||
zod-to-json-schema: 3.24.1(zod@3.24.2)
|
||||
|
||||
@@ -187,6 +187,9 @@
|
||||
},
|
||||
{
|
||||
"path": "./packages/providers/jinaai/tsconfig.json"
|
||||
},
|
||||
{
|
||||
"path": "./packages/providers/perplexity/tsconfig.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/unit-test
|
||||
|
||||
## 0.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c0637]
|
||||
- @llamaindex/openai@0.1.61
|
||||
- llamaindex@0.9.11
|
||||
|
||||
## 0.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/unit-test",
|
||||
"private": true,
|
||||
"version": "0.1.10",
|
||||
"version": "0.1.11",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "vitest run"
|
||||
|
||||
Reference in New Issue
Block a user