File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @pipedream/ai" ,
33 "type" : " module" ,
4- "version" : " 0.0.2 " ,
4+ "version" : " 0.0.3 " ,
55 "description" : " Pipedream AI" ,
66 "main" : " ./dist/index.js" ,
77 "types" : " ./dist/index.d.ts" ,
Original file line number Diff line number Diff line change 1- import OpenAI from "openai/index.mjs" ;
2- import { ChatCompletionTool } from "openai/resources/chat/completions" ;
1+ import { type OpenAI } from "openai" ;
2+ import {
3+ type ChatCompletionTool ,
4+ type ChatCompletionToolMessageParam ,
5+ } from "openai/resources/chat/completions" ;
36import { zodToJsonSchema } from "zod-to-json-schema" ;
47import { CoreTools } from "./core" ;
58
@@ -26,7 +29,9 @@ export class OpenAiTools {
2629 } ) ;
2730 }
2831
29- async handleCompletion ( completion : OpenAI . Chat . Completions . ChatCompletion ) {
32+ async handleCompletion (
33+ completion : OpenAI . Chat . Completions . ChatCompletion ,
34+ ) : Promise < ChatCompletionToolMessageParam [ ] | undefined > {
3035 const toolCalls = completion . choices [ 0 ] . message . tool_calls ;
3136 if ( ! toolCalls ) {
3237 return ;
@@ -43,7 +48,12 @@ export class OpenAiTools {
4348 const parsedArgs = tool . schema . parse ( args ) ;
4449
4550 const result = await tool . execute ( parsedArgs ) ;
46- return result ;
51+ const toolResult : ChatCompletionToolMessageParam = {
52+ role : "tool" ,
53+ tool_call_id : toolCall . id ,
54+ content : JSON . stringify ( result , null , 2 ) ,
55+ } ;
56+ return toolResult ;
4757 } ) ,
4858 ) ;
4959 return results ;
You can’t perform that action at this time.
0 commit comments