Does this example really work at the moment? A chat input returns errors
Error in generating model output:
(Request ID: Wi2n6t)
Bad request:
Bad Request: Invalid state
I also get the same error
I'm having the same error
Error in generating model output:
(Request ID: gNMBU8)
Bad request:
Bad Request: Invalid state
[Step 0: Duration 0.03 seconds]
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 715, in process_events
response = await route_utils.call_process_api(
File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 322, in call_process_api
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 2088, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1647, in call_function
prediction = await utils.async_iteration(iterator)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 728, in async_iteration
return await anext(iterator)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 722, in anext
return await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2461, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 962, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 705, in run_sync_iterator_async
return next(iterator)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 866, in gen_wrapper
response = next(iterator)
File "/home/user/app/Gradio_UI.py", line 197, in interact_with_agent
for msg in stream_to_gradio(self.agent, task=prompt, reset_agent_memory=False):
File "/home/user/app/Gradio_UI.py", line 145, in stream_to_gradio
total_input_tokens += agent.model.last_input_token_count
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'
try this model deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
that worked for me
same here i get errors and it rarely runs
@jemm88 seems like the HF endpoints for the course are being hug to death, i ended up using LiteLLMModel with gemini, heres both examples
the space running this code is here https://huggingface.co/spaces/acidtib/Travel-Planning-Agent
model = HfApiModel(
max_tokens=2096,
temperature=0.5,
model_id='deepseek-ai/DeepSeek-R1-Distill-Qwen-32B',
custom_role_conversions=None,
)
and using litellm
model = LiteLLMModel(
model_id="gemini/gemini-2.0-flash-exp",
max_tokens=2096,
temperature=0.6,
api_key=os.getenv("LITELLM_API_KEY")
)
import os
model = HfApiModel(
...
token=os.getenv('hf_token')
)
Define your secret hf_token in Settings of your space.
I FINALLY figured it out - this should have been explained in onboarding and not some silly stuff like how to install Discord, really
If your agent doesn't work at all like mine did (no response to chat input whatsoever), this is because the default LLM specified in the example is overloaded beyond any hope, probably by requests of your fellow course members. Do the following:
- Click on your avatar and choose Access Tokens from the drop-down menu
- Create New Token - select Read - Create Token, then copy the long token you are shown
- Go to the settings of YOUR space where your cloned agent is and scroll down to find Variables and secrets - click New Secret on the right
- Enter hf_token for the title then paste your long token in the value field, Save
- Go to your app.py and change the overloaded default LLM with another (look for the line starting with model_id), I used
model_id='Qwen/Qwen2.5-Coder-32B-Instruct', - Finally, add this line after the model_id line
token=os.getenv('hf_token'),
This should give you access as a legitimate user, enabling you to finally run your agent and try what the lesson was all about - customizing the agent, not getting it to work at all in the first place.