Spaces:
Sleeping
Sleeping
Upload stage2_graph.py
Browse files- agents/stage2_graph.py +22 -7
agents/stage2_graph.py
CHANGED
|
@@ -150,12 +150,22 @@ async def call_llm(
|
|
| 150 |
if not hf_token:
|
| 151 |
raise ValueError("HF_TOKEN not set")
|
| 152 |
|
| 153 |
-
#
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
# Call without provider argument (it's set at client level)
|
| 161 |
response = client.chat_completion(
|
|
@@ -202,7 +212,12 @@ async def call_llm(
|
|
| 202 |
from huggingface_hub import InferenceClient
|
| 203 |
|
| 204 |
hf_token = os.environ.get("HF_TOKEN")
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
# Try appending provider to model name
|
| 208 |
model_with_provider = f"{model}:{provider}"
|
|
|
|
| 150 |
if not hf_token:
|
| 151 |
raise ValueError("HF_TOKEN not set")
|
| 152 |
|
| 153 |
+
# New HuggingFace router URL (api-inference is deprecated)
|
| 154 |
+
router_url = "https://router.huggingface.co"
|
| 155 |
+
|
| 156 |
+
# Initialize client with provider and new router
|
| 157 |
+
try:
|
| 158 |
+
client = InferenceClient(
|
| 159 |
+
token=hf_token,
|
| 160 |
+
provider=provider,
|
| 161 |
+
base_url=router_url,
|
| 162 |
+
)
|
| 163 |
+
except TypeError:
|
| 164 |
+
# Fallback for older versions
|
| 165 |
+
client = InferenceClient(
|
| 166 |
+
token=hf_token,
|
| 167 |
+
provider=provider,
|
| 168 |
+
)
|
| 169 |
|
| 170 |
# Call without provider argument (it's set at client level)
|
| 171 |
response = client.chat_completion(
|
|
|
|
| 212 |
from huggingface_hub import InferenceClient
|
| 213 |
|
| 214 |
hf_token = os.environ.get("HF_TOKEN")
|
| 215 |
+
router_url = "https://router.huggingface.co"
|
| 216 |
+
|
| 217 |
+
try:
|
| 218 |
+
client = InferenceClient(token=hf_token, base_url=router_url)
|
| 219 |
+
except TypeError:
|
| 220 |
+
client = InferenceClient(token=hf_token)
|
| 221 |
|
| 222 |
# Try appending provider to model name
|
| 223 |
model_with_provider = f"{model}:{provider}"
|