aman1762 commited on
Commit
e0f2984
·
verified ·
1 Parent(s): e038f35

Delete api.py

Browse files
Files changed (1) hide show
  1. api.py +0 -41
api.py DELETED
@@ -1,41 +0,0 @@
1
- from fastapi import FastAPI
2
- from ingest import load_repo, ingest_repo
3
- from vectorstore import create_vectorstore
4
- from rag_chain import build_rag_chain
5
- import os
6
-
7
- import traceback
8
-
9
- app = FastAPI()
10
-
11
- @app.on_event("startup")
12
- def on_startup():
13
- # Helpful startup log to confirm FastAPI loaded successfully
14
- print("===== FASTAPI startup event fired =====")
15
-
16
- @app.get("/health")
17
- def health():
18
- return {"status": "ok"}
19
-
20
- # existing endpoints below ...
21
- # keep your /load and /ask endpoints as before
22
-
23
- app = FastAPI()
24
- qa_chain = None
25
-
26
- @app.post("/load")
27
- def load_repository(repo_url: str):
28
- global qa_chain
29
- path = load_repo(repo_url)
30
- docs = ingest_repo(path)
31
- vectorstore = create_vectorstore(docs)
32
- qa_chain = build_rag_chain(vectorstore, os.getenv("GROQ_API_KEY"))
33
- return {"status": "Repository indexed"}
34
-
35
- @app.get("/ask")
36
- def ask(question: str):
37
- result = qa_chain(question)
38
- return {
39
- "answer": result["result"],
40
- "sources": [doc.metadata["file"] for doc in result["source_documents"]]
41
- }