diff --git a/backend/llm.py b/backend/llm.py index dba5720..a0f49e4 100644 --- a/backend/llm.py +++ b/backend/llm.py @@ -8,6 +8,7 @@ from utils import pprint_prompt # Actual model versions that are passed to the LLMs and stored in our logs +# Keep in sync with s2c-saas repo & DB column `llm_version` class Llm(Enum): GPT_4_VISION = "gpt-4-vision-preview" CLAUDE_3_SONNET = "claude-3-sonnet-20240229" diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py index 092b8d1..feb4664 100644 --- a/backend/routes/generate_code.py +++ b/backend/routes/generate_code.py @@ -343,10 +343,12 @@ async def stream_code(websocket: WebSocket): if IS_PROD: # Catch any errors from sending to SaaS backend and continue try: + assert exact_llm_version is not None, "exact_llm_version is not set" await send_to_saas_backend( prompt_messages, completion, payment_method=payment_method, + llm_version=exact_llm_version, auth_token=params["authToken"], ) except Exception as e: diff --git a/backend/routes/logging_utils.py b/backend/routes/logging_utils.py index 80e0f25..bf2cdad 100644 --- a/backend/routes/logging_utils.py +++ b/backend/routes/logging_utils.py @@ -5,6 +5,7 @@ from typing import List import json from config import BACKEND_SAAS_URL, IS_PROD +from llm import Llm class PaymentMethod(Enum): @@ -19,6 +20,7 @@ async def send_to_saas_backend( prompt_messages: List[ChatCompletionMessageParam], completion: str, payment_method: PaymentMethod, + llm_version: Llm, auth_token: str | None = None, ): if IS_PROD: @@ -30,6 +32,7 @@ async def send_to_saas_backend( "prompt": json.dumps(prompt_messages), "completion": completion, "payment_method": payment_method.value, + "llm_version": llm_version.value, } )