chatgpt-optimized-official
Advanced tools
Comparing version 1.2.7 to 1.2.8
@@ -19,4 +19,4 @@ import Usage from "../models/chatgpt-usage.js"; | ||
askStream(data: (arg0: string) => void, usage: (usage: Usage) => void, prompt: string, conversationId?: string, userName?: string): Promise<string>; | ||
askV1(prompt: string, conversationId?: string, type?: number, function_name?: string, userName?: string): Promise<any>; | ||
askPost(data: (arg0: string) => void, usage: (usage: Usage) => void, prompt: string, conversationId?: string, function_name?: string, userName?: string, type?: number): Promise<any>; | ||
askV1(prompt: string, conversationId?: string, type?: number, function_name?: string, tool_call_id?: string, userName?: string): Promise<any>; | ||
askPost(data: (arg0: string) => void, usage: (usage: Usage) => void, prompt: string, conversationId?: string, function_name?: string, userName?: string, type?: number, tool_call_id?: string): Promise<any>; | ||
moderate(prompt: string, key: string): Promise<boolean>; | ||
@@ -23,0 +23,0 @@ private generatePrompt; |
@@ -218,9 +218,9 @@ import axios from "axios"; | ||
} | ||
async askV1(prompt, conversationId = "default", type = 1, function_name, userName = "User") { | ||
return await this.askPost((data) => { }, (data) => { }, prompt, conversationId, function_name, userName, type); | ||
async askV1(prompt, conversationId = "default", type = 1, function_name, tool_call_id, userName = "User") { | ||
return await this.askPost((data) => { }, (data) => { }, prompt, conversationId, function_name, userName, type, tool_call_id); | ||
} | ||
async askPost(data, usage, prompt, conversationId = "default", function_name, userName = "User", type = MessageType.User) { | ||
async askPost(data, usage, prompt, conversationId = "default", function_name, userName = "User", type = MessageType.User, tool_call_id) { | ||
let oAIKey = this.getOpenAIKey(); | ||
let conversation = this.getConversation(conversationId, userName); | ||
let promptStr = this.generatePrompt(conversation, prompt, type, function_name); | ||
let promptStr = this.generatePrompt(conversation, prompt, type, function_name, tool_call_id); | ||
let prompt_tokens = this.countTokens(promptStr); | ||
@@ -287,3 +287,3 @@ try { | ||
} | ||
generatePrompt(conversation, prompt, type = MessageType.User, function_name) { | ||
generatePrompt(conversation, prompt, type = MessageType.User, function_name, tool_call_id) { | ||
let message = { | ||
@@ -297,2 +297,3 @@ id: randomUUID(), | ||
message["name"] = function_name; | ||
message["tool_call_id"] = tool_call_id; | ||
} | ||
@@ -322,3 +323,4 @@ conversation.messages.push(message); | ||
messages.push({ | ||
role: "function", | ||
tool_call_id: message.tool_call_id, | ||
role: "tool", | ||
name: message.name || "unknownFunction", | ||
@@ -325,0 +327,0 @@ content: message.content, |
@@ -5,3 +5,4 @@ interface ChatGPTMessage { | ||
name?: string; | ||
tool_call_id?: string; | ||
} | ||
export default ChatGPTMessage; |
@@ -8,3 +8,4 @@ import MessageType from "../enums/message-type.js"; | ||
name?: string; | ||
tool_call_id?: string; | ||
} | ||
export default Message; |
@@ -28,3 +28,3 @@ import { ChatGPT, Assistant } from "../dist/index.js"; | ||
"name": "createOrder", | ||
"description": "Guarda los datos de la orden incluyendo el nombre del cliente, dirección, opción de entrega, y la lista de productos seleccionados. siempre llama la función cuando el cliente confirme la orden, antes de pagar", | ||
"description": "Guarda los datos de la orden incluyendo el nombre del cliente, dirección, opción de entrega, lista de productos seleccionados, forma de pago . siempre llama la función cuando el cliente confirme la orden, antes de pagar", | ||
"parameters": { | ||
@@ -31,0 +31,0 @@ "type": "object", |
{ | ||
"name": "chatgpt-optimized-official", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"description": "ChatGPT Client using official OpenAI API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -261,3 +261,3 @@ import axios from "axios"; | ||
} | ||
public async askV1(prompt: string, conversationId: string = "default", type: number = 1, function_name?: string, userName: string = "User") { | ||
public async askV1(prompt: string, conversationId: string = "default", type: number = 1, function_name?: string, tool_call_id?:string, userName: string = "User") { | ||
return await this.askPost( | ||
@@ -270,6 +270,7 @@ (data) => { }, | ||
userName, | ||
type | ||
type, | ||
tool_call_id | ||
); | ||
} | ||
public async askPost(data: (arg0: string) => void, usage: (usage: Usage) => void, prompt: string, conversationId: string = "default",function_name?: string, userName: string = "User", type: number = MessageType.User) { | ||
public async askPost(data: (arg0: string) => void, usage: (usage: Usage) => void, prompt: string, conversationId: string = "default",function_name?: string, userName: string = "User", type: number = MessageType.User, tool_call_id?: string) { | ||
let oAIKey = this.getOpenAIKey(); | ||
@@ -284,3 +285,3 @@ let conversation = this.getConversation(conversationId, userName); | ||
let promptStr = this.generatePrompt(conversation, prompt, type, function_name); | ||
let promptStr = this.generatePrompt(conversation, prompt, type, function_name, tool_call_id); | ||
//console.log(promptStr) | ||
@@ -366,3 +367,3 @@ | ||
private generatePrompt(conversation: Conversation, prompt: string, type: number = MessageType.User, function_name?: string): Message[] { | ||
private generatePrompt(conversation: Conversation, prompt: string, type: number = MessageType.User, function_name?: string, tool_call_id?: string): Message[] { | ||
let message = { | ||
@@ -373,2 +374,3 @@ id: randomUUID(), | ||
date: Date.now(), | ||
}; | ||
@@ -378,2 +380,3 @@ | ||
message["name"] = function_name; | ||
message["tool_call_id"] = tool_call_id; | ||
} | ||
@@ -407,3 +410,4 @@ | ||
messages.push({ | ||
role: "function", | ||
tool_call_id: message.tool_call_id, | ||
role: "tool", | ||
name: message.name || "unknownFunction", // Default to "unknownFunction" if function_name is not provided | ||
@@ -410,0 +414,0 @@ content: message.content, |
@@ -5,4 +5,5 @@ interface ChatGPTMessage { | ||
name?: string; | ||
tool_call_id?: string; | ||
} | ||
export default ChatGPTMessage; |
@@ -9,4 +9,5 @@ import MessageType from "../enums/message-type.js"; | ||
name?: string; | ||
tool_call_id?: string; | ||
} | ||
export default Message; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
482479
2493