nadaaaita commited on
Commit
5d0e1a5
·
1 Parent(s): a0d6c77

small tweaks

Browse files
Files changed (4) hide show
  1. app.py +22 -22
  2. src/generic_bot.py +2 -2
  3. src/passage_finder.py +2 -2
  4. src/srf_bot.py +2 -2
app.py CHANGED
@@ -22,8 +22,8 @@ def respond_passage_finder(message):
22
  output = []
23
  for doc in documents:
24
  quotes = doc.metadata.get('matched_quotes', [])
25
- publication = doc.metadata.get('publication_name', 'Unknown Publication')
26
- chapter = doc.metadata.get('chapter_name', 'Unknown Chapter')
27
  full_passage = doc.metadata.get('highlighted_content', '')
28
 
29
  quote_text = "\n".join([f"• \"{q.quote}\"" for q in quotes])
@@ -62,7 +62,7 @@ def respond_chatbot(query, history):
62
  passages = ''
63
  if documents and len(documents) > 0:
64
  for d in documents:
65
- passages += f'<b>{d.metadata["publication_name"]} - {d.metadata["chapter_name"]}</b>\n{d.page_content}\n\n'
66
  history.append((f'Passages: {query}', passages))
67
  response = result["messages"][-1].content
68
  system_message_dropdown = state.get("system_message_dropdown")
@@ -80,7 +80,7 @@ def respond_genericchatbot(query, history):
80
  passages = ''
81
  if documents and len(documents) > 0:
82
  for d in documents:
83
- passages += f'<b>{d.metadata["publication_name"]} - {d.metadata["chapter_name"]}</b>\n{d.page_content}\n\n'
84
  history.append((f'Passages: {query}', passages))
85
  response = result["messages"][-1].content
86
  history.append((query, response))
@@ -136,9 +136,9 @@ with gr.Blocks(css=css) as demo:
136
 
137
  output_area_pf = gr.HTML()
138
 
139
- gr.Markdown("### Sources")
140
- gr.Textbox(value="Journey to Self Realization, Second Coming of Christ, and Autobiography of a Yogi",
141
- label="Available Sources", interactive=False)
142
 
143
  submit_btn_pf.click(process_input_passage_finder, inputs=input_text_pf, outputs=output_area_pf)
144
 
@@ -156,7 +156,7 @@ with gr.Blocks(css=css) as demo:
156
  with gr.Row():
157
  with gr.Column(scale=4):
158
  chatbot_output = gr.Chatbot(height=600)
159
- user_input_cb = gr.Textbox(placeholder="Type your question here...", label="Your Question", value="What is the meaning of life?")
160
  submit_button_cb = gr.Button("Submit")
161
 
162
  with gr.Column(scale=1):
@@ -180,16 +180,16 @@ with gr.Blocks(css=css) as demo:
180
  )
181
 
182
 
183
- gr.Markdown("""
184
- <div class="source-box">
185
- <strong>Available sources:</strong>
186
- <ul>
187
- <li>Journey to Self-Realization</li>
188
- <li>The Second Coming of Christ</li>
189
- <li>Autobiography of a Yogi</li>
190
- </ul>
191
- </div>
192
- """)
193
 
194
  # system_prompt_dropdown.change(
195
  # fn=lambda x: (sp.chatbot_descriptions[x], sp.system_prompt_templates[x]),
@@ -228,7 +228,7 @@ with gr.Blocks(css=css) as demo:
228
  with gr.Row():
229
  with gr.Column(scale=4):
230
  generic_chatbot_output = gr.Chatbot(height=600)
231
- user_input_gc = gr.Textbox(placeholder="Type your question here...", label="Your Question", value="Loaves and fishes")
232
  submit_button_gc = gr.Button("Submit")
233
 
234
  # ... (existing code for the column with markdown)
@@ -245,9 +245,9 @@ with gr.Blocks(css=css) as demo:
245
 
