Blarc / ai-commits-intellij-plugin

AI Commits for IntelliJ based IDEs/Android Studio.
https://plugins.jetbrains.com/plugin/21335-ai-commits
MIT License
178 stars 26 forks source link

[Feature Request] Support Gemini API #196

Open IRedDragonICY opened 2 months ago

IRedDragonICY commented 2 months ago

Support Gemini API image (from Vertex or Makersuite)╰(°▽°)╯

Blarc commented 1 month ago

Added in v2.1.0.

IRedDragonICY commented 1 month ago

Thanks😁👍🏻

Blarc commented 1 month ago

@IRedDragonICY please report back any problems you might have, since I couldn't really test it, because I don't have a subscription. Thanks :pray: .

IRedDragonICY commented 1 month ago

Hello @Blarc,

I have reviewed the new update and noticed that it currently supports only the Vertex format and not the Google AI Studio (Makersuite) format.

There are currently three models:

Here is an example from Google AI Studio: (cURL)

API_KEY="YOUR_API_KEY"

curl \
  -X POST https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent?key=${API_KEY} \
  -H 'Content-Type: application/json' \
  -d @<(echo '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "INSERT_INPUT_HERE"
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 1,
    "topK": 64,
    "topP": 0.95,
    "maxOutputTokens": 8192,
    "responseMimeType": "text/plain"
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_MEDIUM_AND_ABOVE"
    },
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "BLOCK_MEDIUM_AND_ABOVE"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "BLOCK_MEDIUM_AND_ABOVE"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "BLOCK_MEDIUM_AND_ABOVE"
    }
  ]
}')

For Google AI Studio, we don't require Project ID and Location, only the Model and API key.

Thank you for your attention to this detail.

Blarc commented 1 month ago

Hey @IRedDragonICY, it seems langchain4j does not support this format?

IRedDragonICY commented 1 month ago

Unfortunately, it seems that Google AI Studio is not supported by langchain4j at this time, with only the Google Vertex format being compatible. As a temporary workaround, you might consider making HTTP requests manually for integration with Google AI Studio.

Blarc commented 1 month ago

Unfortunately, it seems that Google AI Studio is not supported by langchain4j at this time, with only the Google Vertex format being compatible. As a temporary workaround, you might consider making HTTP requests manually for integration with Google AI Studio.

I would rather try to open an issue or PR to langchain4j and first add the integration there.

MarJose123 commented 1 month ago

@IRedDragonICY you can use this and stage on vercel on your own, this is what i'm using since the plugin doesn't support yet Gemini.

https://github.com/PublicAffairs/openai-gemini

IRedDragonICY commented 1 month ago

@IRedDragonICY you can use this and stage on vercel on your own, this is what i'm using since the plugin doesn't support yet Gemini.

@MarJose123, Thanks for the suggestion! I’ve been using a similar solution for now, which is this repository: zhu327/gemini-openai-proxy. It's been working quite well as an interim measure until there's official support in the plugin.

GenhaoLi commented 2 weeks ago

@IRedDragonICY you can use this and stage on vercel on your own, this is what i'm using since the plugin doesn't support yet Gemini.

PublicAffairs/openai-gemini

Thanks a lot for the incredibly easy workaround!

Just wanna add a bit more info for anyone like me who doesn't have much experience with Vercel: