carlrobertoh / CodeGPT

The leading open-source AI copilot for JetBrains. Connect to any model in any environment, and customize your coding experience in any way you like.
https://codegpt.ee
Apache License 2.0
1.01k stars 213 forks source link

Unknown API response. Code: 200 for valid local Ollama response #431

Open sltelitsyn opened 6 months ago

sltelitsyn commented 6 months ago

What happened?

Unknown API response. Code: 200, Body: {"model":"deepseek-coder:33b-instruct","created_at":"2024-04-04T18:08:49.964872346Z","message":{"role":"assistant","content":"As an AI developed by JetBrains, I have a variety of capabilities including but not limited to:\n\n1. Code Generation

Relevant log output or stack trace

Unknown API response. Code: 200, Body: {"model":"deepseek-coder:33b-instruct","created_at":"2024-04-04T18:08:49.964872346Z","message":{"role":"assistant","content":"As an AI developed by JetBrains, I have a variety of capabilities including but not limited to:\n\n1. **Code Generation**: I can generate code snippets based on your requirements in various programming languages like Java, Python, JavaScript, etc.\n\n2. **Debugging and Problem Solving**: I can help you debug your code by providing suggestions for potential issues or errors, helping to fix them and explaining why they occurred.\n\n3. **Code Review \u0026 Optimization**: I can review your code and suggest improvements, alternative solutions, or even optimize it to increase efficiency.\n\n4. **Documentation Generation**: I can help generate documentation comments for your functions based on their functionality.\n\n5. **Integration with Version Control Systems**: I integrate seamlessly with GitHub, GitLab, Bitbucket and other version control systems, allowing you to push changes directly from the IDE.\n\n6. **Support for Multiple Languages**: I support a wide range of programming languages such as Java, Python, JavaScript, C#, etc., helping you write code in your preferred language.\n\n7. **Code Completion and Suggestions**: I can provide suggestions while you are typing, saving you time and reducing syntax errors.\n\n8. **Refactoring \u0026 Extract Methods/Classes**: I can help refactor your existing code to improve its quality or extract methods/classes for better readability and maintainability. \n\nPlease note that my responses will be based on the programming language context, so please provide the appropriate information if you need assistance in a specific programming language.\n"},"done":true,"total_duration":16218742110,"load_duration":269793,"prompt_eval_count":7,"prompt_eval_duration":60020000,"eval_count":346,"eval_duration":16156342000}

Steps to reproduce

  1. Run Ollama from docker image https://hub.docker.com/r/ollama/ollama/
  2. Configure Code GPT with Service: Custom OpenAI Service, preset template: Ollama, URL: http://IP:11434/api/chat
  3. Send any request via context menu or directly from chat.

CodeGPT version

2.5.1

Operating System

macOS

sltelitsyn commented 6 months ago

It works fine with http://IP:11434/v1/chat/completions endpoint, but chat history isn't being sent in that case.

reneleonhardt commented 6 months ago

2 URLs are available:

If you change CodeGPT to /api/chat you will see a blue Test Connection but an Unknown API response, so CodeGPT doesn't implement that API, only /v1/chat/completions. It doesn't look like a bug, but a feature request 😉

rayondemiel commented 6 months ago

I have the same problem. I try to connect to this endpoint http://localhost:11434/v1/chat/completions but I get a 404 error POST "/v1/chat/completions/completion" . You can see that the plugin adds completion that doesn't match with API. Is there any way to suppress this addition?

sltelitsyn commented 5 months ago

2 URLs are available:

If you change CodeGPT to /api/chat you will see a blue Test Connection but an Unknown API response, so CodeGPT doesn't implement that API, only /v1/chat/completions. It doesn't look like a bug, but a feature request 😉

The issue is that it was unclear. I had to make trial and error to find a correct setting. Anyways, I'll change a type to Feature request. Thank you for the response.

UPD: or I guess, I can't.

carlrobertoh commented 5 months ago

Ollama provides an OpenAI-compatible chat completions endpoint, which can be configured in the Custom OpenAI Service configuration panel.