Shreyas094 commited on
Commit
5ecdc0c
1 Parent(s): 176123e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -128,7 +128,7 @@ class CitingSources(BaseModel):
128
  description="List of sources to cite. Should be an URL of the source."
129
  )
130
 
131
- def get_response_from_pdf(query):
132
  embed = get_embeddings()
133
  if os.path.exists("faiss_database"):
134
  database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)
@@ -144,7 +144,7 @@ def get_response_from_pdf(query):
144
  Write a detailed and complete response that answers the following user question: '{query}'
145
  Do not include a list of sources in your response. [/INST]"""
146
 
147
- generated_text = generate_chunked_response(prompt)
148
 
149
  # Clean the response
150
  clean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)
@@ -152,7 +152,7 @@ Do not include a list of sources in your response. [/INST]"""
152
 
153
  return clean_text
154
 
155
- def get_response_with_search(query):
156
  search_results = duckduckgo_search(query)
157
  context = "\n".join(f"{result['title']}\n{result['body']}\nSource: {result['href']}\n"
158
  for result in search_results if 'body' in result)
@@ -162,7 +162,7 @@ def get_response_with_search(query):
162
  Write a detailed and complete research document that fulfills the following user request: '{query}'
163
  After writing the document, please provide a list of sources used in your response. [/INST]"""
164
 
165
- generated_text = generate_chunked_response(prompt)
166
 
167
  # Clean the response
168
  clean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)
 
128
  description="List of sources to cite. Should be an URL of the source."
129
  )
130
 
131
+ def get_response_from_pdf(query, temperature=0.7, repetition_penalty=1.1):
132
  embed = get_embeddings()
133
  if os.path.exists("faiss_database"):
134
  database = FAISS.load_local("faiss_database", embed, allow_dangerous_deserialization=True)
 
144
  Write a detailed and complete response that answers the following user question: '{query}'
145
  Do not include a list of sources in your response. [/INST]"""
146
 
147
+ generated_text = generate_chunked_response(prompt, temperature=temperature, repetition_penalty=repetition_penalty)
148
 
149
  # Clean the response
150
  clean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)
 
152
 
153
  return clean_text
154
 
155
+ def get_response_with_search(query, temperature=0.7, repetition_penalty=1.1):
156
  search_results = duckduckgo_search(query)
157
  context = "\n".join(f"{result['title']}\n{result['body']}\nSource: {result['href']}\n"
158
  for result in search_results if 'body' in result)
 
162
  Write a detailed and complete research document that fulfills the following user request: '{query}'
163
  After writing the document, please provide a list of sources used in your response. [/INST]"""
164
 
165
+ generated_text = generate_chunked_response(prompt, temperature=temperature, repetition_penalty=repetition_penalty)
166
 
167
  # Clean the response
168
  clean_text = re.sub(r'<s>\[INST\].*?\[/INST\]\s*', '', generated_text, flags=re.DOTALL)