修复codex
This commit is contained in:
parent
2f2d0de8b4
commit
cd15a3a637
3 changed files with 43 additions and 30 deletions
|
|
@ -61,7 +61,7 @@ export class CodexConverter extends BaseConverter {
|
|||
effort: 'medium',
|
||||
summary: 'auto'
|
||||
},
|
||||
parallel_tool_calls: data.parallel_tool_calls !== false,
|
||||
parallel_tool_calls: true,
|
||||
include: ['reasoning.encrypted_content']
|
||||
};
|
||||
|
||||
|
|
@ -83,16 +83,10 @@ export class CodexConverter extends BaseConverter {
|
|||
codexRequest.reasoning.effort = data.reasoning_effort;
|
||||
}
|
||||
|
||||
// 添加温度和其他参数
|
||||
if (data.temperature !== undefined) {
|
||||
codexRequest.temperature = data.temperature;
|
||||
}
|
||||
if (data.max_tokens !== undefined) {
|
||||
codexRequest.max_output_tokens = data.max_tokens;
|
||||
}
|
||||
if (data.top_p !== undefined) {
|
||||
codexRequest.top_p = data.top_p;
|
||||
}
|
||||
/*
|
||||
Codex doesn't support temperature, top_p, top_k, max_tokens anymore in the new protocol.
|
||||
Removed mapping for these fields.
|
||||
*/
|
||||
|
||||
return codexRequest;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import os from 'os';
|
|||
import { refreshCodexTokensWithRetry } from '../../auth/oauth-handlers.js';
|
||||
import { getProviderPoolManager } from '../../services/service-manager.js';
|
||||
import { MODEL_PROVIDER, formatExpiryLog } from '../../utils/common.js';
|
||||
import { getProxyConfigForProvider } from '../../utils/proxy-utils.js';
|
||||
|
||||
/**
|
||||
* Codex API 服务类
|
||||
|
|
@ -77,10 +78,10 @@ export class CodexApiService {
|
|||
creds = JSON.parse(await fs.readFile(credsPath, 'utf8'));
|
||||
}
|
||||
|
||||
this.accessToken = creds.access_token;
|
||||
this.refreshToken = creds.refresh_token;
|
||||
this.accountId = creds.account_id;
|
||||
this.email = creds.email;
|
||||
this.accessToken = creds.access_token;
|
||||
this.refreshToken = creds.refresh_token;
|
||||
this.accountId = creds.account_id;
|
||||
this.email = creds.email;
|
||||
this.expiresAt = new Date(creds.expired); // 注意:字段名是 expired
|
||||
|
||||
// 检查 token 是否需要刷新
|
||||
|
|
@ -150,10 +151,19 @@ export class CodexApiService {
|
|||
const headers = this.buildHeaders(body.prompt_cache_key);
|
||||
|
||||
try {
|
||||
const response = await axios.post(url, body, {
|
||||
const config = {
|
||||
headers,
|
||||
timeout: 120000 // 2 分钟超时
|
||||
});
|
||||
};
|
||||
|
||||
// 配置代理
|
||||
const proxyConfig = getProxyConfigForProvider(this.config, 'codex');
|
||||
if (proxyConfig) {
|
||||
config.httpAgent = proxyConfig.httpAgent;
|
||||
config.httpsAgent = proxyConfig.httpsAgent;
|
||||
}
|
||||
|
||||
const response = await axios.post(url, body, config);
|
||||
|
||||
return this.parseNonStreamResponse(response.data);
|
||||
} catch (error) {
|
||||
|
|
@ -203,11 +213,20 @@ export class CodexApiService {
|
|||
const headers = this.buildHeaders(body.prompt_cache_key);
|
||||
|
||||
try {
|
||||
const response = await axios.post(url, body, {
|
||||
const config = {
|
||||
headers,
|
||||
responseType: 'stream',
|
||||
timeout: 120000
|
||||
});
|
||||
};
|
||||
|
||||
// 配置代理
|
||||
const proxyConfig = getProxyConfigForProvider(this.config, 'codex');
|
||||
if (proxyConfig) {
|
||||
config.httpAgent = proxyConfig.httpAgent;
|
||||
config.httpsAgent = proxyConfig.httpsAgent;
|
||||
}
|
||||
|
||||
const response = await axios.post(url, body, config);
|
||||
|
||||
yield* this.parseSSEStream(response.data);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ export function getProxyConfigForProvider(config, providerType) {
|
|||
|
||||
const proxyConfig = parseProxyUrl(config.PROXY_URL);
|
||||
if (proxyConfig) {
|
||||
logger.info(`[Proxy] Using ${proxyConfig.proxyType} proxy for ${providerType}: ${config.PROXY_URL}`);
|
||||
// logger.info(`[Proxy] Using ${proxyConfig.proxyType} proxy for ${providerType}: ${config.PROXY_URL}`);
|
||||
}
|
||||
return proxyConfig;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue