Skip to content

Commit

Permalink
fix: use a better model
Browse files Browse the repository at this point in the history
  • Loading branch information
NagariaHussain committed May 4, 2023
1 parent 7b35b60 commit 515591e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doppio_bot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from langchain.chains import ConversationChain
from langchain.prompts import PromptTemplate

OPENAI_MODEL_NAME = "gpt-3.5-turbo"

# Note: Copied the default template and added extra instructions for code output
prompt_template = PromptTemplate(
input_variables=["history", "input"],
Expand Down Expand Up @@ -35,12 +37,13 @@ def get_chatbot_response(session_id: str, prompt_message: str) -> str:
if not opeai_api_key:
frappe.throw("Please set `openai_api_key` in site config")

llm = OpenAI(temperature=0, openai_api_key=opeai_api_key)
llm = OpenAI(model_name=OPENAI_MODEL_NAME, temperature=0, openai_api_key=opeai_api_key)
message_history = RedisChatMessageHistory(
session_id=session_id,
url=frappe.conf.get("redis_cache") or "redis://localhost:6379/0",
)
memory = ConversationBufferMemory(memory_key="history", chat_memory=message_history)
conversation_chain = ConversationChain(llm=llm, memory=memory, prompt=prompt_template)

return conversation_chain.run(prompt_message)
response = conversation_chain.run(prompt_message)
return response

0 comments on commit 515591e

Please sign in to comment.