This change stopped the Runtime error for me, although getting a 504 when calling the Llama model.

#2
by meg HF staff - opened
Files changed (1) hide show
  1. run.py +6 -2
run.py CHANGED
@@ -1,12 +1,16 @@
1
  import gradio as gr
2
  from gradio import ChatMessage
3
- from transformers import load_tool, ReactCodeAgent, HfEngine # type: ignore
4
  from utils import stream_from_transformers_agent
 
 
 
5
 
6
  # Import tool from Hub
7
  image_generation_tool = load_tool("m-ric/text-to-image")
8
 
9
- llm_engine = HfEngine("meta-llama/Meta-Llama-3-70B-Instruct")
 
10
  # Initialize the agent with both tools
11
  agent = ReactCodeAgent(tools=[image_generation_tool], llm_engine=llm_engine)
12
 
 
1
  import gradio as gr
2
  from gradio import ChatMessage
3
+ from transformers import load_tool, ReactCodeAgent, HfApiEngine # type: ignore
4
  from utils import stream_from_transformers_agent
5
+ import os
6
+
7
+ HF_TOKEN = os.environ.get("HF_TOKEN")
8
 
9
  # Import tool from Hub
10
  image_generation_tool = load_tool("m-ric/text-to-image")
11
 
12
+ llm_engine = HfApiEngine(model="meta-llama/Meta-Llama-3-70B-Instruct", token=HF_TOKEN)
13
+
14
  # Initialize the agent with both tools
15
  agent = ReactCodeAgent(tools=[image_generation_tool], llm_engine=llm_engine)
16