ak3ra commited on
Commit
d377a8f
1 Parent(s): d762ede

response instead of everything

Browse files
Files changed (2) hide show
  1. app.py +1 -8
  2. rag/rag_pipeline.py +3 -5
app.py CHANGED
@@ -35,14 +35,7 @@ def query_rag(study_name: str, question: str, prompt_type: str) -> str:
35
  # Use the prepared context in the query
36
  response = rag.query(question, prompt_template=prompt)
37
 
38
- # Format the response as Markdown
39
- formatted_response = f"## Question\n\n{question}\n\n## Answer\n\n{response['answer']}\n\n## Sources\n\n"
40
- for source in response["sources"]:
41
- formatted_response += (
42
- f"- {source['title']} ({source.get('year', 'Year not specified')})\n"
43
- )
44
-
45
- return formatted_response
46
 
47
 
48
  def get_study_info(study_name):
 
35
  # Use the prepared context in the query
36
  response = rag.query(question, prompt_template=prompt)
37
 
38
+ return response.response
 
 
 
 
 
 
 
39
 
40
 
41
  def get_study_info(study_name):
rag/rag_pipeline.py CHANGED
@@ -27,8 +27,8 @@ class RAGPipeline:
27
  for index, doc_data in enumerate(self.data):
28
  doc_content = (
29
  f"Title: {doc_data['title']}\n"
 
30
  f"Authors: {', '.join(doc_data['authors'])}\n"
31
- f"Full Text: {doc_data['full_text']}"
32
  )
33
 
34
  metadata = {
@@ -37,6 +37,7 @@ class RAGPipeline:
37
  "authors": doc_data.get("authors", []),
38
  "year": doc_data.get("year"),
39
  "doi": doc_data.get("doi"),
 
40
  }
41
 
42
  self.documents.append(
@@ -89,7 +90,4 @@ class RAGPipeline:
89
 
90
  response = query_engine.query(context)
91
 
92
- return {
93
- "answer": response.response,
94
- "sources": [node.metadata for node in response.source_nodes],
95
- }
 
27
  for index, doc_data in enumerate(self.data):
28
  doc_content = (
29
  f"Title: {doc_data['title']}\n"
30
+ f"Abstract: {doc_data['abstract']}\n"
31
  f"Authors: {', '.join(doc_data['authors'])}\n"
 
32
  )
33
 
34
  metadata = {
 
37
  "authors": doc_data.get("authors", []),
38
  "year": doc_data.get("year"),
39
  "doi": doc_data.get("doi"),
40
+ "full_text": doc_data.get("full_text"),
41
  }
42
 
43
  self.documents.append(
 
90
 
91
  response = query_engine.query(context)
92
 
93
+ return response