Spaces:
Sleeping
Sleeping
Update chatbot temp and top k hyperparameters
Browse files
app.py
CHANGED
|
@@ -20,20 +20,14 @@ vectordb = Chroma(persist_directory=persist_directory, embedding_function=embedd
|
|
| 20 |
|
| 21 |
llm_name = "gpt-3.5-turbo"
|
| 22 |
|
| 23 |
-
llm = ChatOpenAI(model_name=llm_name, temperature=0,
|
| 24 |
openai_api_key=openai_api_key)
|
| 25 |
|
| 26 |
qa_chain = RetrievalQA.from_chain_type(
|
| 27 |
llm,
|
| 28 |
-
retriever=vectordb.as_retriever()
|
| 29 |
)
|
| 30 |
|
| 31 |
-
question = "production is broken how do I fix it?"
|
| 32 |
-
|
| 33 |
-
result = qa_chain({"query": question})
|
| 34 |
-
|
| 35 |
-
print(result['result'])
|
| 36 |
-
|
| 37 |
|
| 38 |
# Streamed response emulator
|
| 39 |
def response_generator(prompt):
|
|
@@ -44,7 +38,7 @@ def response_generator(prompt):
|
|
| 44 |
time.sleep(0.05)
|
| 45 |
|
| 46 |
|
| 47 |
-
st.title("
|
| 48 |
|
| 49 |
# Initialize chat history
|
| 50 |
if "messages" not in st.session_state:
|
|
@@ -56,7 +50,7 @@ for message in st.session_state.messages:
|
|
| 56 |
st.markdown(message["content"])
|
| 57 |
|
| 58 |
# Accept user input
|
| 59 |
-
if prompt := st.chat_input("
|
| 60 |
# Add user message to chat history
|
| 61 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 62 |
# Display user message in chat message container
|
|
|
|
| 20 |
|
| 21 |
llm_name = "gpt-3.5-turbo"
|
| 22 |
|
| 23 |
+
llm = ChatOpenAI(model_name=llm_name, temperature=0.7,
|
| 24 |
openai_api_key=openai_api_key)
|
| 25 |
|
| 26 |
qa_chain = RetrievalQA.from_chain_type(
|
| 27 |
llm,
|
| 28 |
+
retriever=vectordb.as_retriever(search_kwargs={"k": best_k})
|
| 29 |
)
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# Streamed response emulator
|
| 33 |
def response_generator(prompt):
|
|
|
|
| 38 |
time.sleep(0.05)
|
| 39 |
|
| 40 |
|
| 41 |
+
st.title("Technical Support Chatbot")
|
| 42 |
|
| 43 |
# Initialize chat history
|
| 44 |
if "messages" not in st.session_state:
|
|
|
|
| 50 |
st.markdown(message["content"])
|
| 51 |
|
| 52 |
# Accept user input
|
| 53 |
+
if prompt := st.chat_input("Enter your question here"):
|
| 54 |
# Add user message to chat history
|
| 55 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 56 |
# Display user message in chat message container
|