Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,20 +11,15 @@ API_BASE_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 11 |
HEADERS = {"Content-Type": "application/json", "accept": "application/json"}
|
| 12 |
|
| 13 |
# --- OpenAI Client Configuration ---
|
| 14 |
-
# For Hugging Face Spaces, the API key will be loaded from Secrets.
|
| 15 |
OPENAI_API_KEY_VALUE = os.environ.get("OPENAI_API_KEY")
|
| 16 |
-
|
| 17 |
-
# This 'load_dotenv()' is mainly for local convenience.
|
| 18 |
-
# In HF Spaces, if the secret OPENAI_API_KEY is set, the above line will get it.
|
| 19 |
if not OPENAI_API_KEY_VALUE:
|
| 20 |
print("OPENAI_API_KEY not found in environment variables. Attempting to load from a local .env file (if present)...")
|
| 21 |
-
load_dotenv()
|
| 22 |
OPENAI_API_KEY_VALUE = os.environ.get("OPENAI_API_KEY")
|
| 23 |
|
| 24 |
if not OPENAI_API_KEY_VALUE:
|
| 25 |
print("CRITICAL ERROR: OPENAI_API_KEY is not set.")
|
| 26 |
print("Please ensure it's defined as a Secret in your Hugging Face Space settings.")
|
| 27 |
-
# In a real app, you might raise an error or exit if the key is crucial
|
| 28 |
client = None
|
| 29 |
else:
|
| 30 |
try:
|
|
@@ -34,13 +29,10 @@ else:
|
|
| 34 |
print(f"Error initializing OpenAI client: {e}")
|
| 35 |
client = None
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# Update model to use ChatGPT
|
| 40 |
-
LLM_MODEL = "gpt-3.5-turbo" # Using ChatGPT model
|
| 41 |
|
| 42 |
-
# ---
|
| 43 |
-
GAIA_FINAL_ANSWER_SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units
|
| 44 |
|
| 45 |
# --- Step 3: Pydantic Models for Tool Inputs ---
|
| 46 |
class WebSearchInput(BaseModel):
|
|
|
|
| 11 |
HEADERS = {"Content-Type": "application/json", "accept": "application/json"}
|
| 12 |
|
| 13 |
# --- OpenAI Client Configuration ---
|
|
|
|
| 14 |
OPENAI_API_KEY_VALUE = os.environ.get("OPENAI_API_KEY")
|
|
|
|
|
|
|
|
|
|
| 15 |
if not OPENAI_API_KEY_VALUE:
|
| 16 |
print("OPENAI_API_KEY not found in environment variables. Attempting to load from a local .env file (if present)...")
|
| 17 |
+
load_dotenv()
|
| 18 |
OPENAI_API_KEY_VALUE = os.environ.get("OPENAI_API_KEY")
|
| 19 |
|
| 20 |
if not OPENAI_API_KEY_VALUE:
|
| 21 |
print("CRITICAL ERROR: OPENAI_API_KEY is not set.")
|
| 22 |
print("Please ensure it's defined as a Secret in your Hugging Face Space settings.")
|
|
|
|
| 23 |
client = None
|
| 24 |
else:
|
| 25 |
try:
|
|
|
|
| 29 |
print(f"Error initializing OpenAI client: {e}")
|
| 30 |
client = None
|
| 31 |
|
| 32 |
+
LLM_MODEL = "gpt-3.5-turbo"
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
# --- GAIA System Prompt ---
|
| 35 |
+
GAIA_FINAL_ANSWER_SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units s
|
| 36 |
|
| 37 |
# --- Step 3: Pydantic Models for Tool Inputs ---
|
| 38 |
class WebSearchInput(BaseModel):
|