Skip to content

Commit

Permalink
AIX: server-side Top-P
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Dec 25, 2024
1 parent b2d66af commit f52e350
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ export function aixToAnthropicMessageCreate(model: AixAPI_Model, chatGenerate: A
// top_p: undefined,
};

// Top-P instead of temperature
if (model.topP !== undefined) {
payload.top_p = model.topP;
delete payload.temperature
}

// Preemptive error detection with server-side payload validation before sending it upstream
const validated = AnthropicWire_API_Message_Create.Request_schema.safeParse(payload);
if (!validated.success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export function aixToGeminiGenerateContent(model: AixAPI_Model, chatGenerate: Ai
},
};

// Top-P instead of temperature
if (model.topP !== undefined) {
delete payload.generationConfig!.temperature;
payload.generationConfig!.topP = model.topP;
}

// Preemptive error detection with server-side payload validation before sending it upstream
const validated = GeminiWire_API_Generate_Content.Request_schema.safeParse(payload);
if (!validated.success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export function aixToOpenAIChatCompletions(openAIDialect: OpenAIDialects, model:
user: undefined,
};

// Top-P instead of temperature
if (model.topP !== undefined) {
delete payload.temperature;
payload.top_p = model.topP;
}

if (hotFixOpenAIo1Family)
payload = _fixRequestForOpenAIO1_maxCompletionTokens(payload);

Expand Down

0 comments on commit f52e350

Please sign in to comment.