Further clean up + extending the max_steps now that is seems to be working again.
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ from Gradio_UI import GradioUI
|
|
10 |
|
11 |
verbose = True
|
12 |
|
13 |
-
if verbose: print("Running app.py
|
14 |
|
15 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
16 |
@tool
|
@@ -82,10 +82,8 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
82 |
|
83 |
final_answer = FinalAnswerTool()
|
84 |
|
85 |
-
if verbose: print("Defining MODEL_IDS.\n")
|
86 |
-
|
87 |
MODEL_IDS = [
|
88 |
-
'https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud/',
|
89 |
'https://jc26mwg228mkj8dw.us-east-1.aws.endpoints.huggingface.cloud/',
|
90 |
'meta-llama/Llama-3.2-1B-Instruct',
|
91 |
'Qwen/Qwen2.5-Coder-32B-Instruct',
|
@@ -97,6 +95,8 @@ def is_model_overloaded(model_url):
|
|
97 |
"""Verify if the model is overloaded doing a test call."""
|
98 |
try:
|
99 |
response = requests.post(model_url, json={"inputs": "Test"})
|
|
|
|
|
100 |
if response.status_code == 503: # 503 Service Unavailable = Overloaded
|
101 |
return True
|
102 |
if response.status_code == 404: # 404 Client Error: Not Found
|
@@ -108,12 +108,12 @@ def is_model_overloaded(model_url):
|
|
108 |
def get_available_model():
|
109 |
"""Select the first model available from the list."""
|
110 |
for model_url in MODEL_IDS:
|
111 |
-
print("
|
112 |
if not is_model_overloaded(model_url):
|
113 |
return model_url
|
114 |
return MODEL_IDS[0] # if all are failing, use the first model by dfault
|
115 |
|
116 |
-
if verbose: print("Checking available models
|
117 |
|
118 |
selected_model_id = get_available_model()
|
119 |
|
@@ -136,7 +136,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
136 |
agent = CodeAgent(
|
137 |
model=model,
|
138 |
tools=[final_answer, get_current_time_in_timezone, image_generation_tool, toss_a_die, nse_stock_price_tool], ## add your tools here (don't remove final answer)
|
139 |
-
max_steps=
|
140 |
verbosity_level=1,
|
141 |
grammar=None,
|
142 |
planning_interval=None,
|
|
|
10 |
|
11 |
verbose = True
|
12 |
|
13 |
+
if verbose: print("Running app.py")
|
14 |
|
15 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
16 |
@tool
|
|
|
82 |
|
83 |
final_answer = FinalAnswerTool()
|
84 |
|
|
|
|
|
85 |
MODEL_IDS = [
|
86 |
+
#'https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud/',
|
87 |
'https://jc26mwg228mkj8dw.us-east-1.aws.endpoints.huggingface.cloud/',
|
88 |
'meta-llama/Llama-3.2-1B-Instruct',
|
89 |
'Qwen/Qwen2.5-Coder-32B-Instruct',
|
|
|
95 |
"""Verify if the model is overloaded doing a test call."""
|
96 |
try:
|
97 |
response = requests.post(model_url, json={"inputs": "Test"})
|
98 |
+
if verbose:
|
99 |
+
print(response.status_code)
|
100 |
if response.status_code == 503: # 503 Service Unavailable = Overloaded
|
101 |
return True
|
102 |
if response.status_code == 404: # 404 Client Error: Not Found
|
|
|
108 |
def get_available_model():
|
109 |
"""Select the first model available from the list."""
|
110 |
for model_url in MODEL_IDS:
|
111 |
+
print("trying",model_url)
|
112 |
if not is_model_overloaded(model_url):
|
113 |
return model_url
|
114 |
return MODEL_IDS[0] # if all are failing, use the first model by dfault
|
115 |
|
116 |
+
if verbose: print("Checking available models.")
|
117 |
|
118 |
selected_model_id = get_available_model()
|
119 |
|
|
|
136 |
agent = CodeAgent(
|
137 |
model=model,
|
138 |
tools=[final_answer, get_current_time_in_timezone, image_generation_tool, toss_a_die, nse_stock_price_tool], ## add your tools here (don't remove final answer)
|
139 |
+
max_steps=6,
|
140 |
verbosity_level=1,
|
141 |
grammar=None,
|
142 |
planning_interval=None,
|