Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -474,17 +474,67 @@ def _load_excel_as_text2(file_name: str) -> str:
|
|
474 |
full_url = f"{base_url}/{commit_hash}/2023/validation/{file_name}"
|
475 |
'''
|
476 |
|
477 |
-
DOMANDE_MOCKATE = True
|
478 |
-
def create_mock_questions():
|
479 |
|
480 |
-
|
481 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
"task_id":"cca530fc-4052-43b2-b130-b30968d8aa44",
|
483 |
"question":"Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.",
|
484 |
"Level":"1",
|
485 |
"file_name":"cca530fc-4052-43b2-b130-b30968d8aa44.png"
|
486 |
},
|
487 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
{'task_id': '8e867cd7-cff9-4e6c-867a-ff5ddc2550be',
|
489 |
'question': 'How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.',
|
490 |
'Level': '1',
|
@@ -509,58 +559,10 @@ def create_mock_questions():
|
|
509 |
}
|
510 |
]
|
511 |
|
512 |
-
def process_questions(serviceList
|
513 |
# 1. Rimuovi dalla serviceList tutte le domande i cui task_id sono in blackList
|
514 |
|
515 |
-
whiteList = [
|
516 |
-
{
|
517 |
-
'task_id': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3',
|
518 |
-
'question': 'Hi, I\'m making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I\'m not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can\'t quite make out what she\'s saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I\'ve attached the recipe as Strawberry pie.mp3.\n\nIn your response, please only list the ingredients, not any measurements. So if the recipe calls for "a pinch of salt" or "two cups of ripe strawberries" the ingredients on the list would be "salt" and "ripe strawberries".\n\nPlease format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.',
|
519 |
-
'Level': '1',
|
520 |
-
'file_name': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3'
|
521 |
-
},
|
522 |
-
{
|
523 |
-
"task_id":"f918266a-b3e0-4914-865d-4faa564f1aef",
|
524 |
-
"question":"What is the final numeric output from the attached Python code?",
|
525 |
-
"Level":"1",
|
526 |
-
"file_name":"f918266a-b3e0-4914-865d-4faa564f1aef.py"
|
527 |
-
},
|
528 |
-
{
|
529 |
-
"task_id":"7bd855d8-463d-4ed5-93ca-5fe35145f733",
|
530 |
-
"question":"The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.",
|
531 |
-
"Level":"1",
|
532 |
-
"file_name":"7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx"
|
533 |
-
},
|
534 |
-
{
|
535 |
-
"task_id":"1f975693-876d-457b-a649-393859e79bf3",
|
536 |
-
"question":"Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(\n\nCould you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.",
|
537 |
-
"Level":"1",
|
538 |
-
"file_name":"1f975693-876d-457b-a649-393859e79bf3.mp3"
|
539 |
-
},
|
540 |
-
{
|
541 |
-
"task_id":"4fc2f1ae-8625-45b5-ab34-ad4433bc21f8",
|
542 |
-
"question":"Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?",
|
543 |
-
"Level":"1",
|
544 |
-
"file_name":""
|
545 |
-
},
|
546 |
-
{
|
547 |
-
"task_id":"2d83110e-a098-4ebb-9987-066c06fa42d0",
|
548 |
-
"question":".rewsna eht sa \"tfel\" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI",
|
549 |
-
"Level":"1",
|
550 |
-
"file_name":""
|
551 |
-
}
|
552 |
-
]
|
553 |
|
554 |
-
blackList = [
|
555 |
-
{
|
556 |
-
"task_id":"cca530fc-4052-43b2-b130-b30968d8aa44",
|
557 |
-
"question":"Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.",
|
558 |
-
"Level":"1",
|
559 |
-
"file_name":"cca530fc-4052-43b2-b130-b30968d8aa44.png"
|
560 |
-
},
|
561 |
-
|
562 |
-
|
563 |
-
]
|
564 |
|
565 |
|
566 |
initial_len = len(serviceList)
|
@@ -595,6 +597,22 @@ def process_questions(serviceList, whiteList, blackList):
|
|
595 |
# 7. Ritorna la lista risultante
|
596 |
return serviceList
|
597 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
|
599 |
#Tools
|
600 |
|
|
|
474 |
full_url = f"{base_url}/{commit_hash}/2023/validation/{file_name}"
|
475 |
'''
|
476 |
|
|
|
|
|
477 |
|
478 |
+
|
479 |
+
whiteList = [
|
480 |
+
{
|
481 |
+
'task_id': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3',
|
482 |
+
'question': 'Hi, I\'m making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I\'m not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can\'t quite make out what she\'s saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I\'ve attached the recipe as Strawberry pie.mp3.\n\nIn your response, please only list the ingredients, not any measurements. So if the recipe calls for "a pinch of salt" or "two cups of ripe strawberries" the ingredients on the list would be "salt" and "ripe strawberries".\n\nPlease format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.',
|
483 |
+
'Level': '1',
|
484 |
+
'file_name': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3'
|
485 |
+
},
|
486 |
+
{
|
487 |
+
"task_id":"f918266a-b3e0-4914-865d-4faa564f1aef",
|
488 |
+
"question":"What is the final numeric output from the attached Python code?",
|
489 |
+
"Level":"1",
|
490 |
+
"file_name":"f918266a-b3e0-4914-865d-4faa564f1aef.py"
|
491 |
+
},
|
492 |
+
{
|
493 |
+
"task_id":"7bd855d8-463d-4ed5-93ca-5fe35145f733",
|
494 |
+
"question":"The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.",
|
495 |
+
"Level":"1",
|
496 |
+
"file_name":"7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx"
|
497 |
+
},
|
498 |
+
{
|
499 |
+
"task_id":"1f975693-876d-457b-a649-393859e79bf3",
|
500 |
+
"question":"Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(\n\nCould you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.",
|
501 |
+
"Level":"1",
|
502 |
+
"file_name":"1f975693-876d-457b-a649-393859e79bf3.mp3"
|
503 |
+
},
|
504 |
+
{
|
505 |
+
"task_id":"4fc2f1ae-8625-45b5-ab34-ad4433bc21f8",
|
506 |
+
"question":"Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?",
|
507 |
+
"Level":"1",
|
508 |
+
"file_name":""
|
509 |
+
},
|
510 |
+
{
|
511 |
+
"task_id":"2d83110e-a098-4ebb-9987-066c06fa42d0",
|
512 |
+
"question":".rewsna eht sa \"tfel\" drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI",
|
513 |
+
"Level":"1",
|
514 |
+
"file_name":""
|
515 |
+
}
|
516 |
+
]
|
517 |
+
|
518 |
+
blackList = [
|
519 |
+
{
|
520 |
"task_id":"cca530fc-4052-43b2-b130-b30968d8aa44",
|
521 |
"question":"Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.",
|
522 |
"Level":"1",
|
523 |
"file_name":"cca530fc-4052-43b2-b130-b30968d8aa44.png"
|
524 |
},
|
525 |
|
526 |
+
|
527 |
+
]
|
528 |
+
|
529 |
+
|
530 |
+
|
531 |
+
|
532 |
+
DOMANDE_MOCKATE = True
|
533 |
+
def create_mock_questions():
|
534 |
+
|
535 |
+
'''
|
536 |
+
|
537 |
+
|
538 |
{'task_id': '8e867cd7-cff9-4e6c-867a-ff5ddc2550be',
|
539 |
'question': 'How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.',
|
540 |
'Level': '1',
|
|
|
559 |
}
|
560 |
]
|
561 |
|
562 |
+
def process_questions(serviceList):
|
563 |
# 1. Rimuovi dalla serviceList tutte le domande i cui task_id sono in blackList
|
564 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
565 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
566 |
|
567 |
|
568 |
initial_len = len(serviceList)
|
|
|
597 |
# 7. Ritorna la lista risultante
|
598 |
return serviceList
|
599 |
|
600 |
+
|
601 |
+
def generate_tool_descriptions(tools):
|
602 |
+
lines = []
|
603 |
+
for tool in tools:
|
604 |
+
name = tool.metadata.name
|
605 |
+
desc = tool.metadata.description
|
606 |
+
inputs = tool.metadata.fn.__annotations__
|
607 |
+
return_type = inputs.get('return', 'unknown')
|
608 |
+
|
609 |
+
arg_list = [
|
610 |
+
f"{k}: {v.__name__ if hasattr(v, '__name__') else str(v)}"
|
611 |
+
for k, v in inputs.items() if k != "return"
|
612 |
+
]
|
613 |
+
inputs_str = ", ".join(arg_list)
|
614 |
+
lines.append(f"- {name}: {desc}\n Takes inputs: {inputs_str}\n Returns an output of type: {return_type}")
|
615 |
+
return "\n".join(lines)
|
616 |
|
617 |
#Tools
|
618 |
|