Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files
README.md
CHANGED
|
@@ -36,4 +36,7 @@ itself.
|
|
| 36 |
To run it (locally or as a Space), set the `HF_TOKEN` secret/env var to a
|
| 37 |
Hugging Face access token with Inference API permission. Optionally set
|
| 38 |
`HF_AGENT_MODEL` to override the default model
|
| 39 |
-
(`Qwen/Qwen2.5-Coder-32B-Instruct`)
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
To run it (locally or as a Space), set the `HF_TOKEN` secret/env var to a
|
| 37 |
Hugging Face access token with Inference API permission. Optionally set
|
| 38 |
`HF_AGENT_MODEL` to override the default model
|
| 39 |
+
(`Qwen/Qwen2.5-Coder-32B-Instruct`), and `HF_AGENT_PROVIDER` to override the
|
| 40 |
+
default Inference Provider (`together`) — pinned explicitly because the
|
| 41 |
+
router's `auto` selection can land on a provider that doesn't support tool
|
| 42 |
+
calling for a given model (HTTP 422 `UNSUPPORTED_OPENAI_PARAMS`).
|
agent.py
CHANGED
|
@@ -32,6 +32,12 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 32 |
# HF_AGENT_MODEL env var without touching code.
|
| 33 |
HF_MODEL_REPO_ID = os.getenv("HF_AGENT_MODEL", "Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
with open(Path(__file__).parent / "system_prompt.txt", "r", encoding="utf-8") as f:
|
| 36 |
SYSTEM_PROMPT = f.read()
|
| 37 |
|
|
@@ -269,6 +275,7 @@ def _build_tools():
|
|
| 269 |
def _build_llm():
|
| 270 |
endpoint = HuggingFaceEndpoint(
|
| 271 |
repo_id=HF_MODEL_REPO_ID,
|
|
|
|
| 272 |
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
| 273 |
temperature=0,
|
| 274 |
max_new_tokens=1024,
|
|
|
|
| 32 |
# HF_AGENT_MODEL env var without touching code.
|
| 33 |
HF_MODEL_REPO_ID = os.getenv("HF_AGENT_MODEL", "Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 34 |
|
| 35 |
+
# Left unset ("auto"), the HF router picks whichever provider is cheapest/fastest for the
|
| 36 |
+
# model, and some of those don't support the `tools` param at all (HTTP 422
|
| 37 |
+
# UNSUPPORTED_OPENAI_PARAMS). Pin one that reliably supports tool calling; override via
|
| 38 |
+
# HF_AGENT_PROVIDER if it doesn't happen to host HF_AGENT_MODEL.
|
| 39 |
+
HF_MODEL_PROVIDER = os.getenv("HF_AGENT_PROVIDER", "together")
|
| 40 |
+
|
| 41 |
with open(Path(__file__).parent / "system_prompt.txt", "r", encoding="utf-8") as f:
|
| 42 |
SYSTEM_PROMPT = f.read()
|
| 43 |
|
|
|
|
| 275 |
def _build_llm():
|
| 276 |
endpoint = HuggingFaceEndpoint(
|
| 277 |
repo_id=HF_MODEL_REPO_ID,
|
| 278 |
+
provider=HF_MODEL_PROVIDER,
|
| 279 |
huggingfacehub_api_token=os.getenv("HF_TOKEN"),
|
| 280 |
temperature=0,
|
| 281 |
max_new_tokens=1024,
|