246
  gr.Examples(
247
  examples=[
248
- "Tell me about Paramahansa Yogananda's life",
249
- "What are the main teachings of Self-Realization Fellowship?",
250
- "Explain the concept of Kriya Yoga",
251
  "Can you provide quotes about the importance of meditation?",
252
  ],
253
  inputs=user_input_gc,
 
22
  output = []
23
  for doc in documents:
24
  quotes = doc.metadata.get('matched_quotes', [])
25
+ publication = doc.metadata.get('book_name', 'Unknown Publication')
26
+ chapter = doc.metadata.get('full_title', 'Unknown Chapter')
27
  full_passage = doc.metadata.get('highlighted_content', '')
28
 
29
  quote_text = "\n".join([f"• \"{q.quote}\"" for q in quotes])
 
62
  passages = ''
63
  if documents and len(documents) > 0:
64
  for d in documents:
65
+ passages += f'<b>{d.metadata["book_name"]} - {d.metadata["full_title"]}</b>\n{d.page_content}\n\n'
66
  history.append((f'Passages: {query}', passages))
67
  response = result["messages"][-1].content
68
  system_message_dropdown = state.get("system_message_dropdown")
 
80
  passages = ''
81
  if documents and len(documents) > 0:
82
  for d in documents:
83
+ passages += f'<b>{d.metadata["book_name"]} - {d.metadata["full_title"]}</b>\n{d.page_content}\n\n'
84
  history.append((f'Passages: {query}', passages))
85
  response = result["messages"][-1].content
86
  history.append((query, response))
 
136
 
137
  output_area_pf = gr.HTML()
138
 
139
+ # gr.Markdown("### Sources")
140
+ # gr.Textbox(value="Journey to Self Realization, Second Coming of Christ, and Autobiography of a Yogi",
141
+ # label="Available Sources", interactive=False)
142
 
143
  submit_btn_pf.click(process_input_passage_finder, inputs=input_text_pf, outputs=output_area_pf)
144
 
 
156
  with gr.Row():
157
  with gr.Column(scale=4):
158
  chatbot_output = gr.Chatbot(height=600)
159
+ user_input_cb = gr.Textbox(placeholder="Type your question here...", label="Your Question")
160
  submit_button_cb = gr.Button("Submit")
161
 
162
  with gr.Column(scale=1):
 
180
  )
181
 
182
 
183
+ # gr.Markdown("""
184
+ # <div class="source-box">
185
+ # <strong>Available sources:</strong>
186
+ # <ul>
187
+ # <li>Journey to Self-Realization</li>
188
+ # <li>The Second Coming of Christ</li>
189
+ # <li>Autobiography of a Yogi</li>
190
+ # </ul>
191
+ # </div>
192
+ # """)
193
 
194
  # system_prompt_dropdown.change(
195
  # fn=lambda x: (sp.chatbot_descriptions[x], sp.system_prompt_templates[x]),
 
228
  with gr.Row():
229
  with gr.Column(scale=4):
230
  generic_chatbot_output = gr.Chatbot(height=600)
231
+ user_input_gc = gr.Textbox(placeholder="Type your instructions and question here...", label="Your Instructions and Question")
232
  submit_button_gc = gr.Button("Submit")
233
 
234
  # ... (existing code for the column with markdown)
 
245
 
