[GH-ISSUE #8846] Ai responses stopped #5733

Closed
opened 2026-04-12 17:01:24 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @seghier on GitHub (Feb 5, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8846

Hello,
I tried some models from the Ollama website, but the responses always stop after 15 or 20 answers.
I also tried a code example from Microsoft, and the same issue occurred.
I asked ChatGPT, and it responded that the issue is related to tokens, but I couldn't find a solution.

using Microsoft.Extensions.AI;

IChatClient chatClient = 
    new OllamaChatClient(new Uri("http://localhost:11434/"), "phi3:mini");

// Start the conversation with context for the AI model
List<ChatMessage> chatHistory = new();

while (true)
{
    // Get user prompt and add to chat history
    Console.WriteLine("Your prompt:");
    var userPrompt = Console.ReadLine();
    chatHistory.Add(new ChatMessage(ChatRole.User, userPrompt));

    // Stream the AI response and add to chat history
    Console.WriteLine("AI Response:");
    var response = "";
    await foreach (var item in
        chatClient.CompleteStreamingAsync(chatHistory))
    {
        Console.Write(item.Text);
        response += item.Text;
    }
    chatHistory.Add(new ChatMessage(ChatRole.Assistant, response));
    Console.WriteLine();
}
Originally created by @seghier on GitHub (Feb 5, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8846 Hello, I tried some models from the Ollama website, but the responses always stop after 15 or 20 answers. I also tried a code example from Microsoft, and the same issue occurred. I asked ChatGPT, and it responded that the issue is related to tokens, but I couldn't find a solution. ``` using Microsoft.Extensions.AI; IChatClient chatClient = new OllamaChatClient(new Uri("http://localhost:11434/"), "phi3:mini"); // Start the conversation with context for the AI model List<ChatMessage> chatHistory = new(); while (true) { // Get user prompt and add to chat history Console.WriteLine("Your prompt:"); var userPrompt = Console.ReadLine(); chatHistory.Add(new ChatMessage(ChatRole.User, userPrompt)); // Stream the AI response and add to chat history Console.WriteLine("AI Response:"); var response = ""; await foreach (var item in chatClient.CompleteStreamingAsync(chatHistory)) { Console.Write(item.Text); response += item.Text; } chatHistory.Add(new ChatMessage(ChatRole.Assistant, response)); Console.WriteLine(); } ```
GiteaMirror added the needs more info label 2026-04-12 17:01:24 -05:00
Author
Owner

@Villantiqua commented on GitHub (Feb 5, 2025):

You should increase the context window size: https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-specify-the-context-window-size

<!-- gh-comment-id:2636991532 --> @Villantiqua commented on GitHub (Feb 5, 2025): You should increase the context window size: https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-specify-the-context-window-size
Author
Owner

@rick-github commented on GitHub (Feb 5, 2025):

Server logs may aid in debugging.

<!-- gh-comment-id:2637292576 --> @rick-github commented on GitHub (Feb 5, 2025): [Server logs](https://github.com/ollama/ollama/blob/main/docs/troubleshooting.md#how-to-troubleshoot-issues) may aid in debugging.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5733