fix backend
Browse files- backend/main.py +0 -10
- services/backendService.ts +6 -16
backend/main.py
CHANGED
|
@@ -4,7 +4,6 @@ from fastapi import FastAPI, HTTPException, BackgroundTasks
|
|
| 4 |
from fastapi.staticfiles import StaticFiles
|
| 5 |
from fastapi.responses import FileResponse
|
| 6 |
from pydantic import BaseModel
|
| 7 |
-
from fastapi.middleware.cors import CORSMiddleware
|
| 8 |
from google import genai
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
import os
|
|
@@ -31,16 +30,7 @@ app = FastAPI(title="3GPP Innovation Backend")
|
|
| 31 |
# Initialize DataService
|
| 32 |
data_service = DataService()
|
| 33 |
|
| 34 |
-
# CORS Setup
|
| 35 |
-
origins = [
|
| 36 |
-
"http://localhost:5173",
|
| 37 |
-
"http://localhost:3000",
|
| 38 |
-
"*"
|
| 39 |
-
]
|
| 40 |
-
|
| 41 |
app.add_middleware(
|
| 42 |
-
CORSMiddleware,
|
| 43 |
-
allow_origins=origins,
|
| 44 |
allow_credentials=True,
|
| 45 |
allow_methods=["*"],
|
| 46 |
allow_headers=["*"],
|
|
|
|
| 4 |
from fastapi.staticfiles import StaticFiles
|
| 5 |
from fastapi.responses import FileResponse
|
| 6 |
from pydantic import BaseModel
|
|
|
|
| 7 |
from google import genai
|
| 8 |
from dotenv import load_dotenv
|
| 9 |
import os
|
|
|
|
| 30 |
# Initialize DataService
|
| 31 |
data_service = DataService()
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
app.add_middleware(
|
|
|
|
|
|
|
| 34 |
allow_credentials=True,
|
| 35 |
allow_methods=["*"],
|
| 36 |
allow_headers=["*"],
|
services/backendService.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
| 1 |
import { DocumentFile, Innovation } from '../types';
|
| 2 |
|
| 3 |
-
const BACKEND_API_URL = 'http://localhost:7860';
|
| 4 |
-
|
| 5 |
export interface ProcessResponse {
|
| 6 |
id: string;
|
| 7 |
file_name: string;
|
| 8 |
answer: string;
|
| 9 |
classification: string;
|
| 10 |
-
// id: string;
|
| 11 |
-
// innovation_name: string;
|
| 12 |
-
// problem_id: string;
|
| 13 |
-
// problem_statement: string;
|
| 14 |
-
// context: string;
|
| 15 |
-
// proposed_solution: string;
|
| 16 |
-
// technical_classification: string;
|
| 17 |
-
// classification: string;
|
| 18 |
}
|
| 19 |
|
| 20 |
export const backendService = {
|
|
@@ -40,7 +30,7 @@ export const backendService = {
|
|
| 40 |
url: file.url
|
| 41 |
};
|
| 42 |
|
| 43 |
-
const response = await fetch(
|
| 44 |
method: 'POST',
|
| 45 |
headers: { 'Content-Type': 'application/json' },
|
| 46 |
body: JSON.stringify(payload)
|
|
@@ -69,7 +59,7 @@ export const backendService = {
|
|
| 69 |
|
| 70 |
getPatterns: async (): Promise<any[]> => {
|
| 71 |
try {
|
| 72 |
-
const response = await fetch(
|
| 73 |
if (response.ok) {
|
| 74 |
return await response.json();
|
| 75 |
}
|
|
@@ -82,7 +72,7 @@ export const backendService = {
|
|
| 82 |
|
| 83 |
analyzeContent: async (patternId: number, fileId?: string, text?: string): Promise<{ content: string; result_id: number; methodology: string; context: string; problem: string; pattern_name: string } | null> => {
|
| 84 |
try {
|
| 85 |
-
const response = await fetch(
|
| 86 |
method: 'POST',
|
| 87 |
headers: { 'Content-Type': 'application/json' },
|
| 88 |
body: JSON.stringify({
|
|
@@ -105,7 +95,7 @@ export const backendService = {
|
|
| 105 |
|
| 106 |
saveClassification: async (resultId: number, classification: string): Promise<boolean> => {
|
| 107 |
try {
|
| 108 |
-
const response = await fetch(
|
| 109 |
method: 'POST',
|
| 110 |
headers: { 'Content-Type': 'application/json' },
|
| 111 |
body: JSON.stringify({ result_id: resultId, classification })
|
|
@@ -119,7 +109,7 @@ export const backendService = {
|
|
| 119 |
|
| 120 |
fetchClassifiedInnovations: async (): Promise<any[]> => {
|
| 121 |
try {
|
| 122 |
-
const response = await fetch(
|
| 123 |
if (response.ok) {
|
| 124 |
return await response.json();
|
| 125 |
}
|
|
@@ -132,7 +122,7 @@ export const backendService = {
|
|
| 132 |
|
| 133 |
fetchAllFiles: async (): Promise<DocumentFile[]> => {
|
| 134 |
try {
|
| 135 |
-
const response = await fetch(
|
| 136 |
if (response.ok) {
|
| 137 |
const rows = await response.json();
|
| 138 |
// Map tuple to DocumentFile:
|
|
|
|
| 1 |
import { DocumentFile, Innovation } from '../types';
|
| 2 |
|
|
|
|
|
|
|
| 3 |
export interface ProcessResponse {
|
| 4 |
id: string;
|
| 5 |
file_name: string;
|
| 6 |
answer: string;
|
| 7 |
classification: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
export const backendService = {
|
|
|
|
| 30 |
url: file.url
|
| 31 |
};
|
| 32 |
|
| 33 |
+
const response = await fetch(`/process`, {
|
| 34 |
method: 'POST',
|
| 35 |
headers: { 'Content-Type': 'application/json' },
|
| 36 |
body: JSON.stringify(payload)
|
|
|
|
| 59 |
|
| 60 |
getPatterns: async (): Promise<any[]> => {
|
| 61 |
try {
|
| 62 |
+
const response = await fetch(`/patterns`);
|
| 63 |
if (response.ok) {
|
| 64 |
return await response.json();
|
| 65 |
}
|
|
|
|
| 72 |
|
| 73 |
analyzeContent: async (patternId: number, fileId?: string, text?: string): Promise<{ content: string; result_id: number; methodology: string; context: string; problem: string; pattern_name: string } | null> => {
|
| 74 |
try {
|
| 75 |
+
const response = await fetch(`/analyze`, {
|
| 76 |
method: 'POST',
|
| 77 |
headers: { 'Content-Type': 'application/json' },
|
| 78 |
body: JSON.stringify({
|
|
|
|
| 95 |
|
| 96 |
saveClassification: async (resultId: number, classification: string): Promise<boolean> => {
|
| 97 |
try {
|
| 98 |
+
const response = await fetch(`/classify`, {
|
| 99 |
method: 'POST',
|
| 100 |
headers: { 'Content-Type': 'application/json' },
|
| 101 |
body: JSON.stringify({ result_id: resultId, classification })
|
|
|
|
| 109 |
|
| 110 |
fetchClassifiedInnovations: async (): Promise<any[]> => {
|
| 111 |
try {
|
| 112 |
+
const response = await fetch(`/results`);
|
| 113 |
if (response.ok) {
|
| 114 |
return await response.json();
|
| 115 |
}
|
|
|
|
| 122 |
|
| 123 |
fetchAllFiles: async (): Promise<DocumentFile[]> => {
|
| 124 |
try {
|
| 125 |
+
const response = await fetch(`/get_all`);
|
| 126 |
if (response.ok) {
|
| 127 |
const rows = await response.json();
|
| 128 |
// Map tuple to DocumentFile:
|