mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 00:02:45 +00:00
refactor(ai): streamline codex prompt handling
This commit is contained in:
parent
b04ce9fe95
commit
858c6bae8a
6 changed files with 99 additions and 104 deletions
|
|
@ -33,6 +33,8 @@ import {
|
|||
URL_PATHS,
|
||||
} from "./openai-codex/constants.js";
|
||||
import { getCodexInstructions } from "./openai-codex/prompts/codex.js";
|
||||
import { buildCodexPiBridge } from "./openai-codex/prompts/pi-codex-bridge.js";
|
||||
import { buildCodexSystemPrompt } from "./openai-codex/prompts/system-prompt.js";
|
||||
import {
|
||||
type CodexRequestOptions,
|
||||
normalizeModel,
|
||||
|
|
@ -110,6 +112,15 @@ export const streamOpenAICodexResponses: StreamFunction<"openai-codex-responses"
|
|||
|
||||
const normalizedModel = normalizeModel(params.model);
|
||||
const codexInstructions = await getCodexInstructions(normalizedModel);
|
||||
const bridgeText = buildCodexPiBridge(context.tools);
|
||||
const systemPrompt = buildCodexSystemPrompt({
|
||||
codexInstructions,
|
||||
bridgeText,
|
||||
userSystemPrompt: context.systemPrompt,
|
||||
});
|
||||
|
||||
params.model = normalizedModel;
|
||||
params.instructions = systemPrompt.instructions;
|
||||
|
||||
const codexOptions: CodexRequestOptions = {
|
||||
reasoningEffort: options?.reasoningEffort,
|
||||
|
|
@ -118,13 +129,7 @@ export const streamOpenAICodexResponses: StreamFunction<"openai-codex-responses"
|
|||
include: options?.include,
|
||||
};
|
||||
|
||||
const transformedBody = await transformRequestBody(
|
||||
params,
|
||||
codexInstructions,
|
||||
codexOptions,
|
||||
options?.codexMode ?? true,
|
||||
context.systemPrompt,
|
||||
);
|
||||
const transformedBody = await transformRequestBody(params, codexOptions, systemPrompt);
|
||||
|
||||
const reasoningEffort = transformedBody.reasoning?.effort ?? null;
|
||||
const headers = createCodexHeaders(model.headers, accountId, apiKey, transformedBody.prompt_cache_key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue