Skip to content

Commit

Permalink
nit: move method
Browse files Browse the repository at this point in the history
  • Loading branch information
njbbaer committed Aug 15, 2024
1 parent a93dcd7 commit 5438d2d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ def __init__(self):
self.api_key = os.environ.get(self.ENV_KEY)
self.logger = Logger("log.yml")

@staticmethod
def create(client_type):
clients = {"openrouter": OpenRouterAPIClient, "anthropic": AnthropicAPIClient}
if client_type not in clients:
raise ValueError(f"Unsupported client type: {client_type}")
return clients[client_type]()

async def request_completion(self, messages, parameters, pricing):
body = self.prepare_body(messages, parameters)
async with httpx.AsyncClient(timeout=self.TIMEOUT) as client:
Expand All @@ -37,13 +44,6 @@ def prepare_body(self, messages, parameters):
def create_completion(self, response, pricing):
pass

@staticmethod
def create(client_type):
clients = {"openrouter": OpenRouterAPIClient, "anthropic": AnthropicAPIClient}
if client_type not in clients:
raise ValueError(f"Unsupported client type: {client_type}")
return clients[client_type]()


class OpenRouterAPIClient(APIClient):
API_URL = "https://openrouter.ai/api/v1/chat/completions"
Expand Down

0 comments on commit 5438d2d

Please sign in to comment.