kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
old-agentic-v1^2
rodzic
86935d8484
commit
122f01f6f4
|
@ -16,7 +16,7 @@ async function main() {
|
||||||
// .call()
|
// .call()
|
||||||
// console.log(ex0)
|
// 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.object({ foo: z.string(), bar: z.number() }))
|
||||||
// .output(z.string())
|
// .output(z.string())
|
||||||
// .retry({ attempts: 3 })
|
// .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(
|
gpt4(
|
||||||
promptOrChatCompletionParams:
|
promptOrChatCompletionParams:
|
||||||
| string
|
| string
|
||||||
|
|
|
@ -147,7 +147,7 @@ export abstract class BaseChatModelBuilder<
|
||||||
|
|
||||||
messages.push({
|
messages.push({
|
||||||
role: 'system',
|
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
|
\`\`\`ts
|
||||||
${tsTypeString}
|
${tsTypeString}
|
||||||
\`\`\``
|
\`\`\``
|
||||||
|
|
Ładowanie…
Reference in New Issue