Skip to content

Commit

Permalink
some bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kav-K committed Nov 7, 2023
1 parent 516a410 commit 3586b82
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
4 changes: 3 additions & 1 deletion cogs/code_interpreter_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion cogs/search_service_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion conversation_starter_pretext.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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|>
<yourname>: 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.
2 changes: 1 addition & 1 deletion gpt3discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from models.openai_model import Model


__version__ = "12.1.0"
__version__ = "12.1.1"


PID_FILE = Path("bot.pid")
Expand Down
5 changes: 4 additions & 1 deletion models/index_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions models/openai_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down Expand Up @@ -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..
Expand Down
4 changes: 2 additions & 2 deletions services/text_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3586b82

Please sign in to comment.