add gpt 4 toggle

This commit is contained in:
Fraser
2023-04-01 01:20:59 -04:00
parent 74fa2b7b1a
commit d49e18d4d0
2 changed files with 8 additions and 1 deletions
+2
View File
@@ -140,3 +140,5 @@ api/dataset.pkl
temp/
api/dataset_big.pkl
api/dataset_300.pkl
+6 -1
View File
@@ -10,12 +10,13 @@ import tiktoken
# OpenAI models
EMBEDDING_MODEL = "text-embedding-ada-002"
COMPLETIONS_MODEL = "gpt-3.5-turbo"
# COMPLETIONS_MODEL = "gpt-4"
MODERATION_ENDPOINT = "https://api.openai.com/v1/moderations"
# OpenAI parameters
LEN_EMBEDDINGS = 1536
MAX_TOKEN_LEN_PROMPT = 8191 if COMPLETIONS_MODEL == 'gpt-4' else 4095
TRUNCATE_CONTEXT_LEN = 1500
TRUNCATE_CONTEXT_LEN = 2300 if COMPLETIONS_MODEL == 'gpt-4' else 1500
TRUNCATE_HISTORY_LEN = 500
MAX_RESPONSE_LEN = 900
@@ -111,6 +112,10 @@ def talk_to_robot(dataset_dict, query: str, history: List[Dict[str, str]] = [],
# 2. Generate a prompt for the ChatCompletions API
prompt, max_tokens_completion = construct_prompt(query, history, top_k_blocks)
print(" ------------------------------ prompt: -----------------------------")
for message in prompt:
print(f"{message['role']}: {message['content']}\n\n")
# if we were to error out, return something like this
# return (False, "Example error message", None)