Chris4K commited on
Commit
11e5281
·
verified ·
1 Parent(s): fd41e8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -100,13 +100,7 @@ class CustomHfAgent(Agent):
100
 
101
  st.title("Hugging Face Agent and tools")
102
 
103
- # Initialize the agent
104
- agent = CustomHfAgent(
105
- url_endpoint="https://api-inference.huggingface.co/models/bigcode/starcoder",
106
- token=os.environ['HF_token'],
107
- additional_tools=[],
108
- input_params={"max_new_tokens": 192},
109
- )
110
 
111
  # Display a welcome message
112
  with st.chat_message("assistant"):
@@ -124,9 +118,17 @@ submit_button = st.button("Submit")
124
  # Define the callback function to handle the form submission
125
  def handle_submission():
126
  selected_tools = [tools[idx] for idx, checkbox in enumerate(tool_checkboxes) if checkbox]
127
- agent.tools = selected_tools
128
-
129
- response = agent.chat(user_message)
 
 
 
 
 
 
 
 
130
 
131
  print("Agent Response\n {}".format(response))
132
 
 
100
 
101
  st.title("Hugging Face Agent and tools")
102
 
103
+
 
 
 
 
 
 
104
 
105
  # Display a welcome message
106
  with st.chat_message("assistant"):
 
118
  # Define the callback function to handle the form submission
119
  def handle_submission():
120
  selected_tools = [tools[idx] for idx, checkbox in enumerate(tool_checkboxes) if checkbox]
121
+
122
+ # Initialize the agent
123
+ agent = CustomHfAgent(
124
+ url_endpoint="https://api-inference.huggingface.co/models/bigcode/starcoder",
125
+ token=os.environ['HF_token'],
126
+ additional_tools=selected_tools,
127
+ input_params={"max_new_tokens": 192},
128
+ )
129
+ #agent.tools = selected_tools
130
+
131
+ response = agent.run(user_message)
132
 
133
  print("Agent Response\n {}".format(response))
134