diff --git a/docs/src/components/BuiltinAgents.mdx b/docs/src/components/BuiltinAgents.mdx index 590d5a512..7303c90ab 100644 --- a/docs/src/components/BuiltinAgents.mdx +++ b/docs/src/components/BuiltinAgents.mdx @@ -13,4 +13,4 @@ import { LinkCard } from '@astrojs/starlight/components'; - + diff --git a/docs/src/components/BuiltinTools.mdx b/docs/src/components/BuiltinTools.mdx index 7edf0b168..155e4c260 100644 --- a/docs/src/components/BuiltinTools.mdx +++ b/docs/src/components/BuiltinTools.mdx @@ -13,7 +13,6 @@ import { LinkCard } from '@astrojs/starlight/components'; - diff --git a/docs/src/content/docs/reference/scripts/system.mdx b/docs/src/content/docs/reference/scripts/system.mdx index e63143ef2..d85eac8b9 100644 --- a/docs/src/content/docs/reference/scripts/system.mdx +++ b/docs/src/content/docs/reference/scripts/system.mdx @@ -390,7 +390,7 @@ system({ const model = env.vars.agentWebSearchModel defAgent( - "web-search", + "web", "search the web to accomplish tasks.", `Your are a helpful LLM agent that can use web search. Answer the question in QUERY.`, @@ -1080,7 +1080,6 @@ Tools to query a git repository. - tool `git_branch_default`: Gets the default branch using git. - tool `git_branch_current`: Gets the current branch using git. - tool `git_branch_list`: List all branches using git. -- tool `git_diff`: Computes file diffs using the git diff command. If the diff is too large, it returns the list of modified/added files. - tool `git_list_commits`: Generates a history of commits using the git log command. - tool `git_status`: Generates a status of the repository using git. - tool `git_last_tag`: Gets the last tag using git. @@ -1113,58 +1112,6 @@ defTool("git_branch_list", "List all branches using git.", {}, async () => { return await git.exec("branch") }) -defTool( - "git_diff", - "Computes file diffs using the git diff command. If the diff is too large, it returns the list of modified/added files.", - { - type: "object", - properties: { - base: { - type: "string", - description: "Base branch, ref, commit sha to compare against.", - }, - head: { - type: "string", - description: - "Head branch, ref, commit sha to compare. Use 'HEAD' to compare against the current branch.", - }, - staged: { - type: "boolean", - description: "Compare staged changes", - }, - nameOnly: { - type: "boolean", - description: "Show only file names", - }, - paths: { - type: "array", - description: "Paths to compare", - items: { - type: "string", - description: "File path or wildcard supported by git", - }, - }, - excludedPaths: { - type: "array", - description: "Paths to exclude", - items: { - type: "string", - description: "File path or wildcard supported by git", - }, - }, - }, - }, - async (args) => { - const { context, ...rest } = args - const res = await git.diff({ - llmify: true, - ...rest, - }) - return res - }, - { maxTokens: 20000 } -) - defTool( "git_list_commits", "Generates a history of commits using the git log command.", diff --git a/package.json b/package.json index f896fc556..797fd1681 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "setup": "git submodule update --init --recursive", "setup:az": "curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash", "setup:bicep": "az bicep upgrade", + "az:login": "az login --scope api://trapi/.default", "install:playwright": "yarn install playwright --with-deps", "install:force": "rm yarn.lock && yarn install && yarn --cwd docs install:force && yarn --cwd slides install:force && yarn gen:licenses", "compile-ext": "yarn --cwd packages/core run prompts:bundle && yarn --cwd packages/vscode run compile", diff --git a/packages/core/src/anthropic.ts b/packages/core/src/anthropic.ts index 37d40769d..84cc6dfce 100644 --- a/packages/core/src/anthropic.ts +++ b/packages/core/src/anthropic.ts @@ -433,7 +433,7 @@ const completerFactory = ( trace.appendContent("\n\n") trace.itemValue(`🏁 finish reason`, finishReason) - if (usage) { + if (usage?.total_tokens) { trace.itemValue( `🪙 tokens`, `${usage.total_tokens} total, ${usage.prompt_tokens} prompt, ${usage.completion_tokens} completion` diff --git a/packages/core/src/chat.ts b/packages/core/src/chat.ts index 9a5fec966..11a095797 100644 --- a/packages/core/src/chat.ts +++ b/packages/core/src/chat.ts @@ -79,6 +79,7 @@ import { serializeLogProb, topLogprobsToMarkdown, } from "./logprob" +import { uniq } from "es-toolkit" export function toChatCompletionUserMessage( expanded: string, @@ -892,8 +893,15 @@ export async function executeChatSession( try { trace.startDetails(`🧠 llm chat`) - if (toolDefinitions?.length) + if (toolDefinitions?.length) { trace.detailsFenced(`🛠️ tools`, tools, "yaml") + const toolNames = toolDefinitions.map(({ spec }) => spec.name) + const duplicates = uniq(toolNames).filter( + (name, index) => toolNames.lastIndexOf(name) !== index + ) + if (duplicates.length) + throw new Error(`duplicate tools: ${duplicates.join(", ")}`) + } let genVars: Record while (true) { stats.turns++ diff --git a/packages/core/src/genaisrc/system.agent_web.genai.mjs b/packages/core/src/genaisrc/system.agent_web.genai.mjs index cb87e88a5..9963189b3 100644 --- a/packages/core/src/genaisrc/system.agent_web.genai.mjs +++ b/packages/core/src/genaisrc/system.agent_web.genai.mjs @@ -5,7 +5,7 @@ system({ const model = env.vars.agentWebSearchModel defAgent( - "web-search", + "web", "search the web to accomplish tasks.", `Your are a helpful LLM agent that can use web search. Answer the question in QUERY.`, diff --git a/packages/core/src/genaisrc/system.git.genai.mjs b/packages/core/src/genaisrc/system.git.genai.mjs index b753cd36e..1fb5fbeea 100644 --- a/packages/core/src/genaisrc/system.git.genai.mjs +++ b/packages/core/src/genaisrc/system.git.genai.mjs @@ -25,58 +25,6 @@ defTool("git_branch_list", "List all branches using git.", {}, async () => { return await git.exec("branch") }) -defTool( - "git_diff", - "Computes file diffs using the git diff command. If the diff is too large, it returns the list of modified/added files.", - { - type: "object", - properties: { - base: { - type: "string", - description: "Base branch, ref, commit sha to compare against.", - }, - head: { - type: "string", - description: - "Head branch, ref, commit sha to compare. Use 'HEAD' to compare against the current branch.", - }, - staged: { - type: "boolean", - description: "Compare staged changes", - }, - nameOnly: { - type: "boolean", - description: "Show only file names", - }, - paths: { - type: "array", - description: "Paths to compare", - items: { - type: "string", - description: "File path or wildcard supported by git", - }, - }, - excludedPaths: { - type: "array", - description: "Paths to exclude", - items: { - type: "string", - description: "File path or wildcard supported by git", - }, - }, - }, - }, - async (args) => { - const { context, ...rest } = args - const res = await git.diff({ - llmify: true, - ...rest, - }) - return res - }, - { maxTokens: 20000 } -) - defTool( "git_list_commits", "Generates a history of commits using the git log command.", diff --git a/packages/core/src/llms.json b/packages/core/src/llms.json index 537459a40..46b17b071 100644 --- a/packages/core/src/llms.json +++ b/packages/core/src/llms.json @@ -71,10 +71,10 @@ "prediction": false, "bearerToken": true, "aliases": { - "large": "gemini-2.0-flash-exp", + "large": "gemini-1.5-flash-latest", "small": "gemini-1.5-flash-latest", - "vision": "gemini-2.0-flash-exp", - "long": "gemini-2.0-flash-exp", + "vision": "gemini-1.5-flash-latest", + "long": "gemini-1.5-flash-latest", "reasoning": "gemini-2.0-flash-thinking-exp-1219", "reasoning_small": "gemini-2.0-flash-thinking-exp-1219", "embeddings": "text-embedding-004" diff --git a/packages/core/src/openai.ts b/packages/core/src/openai.ts index 16592161f..73b324cdc 100644 --- a/packages/core/src/openai.ts +++ b/packages/core/src/openai.ts @@ -399,7 +399,7 @@ export const OpenAIChatCompletion: ChatCompletionHandler = async ( trace.appendContent("\n\n") if (responseModel) trace.itemValue(`model`, responseModel) trace.itemValue(`🏁 finish reason`, finishReason) - if (usage) { + if (usage?.total_tokens) { trace.itemValue( `🪙 tokens`, `${usage.total_tokens} total, ${usage.prompt_tokens} prompt, ${usage.completion_tokens} completion`