chatgpt-optimized-official
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -49,4 +49,4 @@ import axios from "axios"; | ||
moderation: options?.moderation || false, | ||
functions: options?.functions || [], | ||
function_call: options?.function_call || "", | ||
functions: options?.functions || null, | ||
function_call: options?.function_call || null, | ||
}; | ||
@@ -150,4 +150,2 @@ } | ||
stream: true, | ||
functions: this.options.functions, | ||
function_call: this.options.function_call, | ||
}, { | ||
@@ -236,3 +234,3 @@ responseType: "stream", | ||
try { | ||
const response = await axios.post(this.options.endpoint, { | ||
let auxOptions = { | ||
model: this.options.model, | ||
@@ -246,5 +244,8 @@ messages: promptStr, | ||
stream: false, | ||
functions: this.options.functions, | ||
function_call: this.options.function_call, | ||
}, { | ||
}; | ||
if (this.options.functions) { | ||
auxOptions["functions"] = this.options.functions; | ||
auxOptions["function_call"] = this.options.function_call ? this.options.function_call : "auto"; | ||
} | ||
const response = await axios.post(this.options.endpoint, auxOptions, { | ||
responseType: "json", | ||
@@ -251,0 +252,0 @@ headers: { |
@@ -9,3 +9,3 @@ import { ChatGPT } from "../dist/index.js"; | ||
let bot = new ChatGPT("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", { | ||
let bot = new ChatGPT("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", { | ||
temperature: 0.7, // OpenAI parameter | ||
@@ -63,3 +63,3 @@ max_tokens: 256, // OpenAI parameter [Max response size by tokens] | ||
process.stdout.write(res.toString()); | ||
}, _ => { }, prompt, "17"); | ||
}, _ => { }, prompt, "19"); | ||
console.log(); | ||
@@ -66,0 +66,0 @@ } |
{ | ||
"name": "chatgpt-optimized-official", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "ChatGPT Client using official OpenAI API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -54,4 +54,4 @@ import axios from "axios"; | ||
moderation: options?.moderation || false, | ||
functions: options?.functions || [], | ||
function_call: options?.function_call || "", | ||
functions: options?.functions || null, | ||
function_call: options?.function_call || null, | ||
}; | ||
@@ -182,4 +182,2 @@ } | ||
stream: true, | ||
functions: this.options.functions, | ||
function_call: this.options.function_call, | ||
}, | ||
@@ -263,3 +261,3 @@ { | ||
} | ||
public async askV1(prompt: string, conversationId: string = "default", type:number=1, userName: string = "User") { | ||
public async askV1(prompt: string, conversationId: string = "default", type: number = 1, userName: string = "User") { | ||
return await this.askPost( | ||
@@ -287,17 +285,20 @@ (data) => { }, | ||
try { | ||
let auxOptions = { | ||
model: this.options.model, | ||
messages: promptStr, | ||
temperature: this.options.temperature, | ||
max_tokens: this.options.max_tokens, | ||
top_p: this.options.top_p, | ||
frequency_penalty: this.options.frequency_penalty, | ||
presence_penalty: this.options.presence_penalty, | ||
stream: false, // Note this | ||
} | ||
if(this.options.functions){ | ||
auxOptions["functions"] = this.options.functions; | ||
auxOptions["function_call"] = this.options.function_call?this.options.function_call:"auto"; | ||
} | ||
const response = await axios.post( | ||
this.options.endpoint, | ||
auxOptions, | ||
{ | ||
model: this.options.model, | ||
messages: promptStr, | ||
temperature: this.options.temperature, | ||
max_tokens: this.options.max_tokens, | ||
top_p: this.options.top_p, | ||
frequency_penalty: this.options.frequency_penalty, | ||
presence_penalty: this.options.presence_penalty, | ||
stream: false, // Note this | ||
functions: this.options.functions, | ||
function_call: this.options.function_call, | ||
}, | ||
{ | ||
responseType: "json", // Note this | ||
@@ -311,3 +312,3 @@ headers: { | ||
); | ||
// console.log("Stream message:", response.data.choices[0]) | ||
//console.log("Stream message:", response.data.choices[0]) | ||
let completion_tokens = response.data.usage['completion_tokens']; | ||
@@ -314,0 +315,0 @@ |
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
119545
1688