Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/client/core.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { CancellationToken } from 'vscode';
import { safeStringify } from '../json';
import { logger } from '../logger';
import type { ChatCompletionRequestBody } from '../provider/thinking';
import type {
DeepSeekRequest,
DeepSeekStreamChunk,
DeepSeekToolCall,
DeepSeekUsage,
Expand All @@ -25,7 +25,7 @@ export class DeepSeekClient {
* Parses SSE chunks and dispatches callbacks for content, thinking, and tool calls.
*/
async streamChatCompletion(
request: DeepSeekRequest,
request: ChatCompletionRequestBody,
callbacks: StreamCallbacks,
cancellationToken?: CancellationToken,
): Promise<void> {
Expand Down Expand Up @@ -81,7 +81,9 @@ export class DeepSeekClient {
break;
}

buffer += decoder.decode(value, { stream: true });
const decoded = decoder.decode(value, { stream: true });
callbacks.onRawResponseData?.(decoded);
buffer += decoded;

const lines = buffer.split('\n');
buffer = lines.pop() || '';
Expand Down
12 changes: 12 additions & 0 deletions src/client/error/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export class DeepSeekRequestError extends Error {
readonly diagnosticMessage: string;
readonly baseUrl?: string;
readonly status?: number;
readonly statusText?: string;
readonly code?: string;
readonly serverMessage?: string;
readonly responseText?: string;

constructor(options: {
message: string;
Expand All @@ -47,7 +50,10 @@ export class DeepSeekRequestError extends Error {
diagnosticMessage?: string;
baseUrl?: string;
status?: number;
statusText?: string;
code?: string;
serverMessage?: string;
responseText?: string;
cause?: unknown;
}) {
super(options.message, { cause: options.cause });
Expand All @@ -57,7 +63,10 @@ export class DeepSeekRequestError extends Error {
this.diagnosticMessage = options.diagnosticMessage ?? options.message;
this.baseUrl = options.baseUrl;
this.status = options.status;
this.statusText = options.statusText;
this.code = options.code;
this.serverMessage = options.serverMessage;
this.responseText = options.responseText;
}
}

Expand All @@ -79,7 +88,10 @@ export async function createHttpError(
kind: 'http',
baseUrl,
status: response.status,
statusText: response.statusText,
code: `HTTP_${response.status}`,
serverMessage,
responseText,
diagnosticMessage: joinDiagnosticParts(
`kind=http`,
`status=${response.status}`,
Expand Down
4 changes: 2 additions & 2 deletions src/client/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DeepSeekRequest } from '../types';
import type { ChatCompletionRequestBody } from '../provider/thinking';

export interface ErrorActionUrls {
configureApiKey?: string;
Expand All @@ -7,7 +7,7 @@ export interface ErrorActionUrls {

export interface RequestErrorContext {
baseUrl: string;
request: DeepSeekRequest;
request: ChatCompletionRequestBody;
}

export interface ErrorActionLink {
Expand Down
Loading
Loading