♻️(engine): extract custom header parsing and update OpenAiEngine

- export parseCustomHeaders from src/utils/engine.ts
- use parseCustomHeaders in OpenAiEngine for config.customHeaders
- remove try/catch and inline JSON.parse logic
- update config test to expect headers as object and drop JSON.parse

Centralize header parsing for reuse and simplify engine code
Update tests to match new header format for clarity
This commit is contained in:
EmilienMottet
2025-04-30 21:43:44 +02:00
parent 71a44fac28
commit 6aae1c7bd7
3 changed files with 8 additions and 14 deletions

View File

@@ -12,7 +12,7 @@ import { GroqEngine } from '../engine/groq';
import { MLXEngine } from '../engine/mlx';
import { DeepseekEngine } from '../engine/deepseek';
function parseCustomHeaders(headers: any): Record<string, string> {
export function parseCustomHeaders(headers: any): Record<string, string> {
let parsedHeaders = {};
if (!headers) {