From 5438d2d583cf545d8507b15fa6da37bfa62e11fa Mon Sep 17 00:00:00 2001 From: Nate Baer Date: Wed, 14 Aug 2024 22:59:10 -0700 Subject: [PATCH] nit: move method --- src/api_client.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api_client.py b/src/api_client.py index a20e9b1..78aa869 100644 --- a/src/api_client.py +++ b/src/api_client.py @@ -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: @@ -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"