-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into himself65/20240501/repro
- Loading branch information
Showing
40 changed files
with
2,555 additions
and
1,297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"llamaindex": patch | ||
--- | ||
|
||
fix: change <-> to <=> in the SELECT query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
# docs | ||
|
||
## 0.0.12 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [1dce275] | ||
- Updated dependencies [d10533e] | ||
- Updated dependencies [2008efe] | ||
- Updated dependencies [5e61934] | ||
- Updated dependencies [9e74a43] | ||
- Updated dependencies [ee719a1] | ||
- [email protected] | ||
|
||
## 0.0.11 | ||
|
||
### Patch Changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEBUG=llamaindex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ChatResponseChunk, ReActAgent } from "llamaindex"; | ||
import { ReadableStream } from "node:stream/web"; | ||
import { | ||
getCurrentIDTool, | ||
getUserInfoTool, | ||
getWeatherTool, | ||
} from "./utils/tools"; | ||
|
||
async function main() { | ||
// Create an OpenAIAgent with the function tools | ||
const agent = new ReActAgent({ | ||
tools: [getCurrentIDTool, getUserInfoTool, getWeatherTool], | ||
}); | ||
|
||
const task = await agent.createTask( | ||
"What is my current address weather based on my profile?", | ||
true, | ||
); | ||
|
||
for await (const stepOutput of task) { | ||
const stream = stepOutput.output as ReadableStream<ChatResponseChunk>; | ||
if (stepOutput.isLast) { | ||
for await (const chunk of stream) { | ||
process.stdout.write(chunk.delta); | ||
} | ||
process.stdout.write("\n"); | ||
} else { | ||
// handing function call | ||
console.log("handling function call..."); | ||
for await (const chunk of stream) { | ||
console.log("debug:", JSON.stringify(chunk.raw)); | ||
} | ||
} | ||
console.log("---"); | ||
} | ||
} | ||
|
||
void main().then(() => { | ||
console.log("Done"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { FunctionTool } from "llamaindex"; | ||
|
||
export const getCurrentIDTool = FunctionTool.from( | ||
() => { | ||
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: { | ||
type: "object", | ||
properties: { | ||
userId: { | ||
type: "string", | ||
description: "The user id", | ||
}, | ||
}, | ||
required: ["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: { | ||
type: "object", | ||
properties: { | ||
address: { | ||
type: "string", | ||
description: "The address", | ||
}, | ||
}, | ||
required: ["address"], | ||
}, | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { HuggingFaceInferenceAPI } from "llamaindex"; | ||
|
||
(async () => { | ||
if (!process.env.HUGGING_FACE_TOKEN) { | ||
throw new Error("Please set the HUGGING_FACE_TOKEN environment variable."); | ||
} | ||
const hf = new HuggingFaceInferenceAPI({ | ||
accessToken: process.env.HUGGING_FACE_TOKEN, | ||
model: "mistralai/Mixtral-8x7B-Instruct-v0.1", | ||
}); | ||
const result = await hf.chat({ | ||
messages: [ | ||
{ content: "You want to talk in rhymes.", role: "system" }, | ||
{ | ||
content: | ||
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?", | ||
role: "user", | ||
}, | ||
], | ||
}); | ||
console.log(result); | ||
})(); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/core/e2e/examples/cloudflare-worker-agent/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
# @llamaindex/cloudflare-worker-agent-test | ||
|
||
## 0.0.5 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [1dce275] | ||
- Updated dependencies [d10533e] | ||
- Updated dependencies [2008efe] | ||
- Updated dependencies [5e61934] | ||
- Updated dependencies [9e74a43] | ||
- Updated dependencies [ee719a1] | ||
- [email protected] | ||
|
||
## 0.0.4 | ||
|
||
### Patch Changes | ||
|
2 changes: 1 addition & 1 deletion
2
packages/core/e2e/examples/cloudflare-worker-agent/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
# @llamaindex/next-agent-test | ||
|
||
## 0.1.5 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [1dce275] | ||
- Updated dependencies [d10533e] | ||
- Updated dependencies [2008efe] | ||
- Updated dependencies [5e61934] | ||
- Updated dependencies [9e74a43] | ||
- Updated dependencies [ee719a1] | ||
- [email protected] | ||
|
||
## 0.1.4 | ||
|
||
### Patch Changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
# @llamaindex/waku-query-engine-test | ||
|
||
## 0.0.5 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [1dce275] | ||
- Updated dependencies [d10533e] | ||
- Updated dependencies [2008efe] | ||
- Updated dependencies [5e61934] | ||
- Updated dependencies [9e74a43] | ||
- Updated dependencies [ee719a1] | ||
- [email protected] | ||
|
||
## 0.0.4 | ||
|
||
### Patch Changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.