Skip to content

Commit

Permalink
Change to use GPT-4o-mini
Browse files Browse the repository at this point in the history
  • Loading branch information
sorendaugaard committed Sep 11, 2024
1 parent aeed11b commit f9afbec
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
7 changes: 5 additions & 2 deletions chat/services/streaming_question_answering_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from langchain.schema.messages import AIMessage, HumanMessage

from chat.retrievers.rules_bot_retriever import RulesBotRetriever
from rulesbot.settings import DEFAULT_CHATGPT_MODEL

prompt_template = """Please use the following information to provide a clear and accurate answer to this question regarding the rules of the game %%GAME%%.
Explain your answer in detail using the rulebook information provided.
Expand Down Expand Up @@ -98,8 +99,10 @@ def _setup_conversational_retrieval_chain(chat_session, response_queue):
callback_handler = QueueCallbackHandler(response_queue)

return ConversationalRetrievalChain.from_llm(
llm=ChatOpenAI(streaming=True, callbacks=[callback_handler]),
condense_question_llm=ChatOpenAI(temperature=0.1),
llm=ChatOpenAI(
streaming=True, callbacks=[callback_handler], model=DEFAULT_CHATGPT_MODEL
),
condense_question_llm=ChatOpenAI(temperature=0.1, model=DEFAULT_CHATGPT_MODEL),
condense_question_prompt=condense_question_prompt,
retriever=RulesBotRetriever(
index=chat_session.game.vector_store.index, search_kwargs={"k": 3}
Expand Down
6 changes: 4 additions & 2 deletions games/loaders/pdf_loader_and_summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from langchain.schema import Document
from langchain.text_splitter import RecursiveCharacterTextSplitter

from rulesbot.settings import DEFAULT_CHATGPT_MODEL


def load_and_split(filename, document):
"""
Expand Down Expand Up @@ -73,7 +75,7 @@ def _summarize_setup_instructions(setup_page_content):
"""
Use ChatGPT to summarize the setup instructions.
"""
llm = ChatOpenAI(temperature=0.1)
llm = ChatOpenAI(temperature=0.1, model=DEFAULT_CHATGPT_MODEL)
prompt = f"Provided are setup instructions for a board game. Please clean them up and summarize them into an easy-to-read format. \n\n{setup_page_content}\n\nSummary:"
return llm.predict(prompt)

Expand All @@ -83,7 +85,7 @@ def _clean_up_page(page_content):
Use ChatGPT to clean up the content.
"""
print("Cleaning up page ... ")
llm = ChatOpenAI(temperature=0.1)
llm = ChatOpenAI(temperature=0.1, model=DEFAULT_CHATGPT_MODEL)
prompt = f"Please clean up the following page of rules to make it easier to read. \n\n{page_content}\n\nCleaned up rules:"
print(f"Input: {page_content}")
cleaned_up_page_content = llm.predict(prompt)
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions rulesbot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,9 @@
# Set login redirect
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"


# CUSTOM APP SETTINGS

# ChatGPT settings
DEFAULT_CHATGPT_MODEL = "gpt-4o-mini"

0 comments on commit f9afbec

Please sign in to comment.