dembasowmr commited on
Commit
a032c74
·
1 Parent(s): 0d58962

Metadata repo card added - README.md

Browse files
Files changed (2) hide show
  1. README.md +32 -0
  2. app.py +4 -4
README.md CHANGED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: CompassIA
3
+ emoji: 💬📚 # You can choose other emojis here
4
+ colorFrom: green
5
+ colorTo: blue
6
+ sdk: docker # This must be 'docker' as you selected
7
+ app_port: 7860 # This is the port your uvicorn app is listening on
8
+ # Optional: You can specify a base image for the Docker SDK if not in Dockerfile directly.
9
+ # base_image: python:3.10-slim-buster
10
+ # pinned: false # Usually not needed unless you want to pin a specific commit
11
+ ---
12
+
13
+ # CompassIA
14
+
15
+ This Space hosts the backend API for CompassIA, a PDF Question Answering system. CompassIA is a smart agent for MaarifCompass that allows users to ask questions about PDF documents, leveraging advanced AI models for natural language understanding and information retrieval.
16
+
17
+ It uses:
18
+ - **Python FastAPI** for the web API.
19
+ - **DeepSeek Chat** (via OpenRouter) as the Large Language Model.
20
+ - **BGE-M3** from FlagEmbedding for local, multilingual text embeddings.
21
+ - **ChromaDB** for persistent vector storage.
22
+ - **pdfminer.six** and **PyTesseract (with Poppler)** for robust PDF text extraction and OCR.
23
+
24
+ ## How to Use:
25
+ This Space exposes a `/compassia/` API endpoint. You can interact with it using `curl`, Postman, Insomnia, or by integrating it with your Next.js frontend.
26
+
27
+ ### API Endpoint: `/ask-pdf/` (POST request)
28
+ **Request Body (JSON):**
29
+ ```json
30
+ {
31
+ "question": "Your question about the PDF documents"
32
+ }
app.py CHANGED
@@ -53,8 +53,8 @@ class QueryRequest(BaseModel):
53
  question: str
54
 
55
  # --- API Endpoint Definition ---
56
- @app.post("/ask-pdf/")
57
- async def ask_pdf_endpoint(request: QueryRequest):
58
  """
59
  Answers a question about the indexed PDF documents using RAG.
60
  """
@@ -63,13 +63,13 @@ async def ask_pdf_endpoint(request: QueryRequest):
63
  answer = rag_system.answer_question(request.question, [])
64
  return {"answer": answer}
65
  except Exception as e:
66
- print(f"Error processing /ask-pdf/ request: {e}")
67
  raise HTTPException(status_code=500, detail=str(e))
68
 
69
  # Basic health check endpoint
70
  @app.get("/")
71
  async def root():
72
- return {"message": "Compassia AI PDF Chat API is running. Use /ask-pdf/ for queries."}
73
 
74
  # You can run this locally for testing:
75
  # if __name__ == "__main__":
 
53
  question: str
54
 
55
  # --- API Endpoint Definition ---
56
+ @app.post("/compassia/")
57
+ async def compassia_endpoint(request: QueryRequest):
58
  """
59
  Answers a question about the indexed PDF documents using RAG.
60
  """
 
63
  answer = rag_system.answer_question(request.question, [])
64
  return {"answer": answer}
65
  except Exception as e:
66
+ print(f"Error processing /compassia/ request: {e}")
67
  raise HTTPException(status_code=500, detail=str(e))
68
 
69
  # Basic health check endpoint
70
  @app.get("/")
71
  async def root():
72
+ return {"message": "CompassIA API is running. Use /compassia/ for queries."}
73
 
74
  # You can run this locally for testing:
75
  # if __name__ == "__main__":