refactors
This commit is contained in:
parent
64926408b0
commit
24a123db36
@ -14,7 +14,7 @@ from llm import (
|
||||
stream_openai_response,
|
||||
)
|
||||
from openai.types.chat import ChatCompletionMessageParam
|
||||
from logging.core import write_logs
|
||||
from fs_logging.core import write_logs
|
||||
from mock_llm import mock_completion
|
||||
from typing import Any, Callable, Coroutine, Dict, List, Literal, Union, cast, get_args
|
||||
from image_generation import create_alt_url_mapping, generate_images
|
||||
@ -30,6 +30,21 @@ from ws.constants import APP_ERROR_WEB_SOCKET_CODE # type: ignore
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
# Auto-upgrade usage of older models
|
||||
def auto_upgrade_model(code_generation_model: Llm) -> Llm:
|
||||
if code_generation_model in {Llm.GPT_4_VISION, Llm.GPT_4_TURBO_2024_04_09}:
|
||||
print(
|
||||
f"Initial deprecated model: {code_generation_model}. Auto-updating code generation model to GPT-4O-2024-05-13"
|
||||
)
|
||||
return Llm.GPT_4O_2024_05_13
|
||||
elif code_generation_model == Llm.CLAUDE_3_SONNET:
|
||||
print(
|
||||
f"Initial deprecated model: {code_generation_model}. Auto-updating code generation model to CLAUDE-3.5-SONNET-2024-06-20"
|
||||
)
|
||||
return Llm.CLAUDE_3_5_SONNET_2024_06_20
|
||||
return code_generation_model
|
||||
|
||||
|
||||
# Generate images and return updated completions
|
||||
async def process_completion(
|
||||
completion: str,
|
||||
@ -121,16 +136,7 @@ async def stream_code(websocket: WebSocket):
|
||||
raise Exception(f"Invalid model: {code_generation_model_str}")
|
||||
|
||||
# Auto-upgrade usage of older models
|
||||
if code_generation_model in {Llm.GPT_4_VISION, Llm.GPT_4_TURBO_2024_04_09}:
|
||||
print(
|
||||
f"Initial deprecated model: {code_generation_model}. Auto-updating code generation model to GPT-4O-2024-05-13"
|
||||
)
|
||||
code_generation_model = Llm.GPT_4O_2024_05_13
|
||||
elif code_generation_model == Llm.CLAUDE_3_SONNET:
|
||||
print(
|
||||
f"Initial deprecated model: {code_generation_model}. Auto-updating code generation model to CLAUDE-3.5-SONNET-2024-06-20"
|
||||
)
|
||||
code_generation_model = Llm.CLAUDE_3_5_SONNET_2024_06_20
|
||||
code_generation_model = auto_upgrade_model(code_generation_model)
|
||||
|
||||
print(
|
||||
f"Generating {generated_code_config} code for uploaded {input_mode} using {code_generation_model} model..."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user