DevoxxGenieIDEAPlugin icon indicating copy to clipboard operation
DevoxxGenieIDEAPlugin copied to clipboard

[BUG] Issue with custom OpenAI model due to duplicated user prompt

Open fchill opened this issue 6 months ago • 4 comments

I am trying to use DevoxxGenie with a mistral model that is hosted on premise at my company. This server unfortunatly answers all prompts from DevoxxGenie with HTTP500. Digging into this issue, I found that there are duplicated user prompts being sent in the messages field. I replaced the Custom OpenAI URL with a server running on localhost that just logs all incoming http requests and found:

Request Method: POST
Request URL: /chat/completions
Request Headers:
{
  connection: 'Upgrade, HTTP2-Settings',
  'content-length': '946',
  host: 'localhost:3000',
  'http2-settings': 'AAEAAEAAAAIAAAAAAAMAAAAAAAQBAAAAAAUAAEAAAAYABgAA',
  upgrade: 'h2c',
  authorization: 'Bearer na',
  'content-type': 'application/json',
  'user-agent': 'langchain4j-openai'                                                                                                                                                                                                                                                                                
}
Request Body:
{
  "model" : "Mistral-Small-24B-Instruct-2501",
  "messages" : [ {
    "role" : "system",
    "content" : "You are a software developer IDEA plugin with expert knowledge in any programming language.\n\nThe Devoxx Genie is open source and available at https://github.com/devoxx/DevoxxGenieIDEAPlugin.\nYou can follow us on Bluesky @ https://bsky.app/profile/devoxxgenie.bsky.social.\nDo not include any more info which might be incorrect, like discord, documentation or other websites.\nOnly provide info that is correct and relevant to the code or plugin.\n\nAlways use markdown to format your prompt. For example, use **bold** or *italic* text and ``` code blocks ```."
  }, {
    "role" : "user",
    "content" : "<UserPrompt>\ntest\n</UserPrompt>\n\n"
  }, {
    "role" : "user",
    "content" : "test"
  } ],
  "temperature" : 0.2,
  "top_p" : 0.9,
  "stream" : true,
  "stream_options" : {
    "include_usage" : true
  }
}

As you can see, there are two messages of type "user" being sent at once. The first one is expanded by further context if I choose so. Manually removing one of the user-messages and sending that request to our actual model solves the HTTP500 issue.

I am unsure if it is indeed an error to send two consecutive "user" elements in this list, but at least it seems redundant and counterintuitive and causes the issue with our model as described.

I am using DevoxxGenie in IDEA 2025.1.2 CE on Windows 10.

fchill avatar Jun 12 '25 12:06 fchill

Thanks for reporting this, will investigate.

stephanj avatar Jun 20 '25 06:06 stephanj

Hi @stephanj, I found the cause inside the StreamingPromptStrategy. The user message was added to the history before executing the chat request. So it turns up once from the history and another time as current chat message. If you kindly give me permission to push my branch I will create a PR.

fchill avatar Jul 10 '25 16:07 fchill

Hey, you should be able to just create a PR... more than happy to merge it into this project!

stephanj avatar Jul 10 '25 20:07 stephanj

In case you need help, I have written a blog about my first PR (starting from paragraph 4): https://mydeveloperplanet.com/2021/01/20/how-to-start-contributing-to-open-source/

  1. Fork the repo (it will appear in your github account)
  2. clone the repo from your github account
  3. create a branch, apply fixes, commit, push to your account
  4. Create the PR

mydeveloperplanet avatar Jul 12 '25 06:07 mydeveloperplanet