Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/Add gemini support #26

Closed
wants to merge 17 commits into from

Conversation

Dioprz
Copy link
Contributor

@Dioprz Dioprz commented Jul 8, 2024

Hi @frankroeder.

Here is my draft with some proposed changes. As I was expecting, things became confusing to me when I was trying to write the gemini.lua file.

So, things pending to do are:

  1. I used the same settings OpenAI models had for the temperature and the top_p. I really don't know how good those will behave, but I also don't have the knowledge to set them in a proper way. If you can give me a hint or put them in a sane default, that can be great.
  2. At the gemini.lua file:
    1. Gemini has a very unusual way to format the curl commands from what I saw in the other providers. Please check the curl_params as I added the model directly into that line, and I'm not sure it's ok.
    2. The verify method looks... Pretty standard.
    3. I was plainly lost on what to do in the preprocess_messages, add_system_prompt, process and check methods.

For reference, here is the documentation I'm following: Gemini API REST. Btw, I'm working with generateContent, should I work with streamGenerateContent instead?

Thanks for your help in advance!

@frankroeder
Copy link
Owner

frankroeder commented Jul 8, 2024

Hi @Dioprz, thank you for this PR and your email! I will get back to you very soon.

@frankroeder
Copy link
Owner

Hi @Dioprz, feel free to check out this version. There may be some remaining issues with parsing the streaming response, but otherwise, Gemini is ready to use.

I had to eliminate all the standard curl body parameters that, for example, OpenAI uses, as the Gemini API operates differently. Indeed, I employ the streamGenerateContent.

Right now, we're working on restructuring methods like the preprocess_messages, so don't worry if it currently seems difficult to use.I have written you an additional email.

@frankroeder frankroeder marked this pull request as ready for review July 9, 2024 08:36
@frankroeder
Copy link
Owner

@Dioprz, let me know if you have any issue or if it works as expected.

@Dioprz
Copy link
Contributor Author

Dioprz commented Jul 10, 2024

Hi @frankroeder,

Sorry for the delay. I have tested your changes, and everything looks really great.

There is just one thing related to parsing the streaming response. When trying to chat with Gemini, sometimes I get incomplete responses like these (see the "" in all of them):

  1. 🗨:
    Hey, are you working?
    
    🦜:[Gemini-1.5-Flash-Chat - gemini]
    As a large language model, I don't work in the traditional sense. I'm always \ So, in that sense, I'm always working! 
  2. 🗨:
    And this?
    
    🦜:[Gemini-1.5-Flash-Chat - gemini]
    \And this?\ understand what you're asking, please give me more context. For example:
    
    * **What is \ to know about it?**  Do you want me to analyze it, provide information about it, or something else?
    
    The more information you give me, the better I can assist you. 
  3. This is special, as it doesn't have the "" mark.

    🗨:
    Are you working?
    
    🦜:[Gemini-1.5-Pro-Chat - gemini]
    You got it! I'm ready and eager to assist you.  What can
  4. 🗨:
    
    What kind of glitch? Please give me some more feedback
    
    🦜:[Gemini-1.5-Flash-Chat - gemini]
    You are correct to be curious! 
    I can't really explain what kind of glitch I had in the same way a person might describe feeling tired or having a headache.  
    
    As a language model, my \ servers I run on. 

The most consistent way I found until now to try to reproduce the error is this one:

🗨:
Are you working?

🦜:[Gemini-1.5-Flash-Chat - gemini]
As a large language model, I don't \. I'm not employed or paid for my services. I'm constantly learning and evolving, but my primary function is to provide information and complete tasks as instructed. 

However, I'm always \ that I'm processing information, generating text, and responding to your requests.  

Would you like me to help you with something? 

However, I'm not sure what induces this kind of truncation.

Please let me know if this information helps you or how I can... I don't know, maybe intercept the API response before it is processed by Parrot or something like that?

- remove print statements
- add missing message preprocessing
@frankroeder
Copy link
Owner

Hey @Dioprz, the parsing issue has been resolved. Please let me know if you encounter any other bugs. I am still looking for missing pieces regarding the API parameters and general improvements.

@frankroeder
Copy link
Owner

I've transferred this to PR #29 as it necessitates a restructure of the providers, which I am currently addressing on a different branch. The API parameter integration for Gemini is complete. You're welcome to switch over to that branch. I'll have it merged into the main branch shortly.

@Dioprz
Copy link
Contributor Author

Dioprz commented Jul 10, 2024

Hey @frankroeder!

Wow, that was really quick; thanks a lot for all your work, man. The transfer is fine with me.

I have already tested your changes and everything works like a charm!

Have a great day, and thank you for your openness to the new feature.

@Dioprz Dioprz deleted the feat/add_gemini_support branch July 10, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants