Compare commits

...

2 Commits

Author SHA1 Message Date
github-actions[bot] 5cb270d07f Release 0.2.13 (#773)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-04-26 13:26:12 -05:00
Alex Yang 62771058aa fix: empty tools (#772) 2024-04-26 13:10:57 -05:00
11 changed files with 48 additions and 7 deletions
+7
View File
@@ -1,5 +1,12 @@
# docs
## 0.0.7
### Patch Changes
- Updated dependencies [6277105]
- llamaindex@0.2.13
## 0.0.6
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.6",
"version": "0.0.7",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
+6
View File
@@ -1,5 +1,11 @@
# llamaindex
## 0.2.13
### Patch Changes
- 6277105: fix: allow passing empty tools to llms
## 0.2.12
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.2.12",
"version": "0.2.13",
"expectedMinorVersion": "2",
"license": "MIT",
"type": "module",
+8 -2
View File
@@ -1,6 +1,7 @@
import type { ClientOptions } from "@anthropic-ai/sdk";
import { Anthropic as SDKAnthropic } from "@anthropic-ai/sdk";
import type {
MessageCreateParamsNonStreaming,
Tool,
ToolResultBlockParam,
ToolUseBlock,
@@ -264,7 +265,7 @@ export class Anthropic extends ToolCallLLM<AnthropicAdditionalChatOptions> {
const anthropic = this.session.anthropic;
if (tools) {
const response = await anthropic.beta.tools.messages.create({
const params: MessageCreateParamsNonStreaming = {
messages: this.formatMessages<true>(messages),
tools: tools.map(Anthropic.toTool),
model: this.getModelName(this.model),
@@ -272,7 +273,12 @@ export class Anthropic extends ToolCallLLM<AnthropicAdditionalChatOptions> {
max_tokens: this.maxTokens ?? 4096,
top_p: this.topP,
...(systemPrompt && { system: systemPrompt }),
});
};
// Remove tools if there are none, as it will cause an error
if (tools.length === 0) {
delete params.tools;
}
const response = await anthropic.beta.tools.messages.create(params);
const toolUseBlock = response.content.find(
(content): content is ToolUseBlock => content.type === "tool_use",
+8
View File
@@ -349,6 +349,14 @@ export class OpenAI extends ToolCallLLM<OpenAIAdditionalChatOptions> {
...Object.assign({}, this.additionalChatOptions, additionalChatOptions),
};
if (
Array.isArray(baseRequestParams.tools) &&
baseRequestParams.tools.length === 0
) {
// remove empty tools array to avoid OpenAI error
delete baseRequestParams.tools;
}
// Streaming
if (stream) {
return this.streamChat(baseRequestParams);
@@ -1,5 +1,12 @@
# test-edge-runtime
## 0.1.4
### Patch Changes
- Updated dependencies [6277105]
- @llamaindex/edge@0.2.13
## 0.1.3
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "test-edge-runtime",
"version": "0.1.3",
"version": "0.1.4",
"private": true,
"scripts": {
"dev": "next dev",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/edge",
"version": "0.2.12",
"version": "0.2.13",
"license": "MIT",
"type": "module",
"dependencies": {
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/experimental
## 0.0.16
### Patch Changes
- Updated dependencies [6277105]
- llamaindex@0.2.13
## 0.0.15
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.15",
"version": "0.0.16",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",