kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
old-agentic-v1^2
rodzic
b755db7c67
commit
49043941ca
|
@ -16,7 +16,7 @@ async function main() {
|
|||
// .call()
|
||||
// console.log(ex0)
|
||||
|
||||
const ex1 = await $.gpt4(`give me fake data`)
|
||||
const ex1 = await $.gpt4(`generate fake data`)
|
||||
.output(z.object({ foo: z.string(), bar: z.number() }))
|
||||
// .output(z.string())
|
||||
// .retry({ attempts: 3 })
|
||||
|
|
|
@ -34,6 +34,36 @@ export class Agentic {
|
|||
}
|
||||
}
|
||||
|
||||
llm(
|
||||
promptOrChatCompletionParams:
|
||||
| string
|
||||
| Partial<types.openai.ChatCompletionParams> // TODO: make more strict
|
||||
) {
|
||||
let options: Partial<types.openai.ChatCompletionParams>
|
||||
|
||||
if (typeof promptOrChatCompletionParams === 'string') {
|
||||
options = {
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
content: promptOrChatCompletionParams
|
||||
}
|
||||
]
|
||||
}
|
||||
} else {
|
||||
options = promptOrChatCompletionParams
|
||||
|
||||
if (!options.messages) {
|
||||
throw new Error('messages must be provided')
|
||||
}
|
||||
}
|
||||
|
||||
return new OpenAIChatModelBuilder(this._client, {
|
||||
...(this._defaults as any), // TODO
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
gpt4(
|
||||
promptOrChatCompletionParams:
|
||||
| string
|
||||
|
|
|
@ -147,7 +147,7 @@ export abstract class BaseChatModelBuilder<
|
|||
|
||||
messages.push({
|
||||
role: 'system',
|
||||
content: dedent`Output JSON only in the following TypeScript format:
|
||||
content: dedent`Do not output code. Output JSON only in the following TypeScript format:
|
||||
\`\`\`ts
|
||||
${tsTypeString}
|
||||
\`\`\``
|
||||
|
|
Ładowanie…
Reference in New Issue