246
  gr.Examples(
247
  examples=[
248
+ "Help me brainstorm ideas for a spiritual talk on the topic of cultivating divine love?",
249
+ "How would I explain this to a beginneron the path: What are the main teachings of Self-Realization Fellowship?",
250
+ "Explain the concept of Kriya Yoga for an advanced kriya yogi",
251
  "Can you provide quotes about the importance of meditation?",
252
  ],
253
  inputs=user_input_gc,
src/generic_bot.py CHANGED
@@ -37,7 +37,7 @@ class ToolManager:
37
 
38
  def add_tools(self):
39
  @tool
40
- def vector_search(query: str, k: int = 5) -> list[Document]:
41
  """Useful for simple queries. This tool will search a vector database for passages from the teachings of Paramhansa Yogananda and other publications from the Self Realization Fellowship (SRF).
42
  The user has the option to specify the number of passages they want the search to return, otherwise the number of passages will be set to the default value."""
43
  retriever = self.vectorstore.as_retriever(search_kwargs={"k": k})
@@ -45,7 +45,7 @@ class ToolManager:
45
  return documents
46
 
47
  @tool
48
- def multiple_query_vector_search(query: str, k: int = 5) -> list[Document]:
49
  """Useful when the user's query is vague, complex, or involves multiple concepts.
50
  This tool will write multiple versions of the user's query and search the vector database for relevant passages.
51
  Use this tool when the user asks for an in depth answer to their question."""
 
37
 
38
  def add_tools(self):
39
  @tool
40
+ def vector_search(query: str, k: int = 15) -> list[Document]:
41
  """Useful for simple queries. This tool will search a vector database for passages from the teachings of Paramhansa Yogananda and other publications from the Self Realization Fellowship (SRF).
42
  The user has the option to specify the number of passages they want the search to return, otherwise the number of passages will be set to the default value."""
43
  retriever = self.vectorstore.as_retriever(search_kwargs={"k": k})
 
45
  return documents
46
 
47
  @tool
48
+ def multiple_query_vector_search(query: str, k: int = 15) -> list[Document]:
49
  """Useful when the user's query is vague, complex, or involves multiple concepts.
50
  This tool will write multiple versions of the user's query and search the vector database for relevant passages.
51
  Use this tool when the user asks for an in depth answer to their question."""
src/passage_finder.py CHANGED
@@ -51,7 +51,7 @@ class ToolManager:
51
 
52
  def add_tools(self):
53
  @tool
54
- def vector_search(query: str, k: int = 10) -> list[Document]:
55
  """Useful for simple queries. This tool will search a vector database for passages from the teachings of Paramhansa Yogananda and other publications from the Self Realization Fellowship (SRF).
56
  The user has the option to specify the number of passages they want the search to return, otherwise the number of passages will be set to the default value."""
57
  retriever = self.vectorstore.as_retriever(search_kwargs={"k": k})
@@ -171,7 +171,7 @@ class QuoteFinder:
171
  docs = state["documents"]
172
  final_response = ""
173
  for doc in docs:
174
- final_response += doc.metadata["publication_name"] + ": " + doc.metadata["chapter_name"] + "\n" + doc.metadata["highlighted_content"] + "\n\n"
175
 
176
  return {"final_response": final_response}
177
 
 
51
 
52
  def add_tools(self):
53
  @tool
54
+ def vector_search(query: str, k: int = 15) -> list[Document]:
55
  """Useful for simple queries. This tool will search a vector database for passages from the teachings of Paramhansa Yogananda and other publications from the Self Realization Fellowship (SRF).
56
  The user has the option to specify the number of passages they want the search to return, otherwise the number of passages will be set to the default value."""
57
  retriever = self.vectorstore.as_retriever(search_kwargs={"k": k})
 
171
  docs = state["documents"]
172
  final_response = ""
173
  for doc in docs:
174
+ final_response += doc.metadata["book_name"] + ": " + doc.metadata["full_title"] + "\n" + doc.metadata["highlighted_content"] + "\n\n"
175
 
176
  return {"final_response": final_response}
177
 
src/srf_bot.py CHANGED
@@ -37,7 +37,7 @@ class ToolManager:
37
 
38
  def add_tools(self):
39
  @tool
40
- def vector_search(query: str, k: int = 5) -> list[Document]:
41
  """Useful for simple queries. This tool will search a vector database for passages from the teachings of Paramhansa Yogananda and other publications from the Self Realization Fellowship (SRF).
42
  The user has the option to specify the number of passages they want the search to return, otherwise the number of passages will be set to the default value."""
43
  retriever = self.vectorstore.as_retriever(search_kwargs={"k": k})
@@ -45,7 +45,7 @@ class ToolManager:
45
  return documents
46
 
47
  @tool
48
- def multiple_query_vector_search(query: str, k: int = 5) -> list[Document]:
49
  """Useful when the user's query is vague, complex, or involves multiple concepts.
50
  This tool will write multiple versions of the user's query and search the vector database for relevant passages.
51
  Use this tool when the user asks for an in depth answer to their question."""
 
37
 
38
  def add_tools(self):
39
  @tool
40
+ def vector_search(query: str, k: int = 15) -> list[Document]:
41
  """Useful for simple queries. This tool will search a vector database for passages from the teachings of Paramhansa Yogananda and other publications from the Self Realization Fellowship (SRF).
42
  The user has the option to specify the number of passages they want the search to return, otherwise the number of passages will be set to the default value."""
43
  retriever = self.vectorstore.as_retriever(search_kwargs={"k": k})
 
45
  return documents
46
 
47
  @tool
48
+ def multiple_query_vector_search(query: str, k: int = 15) -> list[Document]:
49
  """Useful when the user's query is vague, complex, or involves multiple concepts.
50
  This tool will write multiple versions of the user's query and search the vector database for relevant passages.
51
  Use this tool when the user asks for an in depth answer to their question."""