JustusI commited on
Commit
0537952
·
verified ·
1 Parent(s): 76c904e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -30,7 +30,8 @@ def load_vector_db(zip_file_path, extract_path):
30
 
31
  # Function to augment prompt
32
  def augment_prompt(query, vectordb):
33
- results = vectordb.similarity_search(query, k=10)
 
34
  source_knowledge = "\n".join([x.page_content for x in results])
35
  augmented_prompt = f"""
36
  You are an AI assistant. Use the context provided below to answer the question as comprehensively as possible.
@@ -46,7 +47,7 @@ def augment_prompt(query, vectordb):
46
 
47
  # Function to handle chat with OpenAI
48
  def chat_with_openai(query, vectordb, openai_api_key):
49
- chat = ChatOpenAI(model_name="gpt-3.5-turbo", openai_api_key=openai_api_key)
50
  augmented_query = augment_prompt(query, vectordb)
51
  prompt = HumanMessage(content=augmented_query)
52
  messages = [
@@ -201,4 +202,4 @@ if prompt := st.chat_input("Enter your query"):
201
  # if isinstance(message, HumanMessage):
202
  # st.write(f"You: {message.content}")
203
  # else:
204
- # st.write(f"AI: {message.content}")------
 
30
 
31
  # Function to augment prompt
32
  def augment_prompt(query, vectordb):
33
+ # Max Marginal Relevance for better diversity in info retrieval
34
+ results = vectordb.max_marginal_relevance_search(query, k=10, fetch_k=50)
35
  source_knowledge = "\n".join([x.page_content for x in results])
36
  augmented_prompt = f"""
37
  You are an AI assistant. Use the context provided below to answer the question as comprehensively as possible.
 
47
 
48
  # Function to handle chat with OpenAI
49
  def chat_with_openai(query, vectordb, openai_api_key):
50
+ chat = ChatOpenAI(model_name="gpt-5-mini", openai_api_key=openai_api_key, temperature=0.1)
51
  augmented_query = augment_prompt(query, vectordb)
52
  prompt = HumanMessage(content=augmented_query)
53
  messages = [
 
202
  # if isinstance(message, HumanMessage):
203
  # st.write(f"You: {message.content}")
204
  # else:
205
+ # st.write(f"AI: {message.content}")