jcleee commited on
Commit
fd7a1b9
·
verified ·
1 Parent(s): 8fa1deb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -69,17 +69,20 @@ with open("agent.json", "r") as f:
69
 
70
  model_config = agent_config["model"]["data"]
71
 
72
- # === BUILD MODEL MANUALLY (SAFE FALLBACK) ===
73
  model = HfApiModel(
74
  model_id=model_config["model_id"],
75
- token=os.getenv("HF_TOKEN"), # Injected securely from Space secret
76
  temperature=model_config.get("temperature", 0.5),
77
  max_tokens=model_config.get("max_tokens", 2048),
78
- last_input_token_count=model_config.get("last_input_token_count", 0),
79
- last_output_token_count=model_config.get("last_output_token_count", 0),
80
  custom_role_conversions=model_config.get("custom_role_conversions", None),
81
  )
82
 
 
 
 
 
 
83
  # === IMPORT TOOL FROM HUB ===
84
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
85
 
 
69
 
70
  model_config = agent_config["model"]["data"]
71
 
72
+ # === BUILD MODEL ===
73
  model = HfApiModel(
74
  model_id=model_config["model_id"],
75
+ token=os.getenv("HF_TOKEN"),
76
  temperature=model_config.get("temperature", 0.5),
77
  max_tokens=model_config.get("max_tokens", 2048),
 
 
78
  custom_role_conversions=model_config.get("custom_role_conversions", None),
79
  )
80
 
81
+ # ✅ Force these to be correct after init
82
+ model.last_input_token_count = 0
83
+ model.last_output_token_count = 0
84
+
85
+
86
  # === IMPORT TOOL FROM HUB ===
87
  image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
88