wip(confidence-engine): checkpoint open-question presentation work
This commit is contained in:
+17
-5
@@ -546,10 +546,15 @@ class OpenAIReconstructionProvider {
|
||||
this.fetchImpl = fetchImpl;
|
||||
}
|
||||
|
||||
async generateReconstruction(prompt, modelName = "gpt-5.6-terra", outputSchema, { signal } = {}) {
|
||||
async generateReconstruction(
|
||||
prompt,
|
||||
modelName = "gpt-5.6-terra",
|
||||
outputSchema,
|
||||
{ signal, outputZodSchema } = {},
|
||||
) {
|
||||
if (!this.apiKey) throw new Error("OPENAI_API_KEY is not set");
|
||||
const structuredOutputSchema = outputSchema
|
||||
? createOpenAIStrictSchema(outputSchema, null)
|
||||
? createOpenAIStrictSchema(outputSchema, outputZodSchema ?? null)
|
||||
: openAIReconstructionJsonSchema;
|
||||
|
||||
const format = {
|
||||
@@ -594,10 +599,17 @@ class OpenAIReconstructionProvider {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const recoveredResponse = recoverJson(outputText);
|
||||
const normalisedResponse = outputSchema && !outputZodSchema
|
||||
? recoveredResponse
|
||||
: normaliseOpenAITransportResponse(
|
||||
recoveredResponse,
|
||||
outputZodSchema ?? reconstructionV2Schema,
|
||||
outputSchema ?? reconstructionJsonSchema,
|
||||
);
|
||||
|
||||
return {
|
||||
response: outputSchema
|
||||
? recoverJson(outputText)
|
||||
: normaliseOpenAITransportResponse(recoverJson(outputText)),
|
||||
response: normalisedResponse,
|
||||
providerApiPath: "/v1/responses",
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user