Update app.py
Browse files
app.py
CHANGED
@@ -23,8 +23,8 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, Agent, LocalAgent
|
|
23 |
# print(agent.run("Is the following `text` (in Spanish) positive or negative?", text="¡Este es un API muy agradable!"))
|
24 |
|
25 |
# Load tools
|
26 |
-
controlnet_transformer = load_tool("
|
27 |
-
upscaler = load_tool("
|
28 |
|
29 |
|
30 |
tools = [controlnet_transformer, upscaler]
|
@@ -55,7 +55,7 @@ class CustomHfAgent(Agent):
|
|
55 |
return self._generate_one(prompt)
|
56 |
elif response.status_code != 200:
|
57 |
raise ValueError(f"Errors {inputs} {response.status_code}: {response.json()}")
|
58 |
-
|
59 |
result = response.json()[0]["generated_text"]
|
60 |
# Inference API returns the stop sequence
|
61 |
for stop_seq in stop:
|
@@ -71,8 +71,8 @@ message = st.text_input("Enter your message:", "")
|
|
71 |
|
72 |
# Checkboxes for the tools to be used by the agent
|
73 |
|
74 |
-
|
75 |
-
tool_checkboxes = [st.checkbox(f"Use {tool}") for tool in tools]
|
76 |
|
77 |
# Submit button
|
78 |
#submit_button = st.button("Submit")
|
@@ -94,7 +94,7 @@ def handle_submission():
|
|
94 |
|
95 |
# Run the agent with the user's message and selected tools
|
96 |
#response = agent.run(message, tools=selected_tools)
|
97 |
-
response = agent.
|
98 |
|
99 |
print(response)
|
100 |
|
@@ -120,7 +120,9 @@ def handle_submission():
|
|
120 |
# ...
|
121 |
|
122 |
# Display the agent's response
|
123 |
-
if
|
|
|
|
|
124 |
# Display the image response
|
125 |
st.image(response)
|
126 |
elif "audio" in response:
|
|
|
23 |
# print(agent.run("Is the following `text` (in Spanish) positive or negative?", text="¡Este es un API muy agradable!"))
|
24 |
|
25 |
# Load tools
|
26 |
+
controlnet_transformer = load_tool("Chris4K/random-character-tool")
|
27 |
+
upscaler = load_tool("Chris4K/text-generation-tool")
|
28 |
|
29 |
|
30 |
tools = [controlnet_transformer, upscaler]
|
|
|
55 |
return self._generate_one(prompt)
|
56 |
elif response.status_code != 200:
|
57 |
raise ValueError(f"Errors {inputs} {response.status_code}: {response.json()}")
|
58 |
+
print(response)
|
59 |
result = response.json()[0]["generated_text"]
|
60 |
# Inference API returns the stop sequence
|
61 |
for stop_seq in stop:
|
|
|
71 |
|
72 |
# Checkboxes for the tools to be used by the agent
|
73 |
|
74 |
+
|
75 |
+
tool_checkboxes = [st.checkbox(f"Use {tool.name} --- {tool.description} ") for tool in tools]
|
76 |
|
77 |
# Submit button
|
78 |
#submit_button = st.button("Submit")
|
|
|
94 |
|
95 |
# Run the agent with the user's message and selected tools
|
96 |
#response = agent.run(message, tools=selected_tools)
|
97 |
+
response = agent.chat(message)
|
98 |
|
99 |
print(response)
|
100 |
|
|
|
120 |
# ...
|
121 |
|
122 |
# Display the agent's response
|
123 |
+
if response is None:
|
124 |
+
st.warning("The agent's response is None.")
|
125 |
+
elif isinstance(response, Image.Image):
|
126 |
# Display the image response
|
127 |
st.image(response)
|
128 |
elif "audio" in response:
|