From e57eb2a96ed6f3982d9aad976cf74a476f9928f0 Mon Sep 17 00:00:00 2001 From: Val Kharitonov Date: Tue, 28 May 2024 22:13:26 -0400 Subject: [PATCH] Remove Google Bard (#79) --- README.md | 31 ++++++++--------------------- gptcli/assistant.py | 3 --- gptcli/config.py | 2 +- gptcli/google.py | 48 --------------------------------------------- gptcli/gpt.py | 4 ---- pyproject.toml | 5 ++--- 6 files changed, 11 insertions(+), 82 deletions(-) delete mode 100644 gptcli/google.py diff --git a/README.md b/README.md index 6950275..db40671 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,18 @@ # gpt-cli -Command-line interface for ChatGPT Claude and Bard. +Command-line interface for chat LLMs. + +## Supported providers + +- OpenAI +- Anthropic +- Cohere +- Other APIs compatible with OpenAI ![screenshot](https://github.com/kharvd/gpt-cli/assets/466920/ecbcccc4-7cfa-4c04-83c3-a822b6596f01) ## Features -### **Coming soon** - Code Interpreter support https://github.com/kharvd/gpt-cli/pull/37 - - **Command-Line Interface**: Interact with ChatGPT or Claude directly from your terminal. - **Model Customization**: Override the default model, temperature, and top_p values for each assistant, giving you fine-grained control over the AI's behavior. - **Usage tracking**: Track your API usage with token count and price information. @@ -214,23 +219,3 @@ Now you should be able to run `gpt` with `--model claude-v1` or `--model claude- ```bash gpt --model claude-v1 ``` - -### Google Bard (PaLM 2) - -Similar to Claude, set the Google API key - -```bash -export GOOGLE_API_KEY= -``` - -or a config line: - -```yaml -google_api_key: -``` - -Run `gpt` with the correct model: - -```bash -gpt --model chat-bison-001 -``` diff --git a/gptcli/assistant.py b/gptcli/assistant.py index 52deb32..32ee895 100644 --- a/gptcli/assistant.py +++ b/gptcli/assistant.py @@ -11,7 +11,6 @@ ModelOverrides, Message, ) -from gptcli.google import GoogleCompletionProvider from gptcli.llama import LLaMACompletionProvider from gptcli.openai import OpenAICompletionProvider from gptcli.anthropic import AnthropicCompletionProvider @@ -77,8 +76,6 @@ def get_completion_provider(model: str) -> CompletionProvider: return AnthropicCompletionProvider() elif model.startswith("llama"): return LLaMACompletionProvider() - elif model.startswith("chat-bison"): - return GoogleCompletionProvider() elif model.startswith("command") or model.startswith("c4ai"): return CohereCompletionProvider() else: diff --git a/gptcli/config.py b/gptcli/config.py index 57f26a1..6111128 100644 --- a/gptcli/config.py +++ b/gptcli/config.py @@ -22,7 +22,7 @@ class GptCliConfig: openai_api_key: Optional[str] = os.environ.get("OPENAI_API_KEY") openai_base_url: Optional[str] = os.environ.get("OPENAI_BASE_URL") anthropic_api_key: Optional[str] = os.environ.get("ANTHROPIC_API_KEY") - google_api_key: Optional[str] = os.environ.get("GOOGLE_API_KEY") + google_api_key: Optional[str] = os.environ.get("GOOGLE_API_KEY") # deprecated cohere_api_key: Optional[str] = os.environ.get("COHERE_API_KEY") log_file: Optional[str] = None log_level: str = "INFO" diff --git a/gptcli/google.py b/gptcli/google.py deleted file mode 100644 index ca97e9b..0000000 --- a/gptcli/google.py +++ /dev/null @@ -1,48 +0,0 @@ -from typing import Iterator, List -import google.generativeai as genai -from gptcli.completion import ( - CompletionEvent, - CompletionProvider, - Message, - MessageDeltaEvent, -) - - -def role_to_author(role: str) -> str: - if role == "user": - return "0" - elif role == "assistant": - return "1" - else: - raise ValueError(f"Unknown role: {role}") - - -def make_prompt(messages: List[Message]): - system_messages = [ - message["content"] for message in messages if message["role"] == "system" - ] - context = "\n".join(system_messages) - prompt = [ - {"author": role_to_author(message["role"]), "content": message["content"]} - for message in messages - if message["role"] != "system" - ] - return context, prompt - - -class GoogleCompletionProvider(CompletionProvider): - def complete( - self, messages: List[Message], args: dict, stream: bool = False - ) -> Iterator[CompletionEvent]: - context, prompt = make_prompt(messages) - kwargs = { - "context": context, - "messages": prompt, - } - if "temperature" in args: - kwargs["temperature"] = args["temperature"] - if "top_p" in args: - kwargs["top_p"] = args["top_p"] - - response = genai.chat(**kwargs) - yield MessageDeltaEvent(response.last) diff --git a/gptcli/gpt.py b/gptcli/gpt.py index 9ee302a..06045f6 100755 --- a/gptcli/gpt.py +++ b/gptcli/gpt.py @@ -13,7 +13,6 @@ import sys import logging import datetime -import google.generativeai as genai import gptcli.anthropic import gptcli.cohere from gptcli.assistant import ( @@ -187,9 +186,6 @@ def main(): if config.anthropic_api_key: gptcli.anthropic.api_key = config.anthropic_api_key - if config.google_api_key: - genai.configure(api_key=config.google_api_key) - if config.cohere_api_key: gptcli.cohere.api_key = config.cohere_api_key diff --git a/pyproject.toml b/pyproject.toml index 2f4b2c6..d2cb1e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [project] name = "gpt-command-line" version = "0.1.7" -description = "Command-line interface for ChatGPT, Claude and Bard" +description = "Command-line interface for ChatGPT and Claude" authors = [{name = "Val Kharitonov", email = "val@kharvd.com"}] readme = "README.md" license = {file = "LICENSE"} requires-python = ">=3.9" -keywords = ["cli", "command-line", "assistant", "openai", "claude", "bard", "gpt-3", "gpt-4", "llm", "chatgpt", "gpt-cli", "google-bard", "anthropic", "gpt-client", "anthropic-claude", "palm2"] +keywords = ["cli", "command-line", "assistant", "openai", "claude", "cohere", "gpt-3", "gpt-4", "llm", "chatgpt", "gpt-cli", "anthropic", "gpt-client", "anthropic-claude"] classifiers = [ "Development Status :: 4 - Beta", "Environment :: Console", @@ -22,7 +22,6 @@ dependencies = [ "black==24.4.2", "cohere==5.5.3", "mistralai==0.1.8", - "google-generativeai==0.1.0", "openai==1.30.1", "prompt-toolkit==3.0.43", "pytest==7.3.1",