rwillats commited on
Commit
ff0b50f
·
verified ·
1 Parent(s): 1a08e0a

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. ai_responses_demo.py +12 -9
ai_responses_demo.py CHANGED
@@ -74,21 +74,24 @@ ORACLE_API_KEY = os.getenv("ORACLE_KEY", ORACLE_API_KEY)
74
  TOGETHER_API_KEY = os.getenv("TOGETHER_KEY", TOGETHER_API_KEY)
75
  OPENAI_API_KEY = os.getenv("OPENAI_KEY", OPENAI_API_KEY)
76
 
 
 
77
  def random_test_case():
78
  try:
79
  df = pd.read_csv("test cases.csv")
80
-
81
- # Check for required columns
82
- if not {"user input", "response"}.issubset(df.columns):
83
- raise ValueError("CSV must contain 'user input' and 'response' columns.")
84
-
85
- # Sample one row
 
 
86
  sample = df.sample(1).iloc[0]
87
-
88
- # Return both fields
89
  return sample["user input"], sample["response"]
90
-
91
  except Exception as e:
 
92
  return f"Error: {e}", ""
93
 
94
  # Custom CSS for styling
 
74
  TOGETHER_API_KEY = os.getenv("TOGETHER_KEY", TOGETHER_API_KEY)
75
  OPENAI_API_KEY = os.getenv("OPENAI_KEY", OPENAI_API_KEY)
76
 
77
+ import pandas as pd
78
+
79
  def random_test_case():
80
  try:
81
  df = pd.read_csv("test cases.csv")
82
+
83
+ # Print out the first few rows for debugging
84
+ print("CSV Loaded. First few rows:")
85
+ print(df.head())
86
+
87
+ if "user input" not in df.columns or "response" not in df.columns:
88
+ raise ValueError(f"CSV must have 'user input' and 'response' columns, found: {df.columns.tolist()}")
89
+
90
  sample = df.sample(1).iloc[0]
 
 
91
  return sample["user input"], sample["response"]
92
+
93
  except Exception as e:
94
+ print(f"[ERROR] while loading CSV: {e}")
95
  return f"Error: {e}", ""
96
 
97
  # Custom CSS for styling