Skip to content

ChatResponse TypeScript interface is declared wrong? #262

Description

@joaohcopetti

I'm using the "ollama/browser".

This is the ChatResponse:

interface ChatResponse {
    model: string;
    created_at: Date;
    message: Message;
    done: boolean;
    done_reason: string;
    total_duration: number;
    load_duration: number;
    prompt_eval_count: number;
    prompt_eval_duration: number;
    eval_count: number;
    eval_duration: number;
}

And the chat method returns this:

chat(request: ChatRequest & {
  stream: true;
}): Promise<AbortableAsyncIterator<ChatResponse>>;

chat(request: ChatRequest & {
  stream?: false;
}): Promise<ChatResponse>;

The problem is: when it's a stream, only the last response respects this definition:

// Before last.
// There's no: done_reason, eval_count, prompt_eval_count, load_duration, total_duration,
// like defined in the declaration type
{
    "model": "deepseek-v3.1:671b-cloud",
    "remote_model": "deepseek-v3.1:671b",
    "remote_host": "https://ollama.com:443",
    "created_at": "2025-11-13T16:52:22.297583788Z",
    "message": {
        "role": "assistant",
        "content": ""
    },
    "done": false
}

// Last
{
    "model": "deepseek-v3.1:671b-cloud",
    "remote_model": "deepseek-v3.1:671b",
    "remote_host": "https://ollama.com:443",
    "created_at": "2025-11-13T16:52:22.5313487Z",
    "message": {
        "role": "assistant",
        "content": ""
    },
    "done": true,
    "done_reason": "stop",
    "total_duration": 8186506778,
    "prompt_eval_count": 206,
    "eval_count": 60
}

Unless I'm missing something, those properties should be optional: done_reason, eval_count, prompt_eval_count, load_duration, total_duration.

Also, when using local the properties are different too, there's no: remote_model, remote_host.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions