Skip to content

Commit

Permalink
feat!: remove support for gemini
Browse files Browse the repository at this point in the history
Remove the Google provider because the generative-ai-python dependency blocks us from supporting Python 3.13.

We can add it back again when google-gemini/generative-ai-python#518 is resolved.

BREAKING CHANGE: Support for Gemini has been temporarily suspended. If you are using the Google provider, do not install this version and stick to the v0.18.0 tag.
  • Loading branch information
Realiserad committed Dec 30, 2024
1 parent 55c8cf5 commit f8e65a2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 57 deletions.
1 change: 0 additions & 1 deletion .devcontainer/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pyfakefs
mutatest

openai
google-generativeai
simple-term-menu
iterfzf
hugchat
Expand Down
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,6 @@ model = <your deployment name>
api_key = <your API key>
```

If you use [Gemini](https://ai.google.dev):

```ini
[fish-ai]
configuration = gemini

[gemini]
provider = google
api_key = <your API key>
```

If you use [Hugging Face](https://huggingface.co):

```ini
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "fish_ai"
version = "0.18.0"
version = "1.0.0"
authors = [{ name = "Bastian Fredriksson", email = "realiserad@gmail.com" }]
description = "Provides core functionality for fish-ai, an AI plugin for the fish shell."
readme = "README.md"
Expand All @@ -16,7 +16,6 @@ classifiers = [
]
dependencies = [
"openai==1.58.1",
"google-generativeai==0.8.3",
"simple-term-menu==1.6.6",
"iterfzf==1.4.0.54.3",
"hugchat==0.4.17",
Expand Down
44 changes: 1 addition & 43 deletions src/fish_ai/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from openai import OpenAI
from openai import AzureOpenAI
import google.generativeai as genai
from google.generativeai.types import GenerationConfig
from os.path import isfile
import platform
import logging
Expand Down Expand Up @@ -175,34 +173,6 @@ def get_openai_client():
.format(get_config('provider')))


def get_messages_for_gemini(messages):
"""
Create message history which can be used with Gemini.
Google uses a different chat history format than OpenAI.
The message content should be put in a parts array and
system messages are not supported.
"""
outputs = []
system_messages = []
for message in messages:
if message.get('role') == 'system':
system_messages.append(message.get('content'))
for i in range(len(messages) - 1):
message = messages[i]
if message.get('role') == 'user':
outputs.append({
'role': 'user',
'parts': system_messages + [message.get('content')] if i == 0
else [message.get('content')]
})
elif message.get('role') == 'assistant':
outputs.append({
'role': 'model',
'parts': [message.get('content')]
})
return outputs


def get_messages_for_anthropic(messages):
user_messages = []
system_messages = []
Expand Down Expand Up @@ -234,19 +204,7 @@ def get_response(messages):

start_time = time_ns()

if get_config('provider') == 'google':
genai.configure(api_key=get_config('api_key'))
model = genai.GenerativeModel(
get_config('model') or 'gemini-1.5-flash')
chat = model.start_chat(history=get_messages_for_gemini(messages))
generation_config = GenerationConfig(
candidate_count=1,
temperature=float(get_config('temperature') or '0.2'))
response = (chat.send_message(generation_config=generation_config,
content=messages[-1].get('content'),
stream=False)
.text)
elif get_config('provider') == 'huggingface':
if get_config('provider') == 'huggingface':
email = get_config('email')
password = get_config('password')
cookies = Login(email, password).login(
Expand Down

0 comments on commit f8e65a2

Please sign in to comment.