“vinit5112” commited on
Commit
3092e52
·
1 Parent(s): 8146726
Files changed (2) hide show
  1. backend/backend_api.py +0 -28
  2. backend/rag.py +6 -6
backend/backend_api.py CHANGED
@@ -83,34 +83,6 @@ app.add_middleware(
83
  async def health_check():
84
  return {"status": "healthy", "message": "CA Study Assistant API is running"}
85
 
86
- # API Routes
87
- # @app.post("/api/ask", response_model=QuestionResponse)
88
- # async def ask_question(request: QuestionRequest):
89
- # """
90
- # Ask a question to the RAG system
91
- # """
92
- # try:
93
- # if not rag_system:
94
- # raise HTTPException(status_code=500, detail="RAG system not initialized")
95
-
96
- # logger.info(f"Processing question: {request.question[:100]}...")
97
- # answer = rag_system.ask_question(request.question)
98
-
99
- # # Extract sources from the answer if they exist
100
- # sources = []
101
- # if "Sources:" in answer:
102
- # parts = answer.split("Sources:")
103
- # if len(parts) > 1:
104
- # answer = parts[0].strip()
105
- # sources_text = parts[1].strip()
106
- # sources = [s.strip() for s in sources_text.split(",") if s.strip()]
107
-
108
- # return QuestionResponse(answer=answer, sources=sources)
109
-
110
- # except Exception as e:
111
- # logger.error(f"Error processing question: {e}")
112
- # raise HTTPException(status_code=500, detail=f"Error processing question: {str(e)}")
113
-
114
  @app.post("/api/ask_stream")
115
  async def ask_question_stream(request: QuestionRequest):
116
  """
 
83
  async def health_check():
84
  return {"status": "healthy", "message": "CA Study Assistant API is running"}
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  @app.post("/api/ask_stream")
87
  async def ask_question_stream(request: QuestionRequest):
88
  """
backend/rag.py CHANGED
@@ -183,9 +183,9 @@ Question: {question}"""
183
  yield f"Error generating answer: {e}"
184
 
185
  # Simple usage example
186
- if __name__ == "__main__":
187
- # Initialize
188
- rag = RAG(
189
- google_api_key="your_google_api_key",
190
- collection_name="ca-documents"
191
- )
 
183
  yield f"Error generating answer: {e}"
184
 
185
  # Simple usage example
186
+ # if __name__ == "__main__":
187
+ # # Initialize
188
+ # rag = RAG(
189
+ # google_api_key="your_google_api_key",
190
+ # collection_name="ca-documents"
191
+ # )