Co-authored-by: k-boikov <64261260+k-boikov@users.noreply.github.com>
This commit is contained in:
Konrad
2023-05-20 19:45:27 -04:00
committed by GitHub
parent c30f5b7d5e
commit 57ea7b5216
7 changed files with 122 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ from __future__ import annotations
import functools
import time
from itertools import islice
from typing import List, Optional
from typing import List, Literal, Optional
import numpy as np
import openai
@@ -293,3 +293,22 @@ def create_embedding(
) # normalize the length to one
chunk_embeddings = chunk_embeddings.tolist()
return chunk_embeddings
def check_model(
model_name: str, model_type: Literal["smart_llm_model", "fast_llm_model"]
) -> str:
"""Check if model is available for use. If not, return gpt-3.5-turbo."""
api_manager = ApiManager()
models = api_manager.get_models()
if any(model_name in m["id"] for m in models):
return model_name
logger.typewriter_log(
"WARNING: ",
Fore.YELLOW,
f"You do not have access to {model_name}. Setting {model_type} to "
f"gpt-3.5-turbo.",
)
return "gpt-3.5-turbo"