const result = await leadContract.accept(async (attempt) => {
const response = await openai.responses.create({
model: process.env.OPENAI_MODEL ?? "gpt-4.1",
input: [
{
role: "user",
content: [
"Score this lead as JSON.",
attempt.instructions,
`Lead: ${leadSummary}`,
].join("\n\n"),
},
...attempt.repairs,
],
text: {
format: {
type: "json_schema",
name: "lead_score",
schema: {
type: "object",
additionalProperties: false,
properties: {
tier: { type: "string", enum: ["hot", "warm", "cold"] },
score: { type: "number", minimum: 0, maximum: 100 },
reason: { type: "string" },
},
required: ["tier", "score", "reason"],
},
},
},
});
return response.output_text;
});