galbendavids commited on
Commit
53469df
·
1 Parent(s): f073efc

תיקון: עדכון נתיבי קבצים - feedback_transformed_2.csv, תיקון נתיב frontend, הוספת לוגים

Browse files
2_backend_llm/app/api.py CHANGED
@@ -145,7 +145,7 @@ def query_sql(req: QueryRequest) -> SQLQueryResponse:
145
  except Exception as e:
146
  return SQLQueryResponse(
147
  query=req.query,
148
- summary=f"שגיאה באתחול שירות SQL: {str(e)}. אנא ודא שקובץ Feedback.csv קיים.",
149
  sql_queries=[],
150
  query_results=[],
151
  visualizations=None
@@ -247,20 +247,36 @@ def query_sql(req: QueryRequest) -> SQLQueryResponse:
247
 
248
  # Mount static files for a simple frontend if present
249
  # Frontend files are in 1_frontend/ directory
250
- static_dir = Path(__file__).parent.parent.parent / "1_frontend"
 
 
 
251
  if static_dir.exists():
252
  # Serve static assets under /static/* (so index.html can reference /static/app.js)
253
  app.mount("/static", StaticFiles(directory=str(static_dir)), name="static")
 
 
 
254
 
255
 
256
  @app.get("/")
257
  def root() -> HTMLResponse:
258
  """Serve the main index.html for the frontend."""
259
  try:
 
 
 
 
 
260
  html = (static_dir / "index.html").read_text(encoding="utf-8")
261
  return HTMLResponse(html)
262
- except Exception:
263
- return HTMLResponse("<html><body><h1>Frontend not available</h1></body></html>", status_code=404)
 
 
 
 
 
264
 
265
 
266
  @app.get("/history")
 
145
  except Exception as e:
146
  return SQLQueryResponse(
147
  query=req.query,
148
+ summary=f"שגיאה באתחול שירות SQL: {str(e)}. אנא ודא שקובץ feedback_transformed_2.csv קיים בתיקיית 0_preprocessing/.",
149
  sql_queries=[],
150
  query_results=[],
151
  visualizations=None
 
247
 
248
  # Mount static files for a simple frontend if present
249
  # Frontend files are in 1_frontend/ directory
250
+ # Calculate path relative to this file: 2_backend_llm/app/api.py -> root/1_frontend
251
+ static_dir = Path(__file__).resolve().parent.parent.parent / "1_frontend"
252
+ print(f"Looking for frontend at: {static_dir}", flush=True)
253
+ print(f"Frontend exists: {static_dir.exists()}", flush=True)
254
  if static_dir.exists():
255
  # Serve static assets under /static/* (so index.html can reference /static/app.js)
256
  app.mount("/static", StaticFiles(directory=str(static_dir)), name="static")
257
+ print(f"Mounted static files from: {static_dir}", flush=True)
258
+ else:
259
+ print(f"WARNING: Frontend directory not found at {static_dir}", flush=True)
260
 
261
 
262
  @app.get("/")
263
  def root() -> HTMLResponse:
264
  """Serve the main index.html for the frontend."""
265
  try:
266
+ if not static_dir.exists():
267
+ return HTMLResponse(
268
+ f"<html><body><h1>Frontend not available</h1><p>Looking for: {static_dir}</p><p>Current working directory: {Path.cwd()}</p></body></html>",
269
+ status_code=404
270
+ )
271
  html = (static_dir / "index.html").read_text(encoding="utf-8")
272
  return HTMLResponse(html)
273
+ except Exception as e:
274
+ import traceback
275
+ error_msg = traceback.format_exc()
276
+ return HTMLResponse(
277
+ f"<html><body><h1>Frontend not available</h1><p>Error: {str(e)}</p><pre>{error_msg}</pre></body></html>",
278
+ status_code=404
279
+ )
280
 
281
 
282
  @app.get("/history")
2_backend_llm/app/data_loader.py CHANGED
@@ -7,12 +7,20 @@ The system expects a CSV with at least the columns: ID, ServiceName, Level, Text
7
  and returns a cleaned Pandas DataFrame.
8
  """
9
 
 
10
  import pandas as pd
11
  from .config import settings
12
 
13
 
14
  def load_feedback(csv_path: str | None = None) -> pd.DataFrame:
15
- path = csv_path or settings.csv_path
 
 
 
 
 
 
 
16
  df = pd.read_csv(path)
17
  # Basic normalization of expected columns if present
18
  expected = ["ID", "ServiceName", "Level", "Text"]
 
7
  and returns a cleaned Pandas DataFrame.
8
  """
9
 
10
+ from pathlib import Path
11
  import pandas as pd
12
  from .config import settings
13
 
14
 
15
  def load_feedback(csv_path: str | None = None) -> pd.DataFrame:
16
+ path_str = csv_path or settings.csv_path
17
+ # Resolve path relative to project root if it's a relative path
18
+ if Path(path_str).is_absolute():
19
+ path = path_str
20
+ else:
21
+ # Calculate project root: 2_backend_llm/app/data_loader.py -> root/
22
+ project_root = Path(__file__).resolve().parent.parent.parent
23
+ path = project_root / path_str
24
  df = pd.read_csv(path)
25
  # Basic normalization of expected columns if present
26
  expected = ["ID", "ServiceName", "Level", "Text"]
2_backend_llm/app/sql_service.py CHANGED
@@ -328,7 +328,7 @@ class SQLFeedbackService:
328
  4. Synthesize answer
329
  """
330
  if self.df is None:
331
- raise ValueError("No feedback data available. Please ensure Feedback.csv exists.")
332
 
333
  # Step 1: Generate SQL queries (with gibberish validation)
334
  try:
 
328
  4. Synthesize answer
329
  """
330
  if self.df is None:
331
+ raise ValueError("No feedback data available. Please ensure feedback_transformed_2.csv exists in 0_preprocessing/ directory.")
332
 
333
  # Step 1: Generate SQL queries (with gibberish validation)
334
  try: