修复流式参数处理:尊重客户端明确指定的stream参数
- 修正transformers中强制添加stream=true的错误逻辑 - 只有客户端明确指定stream参数时才转发该参数 - 客户端未指定stream时不强制添加,保持原有意图 - 更新routes.js中相应的流式判断逻辑 - 确保非流式请求得到正确处理
This commit is contained in:
@@ -6,10 +6,14 @@ export function transformToAnthropic(openaiRequest) {
|
||||
|
||||
const anthropicRequest = {
|
||||
model: openaiRequest.model,
|
||||
messages: [],
|
||||
stream: openaiRequest.stream !== false
|
||||
messages: []
|
||||
};
|
||||
|
||||
// Only add stream parameter if explicitly provided by client
|
||||
if (openaiRequest.stream !== undefined) {
|
||||
anthropicRequest.stream = openaiRequest.stream;
|
||||
}
|
||||
|
||||
// Handle max_tokens
|
||||
if (openaiRequest.max_tokens) {
|
||||
anthropicRequest.max_tokens = openaiRequest.max_tokens;
|
||||
|
||||
@@ -7,10 +7,14 @@ export function transformToOpenAI(openaiRequest) {
|
||||
const targetRequest = {
|
||||
model: openaiRequest.model,
|
||||
input: [],
|
||||
store: false,
|
||||
stream: openaiRequest.stream !== false
|
||||
store: false
|
||||
};
|
||||
|
||||
// Only add stream parameter if explicitly provided by client
|
||||
if (openaiRequest.stream !== undefined) {
|
||||
targetRequest.stream = openaiRequest.stream;
|
||||
}
|
||||
|
||||
// Transform max_tokens to max_output_tokens
|
||||
if (openaiRequest.max_tokens) {
|
||||
targetRequest.max_output_tokens = openaiRequest.max_tokens;
|
||||
|
||||
Reference in New Issue
Block a user