Skip to content

aider with ollama fails when generating a commit message #624

Closed
@yrobla

Description

@yrobla

Describe the issue

When a commit message is proposed for an specific file edit, we get error:
litellm.APIConnectionError: Ollama_chatException - Extra data: line 2 column 1 (char 437)

I debugged the issue and it was narrowed at the step when aider generates a commit message, using LLM, and sends a request like:

in send completion
{'model': 'ollama_chat/qwen2.5-coder:7b', 'messages': [{'role': 'system', 'content': 'You are an expert software engineer that generates concise, one-line Git commit messages based on the provided diffs.\nReview the provided context and diffs which are about to be committed to a git repo.\nReview the diffs carefully.\nGenerate a one-line commit message for those changes.\nThe commit message should be structured as follows: : \nUse these for : fix, feat, build, chore, ci, docs, style, refactor, perf, test\n\nEnsure the commit message:\n- Starts with the appropriate prefix.\n- Is in the imperative mood (e.g., "Add feature" not "Added feature" or "Adding feature").\n- Does not exceed 72 characters.\n\nReply only with the one-line commit message, without any additional text, explanations, or line breaks.\n'}, {'role': 'user', 'content': '# Diffs:\ndiff --git a/app.py b/app.py\nindex abc9ebf..230525e 100644\n--- a/app.py\n+++ b/app.py\n@@ -4,11 +4,3 @@ def hello():\n Returns a greeting message. Checks for the presence of a GitHub token\n and returns a specific message if the token is found.\n """\n- GITHUB_TOKEN="xxxx"\n- AWS_ACCESS_KEY_ID="xxx"\n- AWS_SECRET_ACCESS_KEY="xxx"\n- GITHUB_TOKEN="xxx"\n- if GITHUB_TOKEN:\n- return "Hello from Python 3.8 inside an EC2 instance running on Fargate, with a Github Token like this one in the code base!!"\n- else:\n- return "Hello, Mars! We have no token here"'}], 'stream': False}

Litellm fails directly, seems we are sending some malformed json.

Steps to Reproduce

Have this file:

@app.route('/')
def hello():
"""
Returns a greeting message. Checks for the presence of a GitHub token
and returns a specific message if the token is found.
"""
GITHUB_TOKEN="xxx"
AWS_ACCESS_KEY_ID="xx"
AWS_SECRET_ACCESS_KEY="xx/K7MDENG/bPxRfiCYEXAMPLEKEY"
GITHUB_TOKEN="xx"
if GITHUB_TOKEN:
return "Hello from Python 3.8 inside an EC2 instance running on Fargate, with a Github Token like this one in the code base!!"
else:
return "Hello, Mars! We have no token here"

Execute: aider app.py --model "ollama_chat/qwen2.5-coder:7b" --message "explain this app line by line"

and wait until the commit generation step

Operating System

MacOS (Arm)

IDE and Version

aider

Extension and Version

latest

Provider

Ollama

Model

qwen

Logs

No response

Additional Context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions