Skip to content

Commit

Permalink
feedback 2
Browse files Browse the repository at this point in the history
  • Loading branch information
srtaalej committed Aug 2, 2024
1 parent d74e37d commit 3f8b047
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
5 changes: 4 additions & 1 deletion ai/ai_utils/get_available_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from ai.providers.openai import OpenAI_API

"""
New providers need to be added below
This file defines a function to retrieve available API models from different AI providers.
It imports specific AI provider classes and combines their available models into a single dictionary.
New AI providers must be added below
"""


Expand Down
6 changes: 5 additions & 1 deletion ai/ai_utils/handle_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from state_store.get_user_state import get_user_state

"""
New providers need to be added below
This file defines functions to handle AI responses by interacting with different AI providers.
The `_get_provider()` function returns an instance of the appropriate API provider based on the given API name.
The `get_ai_response` function retrieves the user's selected API provider and model, sets the model, and generates a response.
New AI providers must be added below
"""


Expand Down
2 changes: 1 addition & 1 deletion ai/providers/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_models(self):
if self.api_key is not None:
return self.MODELS
else:
return None
return {}

def generate_response(self, prompt: str, system_content: str) -> str:
try:
Expand Down
7 changes: 4 additions & 3 deletions ai/providers/base_provider.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# A base class for API providers, defining the interface and common properties for subclasses.


class BaseProvider:
MODELS = {}
BASELINE_MAX_TOKENS: int
API_NAME: str

def __init__(self):
self.current_model = None
self.api_key: str

def set_model(self, model_name: str):
self.current_model = model_name
raise NotImplementedError("Subclass must implement set_model")

def get_models(self):
Expand Down
2 changes: 1 addition & 1 deletion ai/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_models(self):
if self.api_key is not None:
return self.MODELS
else:
return None
return {}

def generate_response(self, prompt: str, system_content: str) -> str:
try:
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@
"token_rotation_enabled": false,
"function_runtime": "remote"
}
}
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ flake8==7.1.0
black==24.4.2
slack-cli-hooks==0.0.2
openai==1.37.1
anthropic==0.32.0
anthropic==0.32.0

0 comments on commit 3f8b047

Please sign in to comment.