Spaces:
Sleeping
Sleeping
Commit
·
bd6208d
1
Parent(s):
47db8e2
- backend/__init__.py +0 -0
- backend/main.py +6 -5
- backend/rag.py +2 -2
backend/__init__.py
ADDED
File without changes
|
backend/main.py
CHANGED
@@ -4,8 +4,10 @@ from fastapi import Request
|
|
4 |
# Access the global FastAPI app state
|
5 |
#from fastapi import current_app
|
6 |
from pydantic import BaseModel
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
from contextlib import asynccontextmanager
|
10 |
|
11 |
import polars as pl
|
@@ -78,11 +80,10 @@ def get_filters():
|
|
78 |
"countries": app.state.countries_list
|
79 |
}
|
80 |
|
81 |
-
|
82 |
@app.get("/api/stats")
|
83 |
def get_stats(request: Request):
|
84 |
params = request.query_params
|
85 |
-
lf = app.state.df
|
86 |
|
87 |
if s := params.get("status"):
|
88 |
lf = lf.filter(pl.col("_status_lc") == s.lower())
|
@@ -114,7 +115,7 @@ def get_stats(request: Request):
|
|
114 |
"Projects per Year 3": {"labels": years, "values": counts},
|
115 |
"Projects per Year 4": {"labels": years, "values": counts},
|
116 |
"Projects per Year 5": {"labels": years, "values": counts},
|
117 |
-
"Projects per Year 6": {"labels": years, "values": counts}
|
118 |
|
119 |
|
120 |
@app.get("/api/project/{project_id}/organizations")
|
|
|
4 |
# Access the global FastAPI app state
|
5 |
#from fastapi import current_app
|
6 |
from pydantic import BaseModel
|
7 |
+
try:
|
8 |
+
from rag import get_rag_chain, RAGRequest, RAGResponse
|
9 |
+
except:
|
10 |
+
from backend.rag import get_rag_chain, RAGRequest, RAGResponse
|
11 |
from contextlib import asynccontextmanager
|
12 |
|
13 |
import polars as pl
|
|
|
80 |
"countries": app.state.countries_list
|
81 |
}
|
82 |
|
|
|
83 |
@app.get("/api/stats")
|
84 |
def get_stats(request: Request):
|
85 |
params = request.query_params
|
86 |
+
lf = app.state.df
|
87 |
|
88 |
if s := params.get("status"):
|
89 |
lf = lf.filter(pl.col("_status_lc") == s.lower())
|
|
|
115 |
"Projects per Year 3": {"labels": years, "values": counts},
|
116 |
"Projects per Year 4": {"labels": years, "values": counts},
|
117 |
"Projects per Year 5": {"labels": years, "values": counts},
|
118 |
+
"Projects per Year 6": {"labels": years, "values": counts}}
|
119 |
|
120 |
|
121 |
@app.get("/api/project/{project_id}/organizations")
|
backend/rag.py
CHANGED
@@ -5,8 +5,8 @@ from typing import Any, Dict, List, Tuple
|
|
5 |
|
6 |
from fastapi import FastAPI
|
7 |
from contextlib import asynccontextmanager
|
8 |
-
from pydantic import BaseSettings,
|
9 |
-
|
10 |
from langchain.schema import Document, BaseRetriever
|
11 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
12 |
from langchain.vectorstores import FAISS
|
|
|
5 |
|
6 |
from fastapi import FastAPI
|
7 |
from contextlib import asynccontextmanager
|
8 |
+
from pydantic import BaseModel #BaseSettings,
|
9 |
+
from pydantic_settings import BaseSettings
|
10 |
from langchain.schema import Document, BaseRetriever
|
11 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
12 |
from langchain.vectorstores import FAISS
|