kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
old-agentic-v1^2
rodzic
2ebb16a893
commit
7b4ebcab58
|
@ -212,6 +212,8 @@ export class OpenAIChatModelBuilder<
|
||||||
|
|
||||||
// TODO: filter/compress messages based on token counts
|
// TODO: filter/compress messages based on token counts
|
||||||
|
|
||||||
|
console.log('>>>')
|
||||||
|
console.log(messages)
|
||||||
const completion = await this._client.createChatCompletion({
|
const completion = await this._client.createChatCompletion({
|
||||||
model: defaultOpenAIModel, // TODO: this shouldn't be necessary but TS is complaining
|
model: defaultOpenAIModel, // TODO: this shouldn't be necessary but TS is complaining
|
||||||
...this._options.modelParams,
|
...this._options.modelParams,
|
||||||
|
@ -225,10 +227,14 @@ export class OpenAIChatModelBuilder<
|
||||||
: z.object(this._options.output)
|
: z.object(this._options.output)
|
||||||
|
|
||||||
let output: any = completion.message.content
|
let output: any = completion.message.content
|
||||||
|
console.log('===')
|
||||||
|
console.log(output)
|
||||||
|
console.log('<<<')
|
||||||
|
|
||||||
if (outputSchema instanceof z.ZodArray) {
|
if (outputSchema instanceof z.ZodArray) {
|
||||||
try {
|
try {
|
||||||
const trimmedOutput = extractJSONArrayFromString(output)
|
const trimmedOutput = extractJSONArrayFromString(output)
|
||||||
output = jsonrepair(trimmedOutput ?? output)
|
output = JSON.parse(jsonrepair(trimmedOutput ?? output))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// TODO
|
// TODO
|
||||||
throw err
|
throw err
|
||||||
|
@ -236,7 +242,7 @@ export class OpenAIChatModelBuilder<
|
||||||
} else if (outputSchema instanceof z.ZodObject) {
|
} else if (outputSchema instanceof z.ZodObject) {
|
||||||
try {
|
try {
|
||||||
const trimmedOutput = extractJSONObjectFromString(output)
|
const trimmedOutput = extractJSONObjectFromString(output)
|
||||||
output = jsonrepair(trimmedOutput ?? output)
|
output = JSON.parse(jsonrepair(trimmedOutput ?? output))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// TODO
|
// TODO
|
||||||
throw err
|
throw err
|
||||||
|
|
Ładowanie…
Reference in New Issue