format content
This commit is contained in:
parent
7889f888f6
commit
0e747b4476
@ -41,13 +41,13 @@ const buildOptions = async (input: AIInput<any>, config: AIConfig = {}) => {
|
|||||||
const outputBuilders: Record<string, (schema: any) => any> = {
|
const outputBuilders: Record<string, (schema: any) => any> = {
|
||||||
schema: (s) => {
|
schema: (s) => {
|
||||||
const schemaPrompt = `\n请按照以下 schema 格式返回结果:\n${JSON.stringify(
|
const schemaPrompt = `\n请按照以下 schema 格式返回结果:\n${JSON.stringify(
|
||||||
z.toJSONSchema(z.object(s)),
|
z.toJSONSchema(z.object(s)),
|
||||||
null,
|
null,
|
||||||
2,
|
2,
|
||||||
)}\n请输出JSON格式,只返回结果,不要将Schema返回。`;
|
)}\n请输出JSON格式,只返回结果,不要将Schema返回。`;
|
||||||
input.system = (input.system ?? "") + schemaPrompt;
|
input.system = (input.system ?? "") + schemaPrompt;
|
||||||
// 返回验证模式
|
// 返回验证模式
|
||||||
return Output.object({ schema: z.object(s) });
|
return Output.object({ schema: z.object(s) });
|
||||||
},
|
},
|
||||||
object: () => {
|
object: () => {
|
||||||
const jsonSchemaPrompt = `\n请按照以下 JSON Schema 格式返回结果:\n${JSON.stringify(
|
const jsonSchemaPrompt = `\n请按照以下 JSON Schema 格式返回结果:\n${JSON.stringify(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user