Models configured via env variables

This commit is contained in:
Daniel O'Connell
2023-09-29 14:48:09 +02:00
parent afacc9e3f5
commit 0bef69b140
3 changed files with 14 additions and 20 deletions
+9 -15
View File
@@ -1,12 +1,14 @@
# ------------------------------- env, constants -------------------------------
from dataclasses import asdict
from typing import List, Dict, Callable
import openai
import re
from sqlalchemy.orm import PropComparator
import tiktoken
import time
import json
import re
import time
from dataclasses import asdict
from typing import List, Dict
import openai
import tiktoken
from stampy_chat.env import COMPLETIONS_MODEL
from stampy_chat.followups import multisearch_authored
from stampy_chat.get_blocks import get_top_k_blocks, Block
from stampy_chat import logging
@@ -15,11 +17,6 @@ from stampy_chat import logging
logger = logging.getLogger(__name__)
# OpenAI models
EMBEDDING_MODEL = "text-embedding-ada-002"
COMPLETIONS_MODEL = "gpt-3.5-turbo"
# COMPLETIONS_MODEL = "gpt-4"
STANDARD_K = 20 if COMPLETIONS_MODEL == 'gpt-4' else 10
# parameters
@@ -139,9 +136,6 @@ def construct_prompt(query: str, mode: str, history: Prompt, context: List[Block
return prompt
# ------------------------------- completion code -------------------------------
import time
import json
def check_openai_moderation(prompt: Prompt, query: str):
prompt_string = '\n\n'.join([message["content"] for message in prompt])
+4
View File
@@ -18,6 +18,10 @@ DISCORD_LOGGING_URL = os.environ.get('LOGGING_URL')
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
openai.api_key = OPENAI_API_KEY # non-optional
### Models ###
EMBEDDING_MODEL = os.environ.get("EMBEDDING_MODEL", "text-embedding-ada-002")
COMPLETIONS_MODEL = os.environ.get("COMPLETIONS_MODEL", "gpt-3.5-turbo")
### Pinecone ###
PINECONE_API_KEY = os.environ.get('PINECONE_API_KEY')
PINECONE_ENVIRONMENT = os.environ.get('PINECONE_ENVIRONMENT', "us-east1-gcp")
+1 -5
View File
@@ -7,16 +7,12 @@ import regex as re
import requests
import time
from typing import List, Tuple
from stampy_chat.env import PINECONE_NAMESPACE, REMOTE_CHAT_INSTANCE
from stampy_chat.env import PINECONE_NAMESPACE, REMOTE_CHAT_INSTANCE, EMBEDDING_MODEL
from stampy_chat import logging
logger = logging.getLogger(__name__)
# ---------------------------------- constants ---------------------------------
EMBEDDING_MODEL = "text-embedding-ada-002"
# ------------------------------------ types -----------------------------------
@dataclasses.dataclass