Skip to content

Commit

Permalink
fix: 统一处理响应头中的内容类型,增强 JSON 响应判断的准确性
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Dec 25, 2024
1 parent 2b81827 commit 67c61c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/buildinfo.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/lib/core/src/agent/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ function fixOpenAICompatibleOptions(options: SseChatCompatibleOptions | null): S
}

export function isJsonResponse(resp: Response): boolean {
return resp.headers.get('content-type')?.includes('json') || false;
const contentType = resp.headers.get('content-type');
return contentType?.toLowerCase().includes('application/json') ?? false;
}

export function isEventStreamResponse(resp: Response): boolean {
const types = ['application/stream+json', 'text/event-stream'];
const content = resp.headers.get('content-type') || '';
const content = resp.headers.get('content-type')?.toLowerCase() || '';
for (const type of types) {
if (content.includes(type)) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/core/src/config/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const BUILD_TIMESTAMP = 1735035887;
export const BUILD_VERSION = 'e9ceae4';
export const BUILD_TIMESTAMP = 1735091598;
export const BUILD_VERSION = '2b81827';

0 comments on commit 67c61c3

Please sign in to comment.