-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
363 additions
and
63 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
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
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
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,3 +1,3 @@ | ||
export { sendChatRequest } from './sendChatRequest'; | ||
export { LlmMessage, LlmRequestMessage, LlmResponseMessage } from './message'; | ||
export { ChatCompletionTool, FunctionDefinition } from './tools'; | ||
export { ChatCompletionTool } from './tools'; |
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { FunctionDefinition } from '../llm'; | ||
import { Tool } from './Tool'; | ||
import { type Tool } from './Tool'; | ||
import { ToolDefinition } from './ToolTypes'; | ||
|
||
export type ToolConfig = { | ||
definition: FunctionDefinition; | ||
// As per Open AI function calling / Tool definition | ||
definition: ToolDefinition; | ||
implementation: Tool; | ||
}; |
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
import { type ProgressData, type CancellationToken, type RoutingContext } from '../agents/AgentContext'; | ||
|
||
export type ToolContext = { | ||
workspaceFolder: string; | ||
routing: RoutingContext; | ||
askForUserPermission: (message: string) => Promise<boolean>; | ||
cancellation: CancellationToken; | ||
onProgress: (progressData: ProgressData) => void; | ||
formatError: (error: string) => string; | ||
mergeRoutingContext: (delta: RoutingContext) => RoutingContext; | ||
}; | ||
|
||
export type ToolCallback = ( | ||
context: ToolContext, | ||
...parameters: any | ||
) => string | undefined | void | Promise<string | undefined | void>; | ||
export type ToolDefinition = { | ||
name: string; | ||
description: string; | ||
parameters: Record<string, unknown>; | ||
}; |
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,38 @@ | ||
// import { ToolManager } from '../ToolManager'; | ||
// import { ToolContext } from '../ToolTypes'; | ||
|
||
// export const TOOL_CLONE_REPO = 'clone_repo'; | ||
|
||
// /** | ||
// * Write text to a file | ||
// * @param filename The name of the file to write | ||
// * @param contents The contents of the file to write | ||
// */ | ||
// const clone_repo = async (context: ToolContext, repoUrl: string, localPath: string) => { | ||
// try { | ||
// const fullPath = await context.git.clone(repoUrl, localPath); | ||
// const project = localPath.split('/').pop(); | ||
// return `The repository ${repoUrl} has been cloned locally as project "${project}" to ${localPath}`; | ||
// } catch (err) { | ||
// return `Error cloning repository from ${repoUrl} to ${localPath}: ${(err as Error).message}`; | ||
// } | ||
// }; | ||
|
||
// ToolManager.registerTool(clone_repo, { | ||
// name: TOOL_CLONE_REPO, | ||
// description: 'Clone a git repository', | ||
// parameters: { | ||
// type: 'object', | ||
// properties: { | ||
// repository_url: { | ||
// type: 'string', | ||
// description: 'The URL of the repository to clone', | ||
// }, | ||
// local_path: { | ||
// type: 'string', | ||
// description: 'The local path to clone the repository to', | ||
// }, | ||
// }, | ||
// required: ['repository_url', 'local_path'], | ||
// }, | ||
// }); |
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,37 @@ | ||
import { execSync } from 'child_process'; | ||
import { logger } from '../../utils/Logger'; | ||
import { ToolContext } from '../ToolTypes'; | ||
import { ToolManager } from '../ToolManager'; | ||
|
||
export const TOOL_EXECUTE_SHELL = 'execute_shell'; | ||
|
||
export const executeShell = async ( | ||
context: ToolContext, | ||
alreadyInDocker: boolean, | ||
args: string[] | ||
): Promise<string> => { | ||
const command = args.join(' '); | ||
if (!alreadyInDocker) { | ||
// TODO: implement allow/deny list as per validate_command in AutoGPT | ||
if (!(await context.askForUserPermission(`Can I run "${command}"?`))) { | ||
return 'Command rejected by user'; | ||
} | ||
logger.info(`Running locally: ${command}`); | ||
} | ||
return execSync(command, { cwd: context.workspaceFolder, encoding: 'utf-8' }); | ||
}; | ||
|
||
ToolManager.registerTool(executeShell, { | ||
name: TOOL_EXECUTE_SHELL, | ||
description: 'Execute a Shell Command, non-interactive commands only', | ||
parameters: { | ||
type: 'object', | ||
properties: { | ||
command_line: { | ||
type: 'string', | ||
description: 'The command line to execute', | ||
}, | ||
}, | ||
required: ['command_line'], | ||
}, | ||
}); |
Oops, something went wrong.