fix(openai): map system prompts to top-level instructions for ChatGPT auth requests
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user