HF_AGENTS_FINAL_PROJECT / configuration.py
AlessandroMasala's picture
Update configuration.py
9742b02 verified
# configuration.py
import os
from smolagents import OpenAIServerModel, InferenceClientModel
# Domande da rispondere
QUESTIONS = [1, 3, 5, 8, 9, 11, 13, 17, 18, 20]
DEFAULT_API_URL = 'https://agents-course-unit4-scoring.hf.space'
INSTRUCTIONS = """
You are a general AI assistant. I will ask you a question...
When you have your final answer, call final_answer(...) with that value.
"""
# Leggi le chiavi dalle Secrets di Spaces
OPENAI_KEY = os.getenv("OPENAI_API_KEY")
HF_KEY = os.getenv("HF_TOKEN") # conserva la tua HF_TOKEN se vuoi fallback
if not (OPENAI_KEY):
raise RuntimeError(
"Devi impostare OPENAI_API_KEY nelle Secrets di Spaces!"
)
def make_model():
if OPENAI_KEY:
# 1) GPT‑4.1 via OpenAI API (trial/pay‑as‑you‑go)
return OpenAIServerModel(
model_id="gpt-4.1",
api_key=OPENAI_KEY,
max_tokens=8000
)
# Tutti i client LLM usano lo stesso MODEL
MODEL = make_model()
MANAGER_MODEL = MODEL
WORKER_MODEL = MODEL
CHECK_MODEL = MODEL
# Limiti e pause
TOKEN_LIMITER = 5000
STEP_WAIT = 60