fix(openai): map system prompts to top-level instructions for ChatGPT auth requests

This commit is contained in:
2026-05-14 19:47:17 +00:00
parent 8a6c92c04e
commit c8f98b3364
4 changed files with 71 additions and 5 deletions
+10 -4
View File
@@ -199,15 +199,21 @@ tap.test('getModel uses ChatGPT Codex backend for OpenAI ChatGPT auth', async ()
};
try {
await model.doGenerate({
prompt: [{ role: 'user', content: [{ type: 'text', text: 'hello' }] }],
inputFormat: 'prompt',
} as any);
await smartai.generateText({
model,
system: 'system prompt',
prompt: 'hello',
});
expect(capturedRequest?.url).toEqual('https://chatgpt.com/backend-api/codex/responses');
expect(getHeader(capturedRequest?.init, 'authorization')).toEqual(`Bearer ${tokenData.accessToken}`);
expect(getHeader(capturedRequest?.init, 'chatgpt-account-id')).toEqual('workspace-1');
expect(getHeader(capturedRequest?.init, 'originator')).toEqual('smartai');
const capturedBody = JSON.parse(String(capturedRequest?.init?.body));
expect(capturedBody.instructions).toEqual('system prompt');
expect(capturedBody.input).toEqual([
{ role: 'user', content: [{ type: 'input_text', text: 'hello' }] },
]);
} finally {
globalThis.fetch = originalFetch;
}