forked from run-llama/LlamaIndexTS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle
RouterQueryEngine
with string query (run-llama#1181)
- Loading branch information
1 parent
2dcad52
commit 4810364
Showing
7 changed files
with
151 additions
and
5 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: handle `RouterQueryEngine` with string 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@llamaindex/cloud": patch | ||
--- | ||
|
||
fix: bump version |
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,67 @@ | ||
import { LLMSingleSelector, Settings } from "llamaindex"; | ||
import assert from "node:assert"; | ||
import { test } from "node:test"; | ||
import { mockLLMEvent } from "./utils.js"; | ||
|
||
await test("#1177", async (t) => { | ||
await mockLLMEvent(t, "#1177"); | ||
await t.test(async () => { | ||
const selector = new LLMSingleSelector({ | ||
llm: Settings.llm, | ||
}); | ||
{ | ||
const result = await selector.select( | ||
[ | ||
{ | ||
description: "Math calculation", | ||
}, | ||
{ | ||
description: "Search from google", | ||
}, | ||
], | ||
"calculate 2 + 2", | ||
); | ||
assert.equal(result.selections.length, 1); | ||
assert.equal(result.selections.at(0)!.index, 0); | ||
} | ||
{ | ||
const result = await selector.select( | ||
[ | ||
{ | ||
description: "Math calculation", | ||
}, | ||
{ | ||
description: "Search from google", | ||
}, | ||
], | ||
{ | ||
query: "calculate 2 + 2", | ||
}, | ||
); | ||
assert.equal(result.selections.length, 1); | ||
assert.equal(result.selections.at(0)!.index, 0); | ||
} | ||
{ | ||
const result = await selector.select( | ||
[ | ||
{ | ||
description: "Math calculation", | ||
}, | ||
{ | ||
description: "Search from google", | ||
}, | ||
], | ||
{ | ||
query: [ | ||
{ | ||
type: "text", | ||
text: "calculate 2 + 2", | ||
}, | ||
], | ||
}, | ||
); | ||
assert.equal(result.selections.length, 1); | ||
assert.equal(result.selections.at(0)!.index, 0); | ||
} | ||
}); | ||
}); |
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,67 @@ | ||
{ | ||
"llmEventStart": [ | ||
{ | ||
"id": "PRESERVE_0", | ||
"messages": [ | ||
{ | ||
"content": "Some choices are given below. It is provided in a numbered list (1 to 42), where each item in the list corresponds to a summary.\n---------------------\n(1) Math calculation(2) Search from google\n---------------------\nUsing only the choices above and not prior knowledge, return the choice that is most relevant to the question: 'calculate 2 + 2'\n\n\nThe output should be ONLY JSON formatted as a JSON instance.\n\nHere is an example:\n[\n {\n \"choice\": 1,\n \"reason\": \"<insert reason for choice>\"\n },\n ...\n]\n", | ||
"role": "user" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "PRESERVE_1", | ||
"messages": [ | ||
{ | ||
"content": "Some choices are given below. It is provided in a numbered list (1 to 42), where each item in the list corresponds to a summary.\n---------------------\n(1) Math calculation(2) Search from google\n---------------------\nUsing only the choices above and not prior knowledge, return the choice that is most relevant to the question: 'calculate 2 + 2'\n\n\nThe output should be ONLY JSON formatted as a JSON instance.\n\nHere is an example:\n[\n {\n \"choice\": 1,\n \"reason\": \"<insert reason for choice>\"\n },\n ...\n]\n", | ||
"role": "user" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "PRESERVE_2", | ||
"messages": [ | ||
{ | ||
"content": "Some choices are given below. It is provided in a numbered list (1 to 42), where each item in the list corresponds to a summary.\n---------------------\n(1) Math calculation(2) Search from google\n---------------------\nUsing only the choices above and not prior knowledge, return the choice that is most relevant to the question: 'calculate 2 + 2'\n\n\nThe output should be ONLY JSON formatted as a JSON instance.\n\nHere is an example:\n[\n {\n \"choice\": 1,\n \"reason\": \"<insert reason for choice>\"\n },\n ...\n]\n", | ||
"role": "user" | ||
} | ||
] | ||
} | ||
], | ||
"llmEventEnd": [ | ||
{ | ||
"id": "PRESERVE_0", | ||
"response": { | ||
"raw": null, | ||
"message": { | ||
"content": "[\n {\n \"choice\": 1,\n \"reason\": \"The question 'calculate 2 + 2' is directly asking for a math calculation, which corresponds to choice 1.\"\n }\n]", | ||
"role": "assistant", | ||
"options": {} | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "PRESERVE_1", | ||
"response": { | ||
"raw": null, | ||
"message": { | ||
"content": "[\n {\n \"choice\": 1,\n \"reason\": \"The question 'calculate 2 + 2' is asking for a mathematical calculation, which directly corresponds to choice 1: Math calculation.\"\n }\n]", | ||
"role": "assistant", | ||
"options": {} | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "PRESERVE_2", | ||
"response": { | ||
"raw": null, | ||
"message": { | ||
"content": "[\n {\n \"choice\": 1,\n \"reason\": \"The question 'calculate 2 + 2' is asking for a mathematical calculation, which directly corresponds to choice 1: Math calculation.\"\n }\n]", | ||
"role": "assistant", | ||
"options": {} | ||
} | ||
} | ||
} | ||
], | ||
"llmEventStream": [] | ||
} |
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