Update handler.py
Browse files- handler.py +99 -1
handler.py
CHANGED
|
@@ -311,7 +311,105 @@ class EndpointHandler:
|
|
| 311 |
do_sample = parameters.get("do_sample", temperature > 0.1)
|
| 312 |
stream = parameters.get("stream", False)
|
| 313 |
json_mode = parameters.get("json_mode", False)
|
| 314 |
-
system_prompt =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
| 316 |
# Check if input is in various formats and normalize to messages format
|
| 317 |
if isinstance(inputs, str):
|
|
|
|
| 311 |
do_sample = parameters.get("do_sample", temperature > 0.1)
|
| 312 |
stream = parameters.get("stream", False)
|
| 313 |
json_mode = parameters.get("json_mode", False)
|
| 314 |
+
system_prompt = """
|
| 315 |
+
<|begin_of_text|><|start_header_id|>system<|end_header_id|>
|
| 316 |
+
|
| 317 |
+
Cutting Knowledge Date: December 2023
|
| 318 |
+
Today Date: 16 March 2025
|
| 319 |
+
|
| 320 |
+
When you receive a tool call response, use the output to format an answer to the orginal user question.
|
| 321 |
+
|
| 322 |
+
You are a helpful assistant with tool calling capabilities.<|eot_id|><|start_header_id|>user<|end_header_id|>
|
| 323 |
+
|
| 324 |
+
Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.
|
| 325 |
+
|
| 326 |
+
Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. Do not use variables.
|
| 327 |
+
{
|
| 328 |
+
"type": "function",
|
| 329 |
+
"function": {
|
| 330 |
+
"name": "llm",
|
| 331 |
+
"description": "Access your internal knowledge as an LLM to provide general information, explanations, and guidance without searching the web.",
|
| 332 |
+
},
|
| 333 |
+
|
| 334 |
+
"type": "function",
|
| 335 |
+
"function": {
|
| 336 |
+
"name": "search_web",
|
| 337 |
+
"description": "Fetch up-to-date, specific, or contextual information that may not be stable or broadly known.",
|
| 338 |
+
"arguments": {
|
| 339 |
+
"type": "object",
|
| 340 |
+
"properties": {
|
| 341 |
+
"query": {
|
| 342 |
+
"type": "string",
|
| 343 |
+
"description": "A search query used to find relevant information on the web"
|
| 344 |
+
},
|
| 345 |
+
"required": ["query"]
|
| 346 |
+
}
|
| 347 |
+
},
|
| 348 |
+
|
| 349 |
+
"type": "function",
|
| 350 |
+
"function": {
|
| 351 |
+
"name": "calculate",
|
| 352 |
+
"description": "used for precise mathematical computations",
|
| 353 |
+
"arguments": {
|
| 354 |
+
"type": "object",
|
| 355 |
+
"properties": {
|
| 356 |
+
"expression": {
|
| 357 |
+
"type": "string",
|
| 358 |
+
"description": "An executable mathmatical javascript expression"
|
| 359 |
+
},
|
| 360 |
+
"required": ["expression"]
|
| 361 |
+
}
|
| 362 |
+
},
|
| 363 |
+
|
| 364 |
+
"type": "function",
|
| 365 |
+
"function": {
|
| 366 |
+
"name": "open_url",
|
| 367 |
+
"description": "Opens or shows a website to the user with the specified URL",
|
| 368 |
+
"arguments": {
|
| 369 |
+
"type": "object",
|
| 370 |
+
"properties": {
|
| 371 |
+
"url": {
|
| 372 |
+
"type": "string",
|
| 373 |
+
"description": "The URL of the website to open or show to the user"
|
| 374 |
+
},
|
| 375 |
+
"required": ["url"]
|
| 376 |
+
}
|
| 377 |
+
},
|
| 378 |
+
|
| 379 |
+
"type": "function",
|
| 380 |
+
"function": {
|
| 381 |
+
"name": "fetch_web_content",
|
| 382 |
+
"description": "The URL or webiste of the content to fetch, get, summarize, or analyze"
|
| 383 |
+
"arguments": {
|
| 384 |
+
"type": "object",
|
| 385 |
+
"properties": {
|
| 386 |
+
"url": {
|
| 387 |
+
"type": "string",
|
| 388 |
+
"description": "The URL of the content to fetch, get, summarize, or analyze"
|
| 389 |
+
},
|
| 390 |
+
"required": ["url"]
|
| 391 |
+
}
|
| 392 |
+
},
|
| 393 |
+
|
| 394 |
+
"type": "function",
|
| 395 |
+
"function": {
|
| 396 |
+
"name": "unsupported_capability",
|
| 397 |
+
"description": "Use this function to indicate that the requested action is not supported or not possible.",
|
| 398 |
+
"arguments": {
|
| 399 |
+
"type": "object",
|
| 400 |
+
"properties": {
|
| 401 |
+
"capability": {
|
| 402 |
+
"type": "string",
|
| 403 |
+
"description": "The capability requested by the user that is not supported"
|
| 404 |
+
},
|
| 405 |
+
"required": ["capability"]
|
| 406 |
+
}
|
| 407 |
+
},
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
Question:
|
| 411 |
+
|
| 412 |
+
"""
|
| 413 |
|
| 414 |
# Check if input is in various formats and normalize to messages format
|
| 415 |
if isinstance(inputs, str):
|