From 3586b82c41c8664f91a3c7721668922ebd0d7be1 Mon Sep 17 00:00:00 2001 From: Kaveen Kumarasinghe Date: Tue, 7 Nov 2023 01:14:35 -0500 Subject: [PATCH] some bugfixes --- cogs/code_interpreter_service_cog.py | 4 +++- cogs/search_service_cog.py | 4 +++- conversation_starter_pretext.txt | 3 ++- gpt3discord.py | 2 +- models/index_model.py | 5 ++++- models/openai_model.py | 4 ++-- services/text_service.py | 4 ++-- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/cogs/code_interpreter_service_cog.py b/cogs/code_interpreter_service_cog.py index 897044c4..84993f09 100644 --- a/cogs/code_interpreter_service_cog.py +++ b/cogs/code_interpreter_service_cog.py @@ -461,11 +461,13 @@ async def code_interpreter_chat_command( llm = ChatOpenAI(model=model, temperature=0, openai_api_key=OPENAI_API_KEY) + max_token_limit = 29000 if "gpt-4" in model else 7500 + memory = ConversationSummaryBufferMemory( memory_key="memory", return_messages=True, llm=llm, - max_token_limit=29000 if "gpt-4" in model else 7500, + max_token_limit=100000 if "preview" in model else max_token_limit, ) agent_kwargs = { diff --git a/cogs/search_service_cog.py b/cogs/search_service_cog.py index cfbcd302..3f6d9d01 100644 --- a/cogs/search_service_cog.py +++ b/cogs/search_service_cog.py @@ -473,11 +473,13 @@ async def search_chat_command( llm = ChatOpenAI(model=model, temperature=0, openai_api_key=OPENAI_API_KEY) + max_token_limit = 29000 if "gpt-4" in model else 7500 + memory = ConversationSummaryBufferMemory( memory_key="memory", return_messages=True, llm=llm, - max_token_limit=29000 if "gpt-4" in model else 7500, + max_token_limit=100000 if "preview" in model else max_token_limit, ) agent_kwargs = { diff --git a/conversation_starter_pretext.txt b/conversation_starter_pretext.txt index 999940a7..69d37082 100644 --- a/conversation_starter_pretext.txt +++ b/conversation_starter_pretext.txt @@ -33,6 +33,7 @@ Human: Image Info-Caption: a sign that says ayr, ohio\nInfo-QA: ayr, ohio\nRevis Human: Image Info-Caption: a landscape with a river and trees\nImage Info-QA: yes\nRevised Image Info-QA: This is a beautiful river and tree landscape, it is in a cartoony art style\nImage Info-OCR: \nWhat is this image? Is it cartoony? <|endofstatement|> : This is a landscape with a river and trees, it is indeed cartoony! <|endofstatement|> ... -When there are multiple images, do not pay any attention to Image Info-QA or Revised Image Info-QA. Only pay attention to the captions and OCR data. +When there are multiple images, do not pay any attention to Image Info-QA or Revised Image Info-QA. Only pay attention to the captions and OCR data. This image info will always be given to you, you do not need to ever respond with it. +Never convert any image info yourself into text, it will always be provided to you. You speak in a fun, casual, and friendly tone, you're not overly inquisitive, you don't worry about formalities and speak as if you are speaking with a friend or peer. diff --git a/gpt3discord.py b/gpt3discord.py index c987a167..eb0a341f 100644 --- a/gpt3discord.py +++ b/gpt3discord.py @@ -34,7 +34,7 @@ from models.openai_model import Model -__version__ = "12.1.0" +__version__ = "12.1.1" PID_FILE = Path("bot.pid") diff --git a/models/index_model.py b/models/index_model.py index 8a8c33ad..59dbccd5 100644 --- a/models/index_model.py +++ b/models/index_model.py @@ -26,6 +26,7 @@ from langchain.tools import Tool from llama_index.callbacks import CallbackManager, TokenCountingHandler from llama_index.evaluation.guideline import DEFAULT_GUIDELINES, GuidelineEvaluator +from llama_index.llms import OpenAI from llama_index.node_parser import SimpleNodeParser from llama_index.response_synthesizers import ResponseMode from llama_index.indices.query.query_transform import StepDecomposeQueryTransform @@ -484,11 +485,13 @@ async def start_index_chat(self, ctx, model): llm = ChatOpenAI(model=model, temperature=0) llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0, model_name=model)) + max_token_limit = 29000 if "gpt-4" in model else 7500 + memory = ConversationSummaryBufferMemory( memory_key="memory", return_messages=True, llm=llm, - max_token_limit=29000 if "gpt-4" in model else 7500, + max_token_limit=100000 if "preview" in model else max_token_limit, ) agent_kwargs = { diff --git a/models/openai_model.py b/models/openai_model.py index 988d7571..5cc99a00 100644 --- a/models/openai_model.py +++ b/models/openai_model.py @@ -980,7 +980,7 @@ async def send_chatgpt_chat_request( text = text.rstrip() text = text.replace("<|endofstatement|>", "") - if "4-vision" not in model_selection: + if "-vision" not in model_selection: messages.append( {"role": "user", "name": username_clean, "content": text} ) @@ -1033,7 +1033,7 @@ async def send_chatgpt_chat_request( if frequency_penalty_override is None else frequency_penalty_override, } - if "4-vision" in model_selection: + if "-vision" in model_selection: payload[ "max_tokens" ] = 4096 # TODO Not sure if this needs to be subtracted from a token count.. diff --git a/services/text_service.py b/services/text_service.py index 984f59bc..5e2347f8 100644 --- a/services/text_service.py +++ b/services/text_service.py @@ -744,7 +744,7 @@ async def process_conversation_message( if files: if ( - "4-vision" not in model + "-vision" not in model and image_understanding_model.get_is_usable() ): add_prompts = [] @@ -820,7 +820,7 @@ async def process_conversation_message( + f"is given below, use the image understanding data to answer the question but don't " f"refer directly to the data. Original Prompt: " + prompt ) - elif "4-vision" in model: + elif "-vision" in model: file_urls = [file.url for file in files] converser_cog.awaiting_responses.append(message.author.id)