mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-06 05:42:37 +02:00
send msgs in webhook tool calls
This commit is contained in:
parent
39282907d4
commit
80a98f1d7b
4 changed files with 10 additions and 2 deletions
|
|
@ -1054,11 +1054,12 @@ export async function updateWebhookUrl(projectId: string, url: string) {
|
||||||
|
|
||||||
export async function executeClientTool(
|
export async function executeClientTool(
|
||||||
toolCall: z.infer<typeof apiV1.AssistantMessageWithToolCalls>['tool_calls'][number],
|
toolCall: z.infer<typeof apiV1.AssistantMessageWithToolCalls>['tool_calls'][number],
|
||||||
|
messages: z.infer<typeof apiV1.ChatMessage>[],
|
||||||
projectId: string,
|
projectId: string,
|
||||||
): Promise<unknown> {
|
): Promise<unknown> {
|
||||||
await projectAuthCheck(projectId);
|
await projectAuthCheck(projectId);
|
||||||
|
|
||||||
const result = await callClientToolWebhook(toolCall, projectId);
|
const result = await callClientToolWebhook(toolCall, messages, projectId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,11 @@ export async function POST(
|
||||||
const toolCallResults = await Promise.all(lastMessage.tool_calls.map(async toolCall => {
|
const toolCallResults = await Promise.all(lastMessage.tool_calls.map(async toolCall => {
|
||||||
console.log('executing tool call', toolCall);
|
console.log('executing tool call', toolCall);
|
||||||
try {
|
try {
|
||||||
return await callClientToolWebhook(toolCall, session.projectId);
|
return await callClientToolWebhook(
|
||||||
|
toolCall,
|
||||||
|
[...messages, ...unsavedMessages],
|
||||||
|
session.projectId,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error executing tool call ${toolCall.id}:`, error);
|
console.error(`Error executing tool call ${toolCall.id}:`, error);
|
||||||
return { error: "Tool execution failed" };
|
return { error: "Tool execution failed" };
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import crypto from "crypto";
|
||||||
|
|
||||||
export async function callClientToolWebhook(
|
export async function callClientToolWebhook(
|
||||||
toolCall: z.infer<typeof apiV1.AssistantMessageWithToolCalls>['tool_calls'][number],
|
toolCall: z.infer<typeof apiV1.AssistantMessageWithToolCalls>['tool_calls'][number],
|
||||||
|
messages: z.infer<typeof apiV1.ChatMessage>[],
|
||||||
projectId: string,
|
projectId: string,
|
||||||
): Promise<unknown> {
|
): Promise<unknown> {
|
||||||
const project = await projectsCollection.findOne({
|
const project = await projectsCollection.findOne({
|
||||||
|
|
@ -23,6 +24,7 @@ export async function callClientToolWebhook(
|
||||||
// prepare request body
|
// prepare request body
|
||||||
const content = JSON.stringify({
|
const content = JSON.stringify({
|
||||||
toolCall,
|
toolCall,
|
||||||
|
messages,
|
||||||
} as z.infer<typeof ClientToolCallRequestBody>);
|
} as z.infer<typeof ClientToolCallRequestBody>);
|
||||||
const requestId = crypto.randomUUID();
|
const requestId = crypto.randomUUID();
|
||||||
const bodyHash = crypto
|
const bodyHash = crypto
|
||||||
|
|
|
||||||
|
|
@ -443,6 +443,7 @@ function ClientToolCall({
|
||||||
try {
|
try {
|
||||||
response = await executeClientTool(
|
response = await executeClientTool(
|
||||||
toolCall,
|
toolCall,
|
||||||
|
messages,
|
||||||
projectId,
|
projectId,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue