Skip to content

Commit

Permalink
feat: provide messages to tools (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
grabbou authored Dec 7, 2024
1 parent 9217c83 commit 4378a18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/framework/src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export async function executeTaskWithAgent(

const content = await tool.execute(toolCall.function.parsed_arguments, {
provider: agent.provider,
messages,
})
return {
role: 'tool' as const,
Expand Down
6 changes: 5 additions & 1 deletion packages/framework/src/tool.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import z, { ZodTypeAny } from 'zod'

import { Provider } from './models/openai.js'
import { Message } from './types.js'

export type Tool<P extends ZodTypeAny = any> = {
description: string
parameters: P
execute: (parameters: z.infer<P>, context: { provider: Provider }) => Promise<string>
execute: (
parameters: z.infer<P>,
context: { provider: Provider; messages: Message[] }
) => Promise<string>
}

/**
Expand Down

0 comments on commit 4378a18

Please sign in to comment.