Skip to content

Commit

Permalink
feat(tools): switch openAPI tool to framework version
Browse files Browse the repository at this point in the history
Signed-off-by: Lukáš Janeček <[email protected]>
  • Loading branch information
Lukáš Janeček committed Jan 13, 2025
1 parent f50e20d commit 8b9139a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/runs/execution/tools/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { DuckDuckGoSearchTool } from 'bee-agent-framework/tools/search/duckDuckG
import { SearchToolOptions, SearchToolOutput } from 'bee-agent-framework/tools/search/base';
import { PromptTemplate } from 'bee-agent-framework/template';
import { CalculatorTool } from 'bee-agent-framework/tools/calculator';
import { OpenAPITool, OpenAPIToolOutput } from 'bee-agent-framework/tools/openapi';
import { LLMTool } from 'bee-agent-framework/tools/llm';

import { AgentContext } from '../execute.js';
Expand All @@ -45,7 +46,6 @@ import { RedisCache } from '../cache.js';
import { createPythonStorage } from './python-tool-storage.js';
import { FunctionTool, FunctionToolOutput } from './function.js';
import { FileSearchTool, FileSearchToolOutput } from './file-search-tool.js';
import { ApiCallTool } from './api-call-tool.js';
import { ReadFileTool } from './read-file-tool.js';

import { CodeInterpreterCall } from '@/tools/entities/tool-calls/code-interpreter-call.entity.js';
Expand All @@ -57,7 +57,8 @@ import {
BEE_CODE_INTERPRETER_CA_CERT,
BEE_CODE_INTERPRETER_CERT,
BEE_CODE_INTERPRETER_KEY,
BEE_CODE_INTERPRETER_URL
BEE_CODE_INTERPRETER_URL,
HTTP_PROXY_URL
} from '@/config.js';
import { FileContainer } from '@/files/entities/files-container.entity.js';
import { FunctionUsage } from '@/tools/entities/tool-usages/function-usage.entity.js';
Expand Down Expand Up @@ -241,12 +242,12 @@ export async function getTools(run: LoadedRun, context: AgentContext): Promise<F
context
});
case ToolExecutor.API:
return new ApiCallTool({
return new OpenAPITool({
name: toolUsage.tool.$.name,
description: toolUsage.tool.$.description,
openApiSchema: (<ApiCallUserTool>toolUsage.tool.$).openApiSchema,
context,
apiKey: (<ApiCallUserTool>toolUsage.tool.$).apiKey
apiKey: (<ApiCallUserTool>toolUsage.tool.$).apiKey,
httpProxyUrl: HTTP_PROXY_URL ?? undefined
});
}
})
Expand Down Expand Up @@ -369,7 +370,7 @@ export async function createToolCall(
});
} else if (tool instanceof FunctionTool) {
return new FunctionCall({ name: tool.name, arguments: JSON.stringify(input) });
} else if (tool instanceof CustomTool || tool instanceof ApiCallTool) {
} else if (tool instanceof CustomTool || tool instanceof OpenAPITool) {
const [toolEntity] = await ORM.em
.getRepository(Tool)
.find({ name: tool.name, project: run.project });
Expand Down Expand Up @@ -433,7 +434,8 @@ export async function finalizeToolCall(
if (!(result instanceof FileSearchToolOutput)) throw new TypeError();
toolCall.results = result.results;
} else if (toolCall instanceof UserCall) {
if (!(result instanceof StringToolOutput)) throw new TypeError();
if (!(result instanceof StringToolOutput || result instanceof OpenAPIToolOutput))
throw new TypeError();
toolCall.output = result.result;
} else {
throw new Error(`Unexpected tool call`);
Expand Down

0 comments on commit 8b9139a

Please sign in to comment.