Upload app.py
Browse files
app.py
CHANGED
@@ -38,15 +38,19 @@ final_answer = FinalAnswerTool()
|
|
38 |
|
39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
model = HfApiModel(
|
43 |
-
max_tokens=
|
44 |
-
temperature=0.5,
|
45 |
-
model_id='Qwen/Qwen2.5-Coder-32B-Instruct'
|
46 |
-
custom_role_conversions=None,
|
47 |
)
|
48 |
|
49 |
-
|
50 |
# Import tool from Hub
|
51 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
52 |
|
|
|
38 |
|
39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
41 |
+
MAX_ALLOWED_TOKENS = 16000 # Model limit
|
42 |
+
|
43 |
+
def get_safe_max_tokens(input_tokens, default_max_tokens=1200):
|
44 |
+
remaining = MAX_ALLOWED_TOKENS - input_tokens
|
45 |
+
return min(remaining, default_max_tokens) if remaining > 0 else 100 # Set minimum fallback
|
46 |
|
47 |
model = HfApiModel(
|
48 |
+
max_tokens=get_safe_max_tokens(14186), # Dynamic adjustment
|
49 |
+
temperature=0.5,
|
50 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
51 |
+
custom_role_conversions=None,
|
52 |
)
|
53 |
|
|
|
54 |
# Import tool from Hub
|
55 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
56 |
|