Spaces:
Paused
Paused
Hemang Thakur
commited on
Commit
·
2bab159
1
Parent(s):
2023de2
changed hardcoded routes to relative
Browse files
Dockerfile
CHANGED
@@ -43,14 +43,14 @@ COPY requirements.txt .
|
|
43 |
RUN pip install --no-cache-dir -r requirements.txt
|
44 |
|
45 |
# Install additional dependencies for torch and spaCy
|
46 |
-
RUN pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
|
47 |
RUN python -m spacy download en_core_web_sm
|
48 |
|
49 |
# Copy the rest of your backend code and resources
|
50 |
COPY . .
|
51 |
|
52 |
-
# Copy the built React app from the builder stage into
|
53 |
-
COPY --from=builder /app/frontend/build ./
|
54 |
|
55 |
# Expose the port
|
56 |
EXPOSE ${PORT:-7860}
|
|
|
43 |
RUN pip install --no-cache-dir -r requirements.txt
|
44 |
|
45 |
# Install additional dependencies for torch and spaCy
|
46 |
+
RUN pip install --no-cache-dir torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124
|
47 |
RUN python -m spacy download en_core_web_sm
|
48 |
|
49 |
# Copy the rest of your backend code and resources
|
50 |
COPY . .
|
51 |
|
52 |
+
# Copy the built React app from the builder stage into the same folder structure as used in your FastAPI code
|
53 |
+
COPY --from=builder /app/frontend/build ./frontend/build
|
54 |
|
55 |
# Expose the port
|
56 |
EXPOSE ${PORT:-7860}
|
frontend/src/Components/AiComponents/Evaluate.js
CHANGED
@@ -87,7 +87,7 @@ export default function MultipleSelectChip({ evaluation }) {
|
|
87 |
|
88 |
const payload = { ...evaluation, metrics: selectedMetrics };
|
89 |
try {
|
90 |
-
const res = await fetch("
|
91 |
method: "POST",
|
92 |
headers: { "Content-Type": "application/json" },
|
93 |
body: JSON.stringify(payload),
|
|
|
87 |
|
88 |
const payload = { ...evaluation, metrics: selectedMetrics };
|
89 |
try {
|
90 |
+
const res = await fetch("/action/evaluate", {
|
91 |
method: "POST",
|
92 |
headers: { "Content-Type": "application/json" },
|
93 |
body: JSON.stringify(payload),
|
frontend/src/Components/AiComponents/Graph.js
CHANGED
@@ -11,7 +11,7 @@ export default function Graph({ open, onClose, payload }) {
|
|
11 |
if (open && payload) {
|
12 |
setLoading(true);
|
13 |
setError("");
|
14 |
-
fetch("
|
15 |
method: "POST",
|
16 |
headers: { "Content-Type": "application/json" },
|
17 |
body: JSON.stringify(payload)
|
|
|
11 |
if (open && payload) {
|
12 |
setLoading(true);
|
13 |
setError("");
|
14 |
+
fetch("/action/graph", {
|
15 |
method: "POST",
|
16 |
headers: { "Content-Type": "application/json" },
|
17 |
body: JSON.stringify(payload)
|
frontend/src/Components/AiComponents/Sources.js
CHANGED
@@ -33,7 +33,7 @@ export default function Sources({ sources, handleSourceClick }) {
|
|
33 |
try {
|
34 |
// Use sources.payload if it exists.
|
35 |
const bodyData = sources && sources.payload ? sources.payload : sources;
|
36 |
-
const res = await fetch("
|
37 |
method: "POST",
|
38 |
headers: { "Content-Type": "application/json" },
|
39 |
body: JSON.stringify(bodyData)
|
|
|
33 |
try {
|
34 |
// Use sources.payload if it exists.
|
35 |
const bodyData = sources && sources.payload ? sources.payload : sources;
|
36 |
+
const res = await fetch("/action/sources", {
|
37 |
method: "POST",
|
38 |
headers: { "Content-Type": "application/json" },
|
39 |
body: JSON.stringify(bodyData)
|
frontend/src/Components/AiPage.js
CHANGED
@@ -88,7 +88,7 @@ function AiPage() {
|
|
88 |
// Initiate the SSE
|
89 |
const initiateSSE = (query, blockId) => {
|
90 |
const startTime = Date.now();
|
91 |
-
const sseUrl =
|
92 |
const eventSource = new EventSource(sseUrl);
|
93 |
activeEventSourceRef.current = eventSource;
|
94 |
|
@@ -261,7 +261,7 @@ function AiPage() {
|
|
261 |
}
|
262 |
// Send POST request to /stop and update the chat block with the returned message
|
263 |
try {
|
264 |
-
const response = await fetch('
|
265 |
method: 'POST',
|
266 |
headers: { 'Content-Type': 'application/json' },
|
267 |
body: JSON.stringify({})
|
|
|
88 |
// Initiate the SSE
|
89 |
const initiateSSE = (query, blockId) => {
|
90 |
const startTime = Date.now();
|
91 |
+
const sseUrl = `/message-sse?user_message=${encodeURIComponent(query)}`;
|
92 |
const eventSource = new EventSource(sseUrl);
|
93 |
activeEventSourceRef.current = eventSource;
|
94 |
|
|
|
261 |
}
|
262 |
// Send POST request to /stop and update the chat block with the returned message
|
263 |
try {
|
264 |
+
const response = await fetch('/stop', {
|
265 |
method: 'POST',
|
266 |
headers: { 'Content-Type': 'application/json' },
|
267 |
body: JSON.stringify({})
|
frontend/src/Components/IntialSetting.js
CHANGED
@@ -164,7 +164,7 @@ function IntialSetting(props) {
|
|
164 |
|
165 |
// Send the payload to the backend
|
166 |
try {
|
167 |
-
const response = await fetch("
|
168 |
method: "POST",
|
169 |
headers: {
|
170 |
"Content-Type": "application/json",
|
|
|
164 |
|
165 |
// Send the payload to the backend
|
166 |
try {
|
167 |
+
const response = await fetch("/settings", {
|
168 |
method: "POST",
|
169 |
headers: {
|
170 |
"Content-Type": "application/json",
|
main.py
CHANGED
@@ -539,7 +539,7 @@ app.add_middleware(
|
|
539 |
)
|
540 |
|
541 |
# Serve the React app (the production build) at the root URL.
|
542 |
-
app.mount("/static", StaticFiles(directory="
|
543 |
|
544 |
# Catch-all route for frontend paths.
|
545 |
@app.get("/{full_path:path}")
|
@@ -547,7 +547,7 @@ async def serve_frontend(full_path: str, request: Request):
|
|
547 |
if full_path.startswith("action") or full_path in ["settings", "message-sse", "stop"]:
|
548 |
raise HTTPException(status_code=404, detail="Not Found")
|
549 |
|
550 |
-
index_path = os.path.join("
|
551 |
if not os.path.exists(index_path):
|
552 |
raise HTTPException(status_code=500, detail="Frontend build not found")
|
553 |
return FileResponse(index_path)
|
|
|
539 |
)
|
540 |
|
541 |
# Serve the React app (the production build) at the root URL.
|
542 |
+
app.mount("/static", StaticFiles(directory="frontend/build/static", html=True), name="static")
|
543 |
|
544 |
# Catch-all route for frontend paths.
|
545 |
@app.get("/{full_path:path}")
|
|
|
547 |
if full_path.startswith("action") or full_path in ["settings", "message-sse", "stop"]:
|
548 |
raise HTTPException(status_code=404, detail="Not Found")
|
549 |
|
550 |
+
index_path = os.path.join("frontend", "build", "index.html")
|
551 |
if not os.path.exists(index_path):
|
552 |
raise HTTPException(status_code=500, detail="Frontend build not found")
|
553 |
return FileResponse(index_path)
|