Spaces:
Running
Running
Huanzhi (Hans) Mao
commited on
Commit
•
4d1746c
1
Parent(s):
43a1ab6
init
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- BFCL_v3_multi_turn_base.json +0 -0
- BFCL_v3_multi_turn_base_sol.json +200 -0
- README.md +5 -5
- api_info.csv +1369 -0
- app.py +469 -0
- backend.py +8 -0
- base_handler.py +445 -0
- claude.py +219 -0
- config/gorilla_file_system.json +18 -0
- config/math_api.json +17 -0
- config/message_api.json +10 -0
- config/posting_api.json +14 -0
- config/ticket_api.json +9 -0
- config/trading_bot.json +22 -0
- config/travel_booking.json +17 -0
- config/vehicle_control.json +22 -0
- constant.py +154 -0
- db.py +13 -0
- eval_runner_helper.py +127 -0
- flagged/log.csv +2 -0
- info_table.py +42 -0
- model_style.py +14 -0
- multi_turn_eval/.DS_Store +0 -0
- multi_turn_eval/func_source_code/__pycache__/__init__.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/__init__.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/gorilla_file_system.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/gorilla_file_system.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/long_context.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/long_context.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/math_api.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/math_api.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/message_api.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/message_api.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/posting_api.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/posting_api.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/ticket_api.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/ticket_api.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/trading_bot.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/trading_bot.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/travel_booking.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/travel_booking.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/vehicle_control.cpython-311.pyc +0 -0
- multi_turn_eval/func_source_code/__pycache__/vehicle_control.cpython-312.pyc +0 -0
- multi_turn_eval/func_source_code/gorilla_file_system.py +811 -0
- multi_turn_eval/func_source_code/long_context.py +0 -0
- multi_turn_eval/func_source_code/math_api.py +373 -0
- multi_turn_eval/func_source_code/message_api.py +321 -0
- multi_turn_eval/func_source_code/posting_api.py +313 -0
- multi_turn_eval/func_source_code/ticket_api.py +265 -0
- multi_turn_eval/func_source_code/trading_bot.py +734 -0
BFCL_v3_multi_turn_base.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
BFCL_v3_multi_turn_base_sol.json
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"id": "multi_turn_base_0", "ground_truth": [["cd(folder='document')", "mkdir(dir_name='temp')", "mv(source='final_report.pdf', destination='temp')"], ["cd(folder='temp')", "grep(file_name='final_report.pdf',pattern='budget analysis')"], ["sort('final_report.pdf')"], ["cd(folder='..')", "mv(source='previous_report.pdf',destination='temp')", "cd(folder='temp')", "diff(file_name1='final_report.pdf',file_name2='previous_report.pdf')"]]}
|
2 |
+
{"id": "multi_turn_base_1", "ground_truth": [["ls(a=True)"], ["cd(folder='workspace')", "mv(source='log.txt',destination='archive')"], ["cd(folder='archive')", "grep(file_name='log.txt',pattern='Error')"], ["tail(file_name='log.txt',lines=20)"]]}
|
3 |
+
{"id": "multi_turn_base_2", "ground_truth": [["cd(folder='documents')", "touch(file_name='TeamNotes.txt')"], ["echo(content='Collaboration leads to success. Innovation ignites growth.',file_name='TeamNotes.txt')"], ["diff(file_name1='ideas.txt', file_name2='TeamNotes.txt')"], ["cp(source='TeamNotes.txt',destination='Archived')", "cd(folder='Archived')", "mv(source='TeamNotes.txt',destination='IdeasArchive.txt')"], ["cat(file_name='IdeasArchive.txt')"]]}
|
4 |
+
{"id": "multi_turn_base_3", "ground_truth": [["find(path='.',name='test')"], ["cd(folder='projects')","cd(folder='photography')","cp(source='test_image1.jpg',destination='backup_tests')", "cp(source='test_document.txt',destination='backup_tests')"]]}
|
5 |
+
{"id": "multi_turn_base_4", "ground_truth": [["ls(a=True)"], ["sort(file_name='report.txt')"], ["post_tweet(content='Initial report content More unsorted data Unsorted data', mentions=['@Julia'], tags=['#currenttechtrend'])"]]}
|
6 |
+
{"id": "multi_turn_base_5", "ground_truth": [["cd(folder='project')", "mv(source='analysis_report.csv',destination='archive')"], ["cat(file_name='archive_summary.txt')", "sort(file_name='archive_summary.txt')"], ["authenticate_twitter(username='dr_smith', password='securePass123')", "post_tweet(content='Managed to archive important data files!',tags=['#DataManagement','#Efficiency'])"], ["comment(tweet_id=0,comment_content='Another successful task completed today!')"]]}
|
7 |
+
{"id": "multi_turn_base_6", "ground_truth": [["cd(folder='communal')", "touch(file_name='Annual_Report_2023.docx')"], ["echo(content='Company Earning: 2000 Company Expenditure: 500 Company Name: Gorilla',file_name='Annual_Report_2023.docx')"], ["cat(file_name='Annual_Report_2023.docx')"], ["wc(file_name='Annual_Report_2023.docx',mode='w')"], ["cd(folder='..')", "cd(folder='shared')", "echo(content='9',file_name='report_word_count')"]]}
|
8 |
+
{"id": "multi_turn_base_7", "ground_truth": [["cd(folder='academic_venture')", "mkdir(dir_name='academic_hub')"], ["find(path='.',name='goal')"], ["cat(file_name='goals.txt')"]]}
|
9 |
+
{"id": "multi_turn_base_8", "ground_truth": [["grep(file_name='experiment_log.txt',pattern='Anomaly')"], ["diff(file_name1='experiment_log.txt', file_name2='previous_study_log.txt')"], ["authenticate_twitter(username='dr_smith', password='securePass123')", "post_tweet(content='- Research topic selection+ Data analysis- Literature review+ Data collection- Data collection+ Draft writing- Data analysis+ Final submission- Draft writing+ Literature review- Final submission+ Research topic selection')"], ["comment(tweet_id=1,comment_content='Cheers!')"]]}
|
10 |
+
{"id": "multi_turn_base_9", "ground_truth": [["cd(folder='Documentation')"], ["cp(source='FinalReport.txt',destination='Archives')", "cd(folder='Archives')", "mv(source='FinalReport.txt',destination='ArchivedFinalReport2024.txt')"], ["sort(file_name='ArchivedFinalReport2024.txt')"]]}
|
11 |
+
{"id": "multi_turn_base_10", "ground_truth": [["cd(folder='workspace')", "mkdir(dir_name='Projects')"], ["mv(source='proposal.docx',destination='Projects')", "cd(folder='Projects')", "mv(source='proposal.docx',destination='final_proposal_2024')"], ["touch(file_name='note.md')"], ["touch(file_name='summary.txt')", "echo(content='Hello',file_name='summary.txt')", "diff(file_name1='note.md',file_name2='summary.txt')"], ["wc(file_name='summary.txt',mode='c')"]]}
|
12 |
+
{"id": "multi_turn_base_11", "ground_truth": [["ls(a=True)"], ["post_tweet(content='file1.txt, file2.txt',tags=['#fileshowcase'])"]]}
|
13 |
+
{"id": "multi_turn_base_12", "ground_truth": [["cd(folder='Documents')", "touch(file_name='summary.txt')"], ["echo(content='quantum computing',file_name='summary.txt')"], ["wc(file_name='summary.txt',mode='w')"]]}
|
14 |
+
{"id": "multi_turn_base_13", "ground_truth": [["cd(folder='documents')", "tail(file_name='report.txt',lines=1)"], ["diff(file_name1='report.txt',file_name2='summary.txt')"]]}
|
15 |
+
{"id": "multi_turn_base_14", "ground_truth": [["cd(folder='ResearchDocs')", "find(path='.',name='report.csv')"], ["grep(file_name='report.csv',pattern='Quarterly Financial Overview')"], ["tail(file_name='report.csv',lines=5)"], ["message_login(user_id='USR001')", "add_contact(user_name='John Levy')", "send_message(receiver_id='USR005',message='Latest Quarter Performance has been well.')"]]}
|
16 |
+
{"id": "multi_turn_base_15", "ground_truth": [["touch(file_name='DataSet1.csv')"], ["echo(content='Student | Math | Computer Science\\nAlice | 5 | 9\\nBob | 10 | 7',file_name='DataSet1.csv')"], ["tail(file_name='DataSet1.csv',lines=1)"], ["wc(file_name='DataSet1.csv',mode='l')", "wc(file_name='DataSet1.csv',mode='w')", "wc(file_name='DataSet1.csv',mode='c')"], ["mean(numbers=[3,16,60])"]]}
|
17 |
+
{"id": "multi_turn_base_16", "ground_truth": [["cd(folder='research')", "cp(source='research_notes.txt',destination='archives')", "cd(folder='archives')", "mv(source='research_notes.txt',destination='2024_research_backup.txt')"], ["sort(file_name='2024_research_backup.txt')"], ["wc(file_name='2024_research_backup.txt',mode='l')"]]}
|
18 |
+
{"id": "multi_turn_base_17", "ground_truth": [["ls(a=True)"], ["cd(folder='project')", "cat(file_name='test_report.docx')"], ["add_contact(user_name='Kelly')", "send_message(receiver_id='USR005',message='Kelly Total Score: 96')", "view_messages_sent()"]]}
|
19 |
+
{"id": "multi_turn_base_18", "ground_truth": [["mkdir(dir_name='Archived_Quarter1')", "cp(source='report1.txt',destination='Archived_Quarter1')", "cp(source='report2.txt',destination='Archived_Quarter1')", "cp(source='History101.txt',destination='Archived_Quarter1')", "cp(source='History202.txt',destination='Archived_Quarter1')"], ["cat(file_name='MonthlySummary.docx')", "sort(file_name='MonthlySummary.docx')"], ["diff(file_name1='History101.txt',file_name2='History202.txt')", "post_tweet(content='- Introduction to History. Ancient civilizations.+ Advanced History. Modern world events.',mentions=['Jerry'])"]]}
|
20 |
+
{"id": "multi_turn_base_19", "ground_truth": [["find(path='.',name='test_document.txt')"], ["cp(source='test_document.txt',destination='archives')", "cd(folder='archives')", "mv(source='test_document.txt',destination='final_document.txt')"], ["cat(file_name='final_document.txt')"]]}
|
21 |
+
{"id": "multi_turn_base_20", "ground_truth": [["cd(folder='documents')", "tail(file_name='file1.txt',lines=1)"], ["diff(file_name1='file1.txt',file_name2='file2.txt')", "echo(content='- The quick brown fox jumps over the lazy dog.\\n+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.',file_name='file5.txt')"]]}
|
22 |
+
{"id": "multi_turn_base_21", "ground_truth": [["echo(content='To be discussed',file_name='ProjectOverview.txt')"], ["diff(file_name1='ProjectOverview.txt',file_name2='Draft.txt')"], ["authenticate_twitter(username='tech_guru', password='securePass123')", "post_tweet(content='Initial summary of the project. To be discussed', tags=['#ProjectUpdate'],mentions=['@manager','@team_lead'])"]]}
|
23 |
+
{"id": "multi_turn_base_22", "ground_truth": [["cd(folder='workspace')", "cat(file_name='project_analysis.txt')"], ["cp(source='project_analysis.txt', destination='project_archive')"], ["diff(file_name1='project_analysis.txt', file_name2='old_project_analysis.txt')"], ["authenticate_twitter(username='tech_guru', password='securePass123')", "post_tweet(content='Just completed a comparative analysis between the latest and previous project data. Some insightful findings!', tags=['#ProjectInsight'], mentions=['@colleagues'])"]]}
|
24 |
+
{"id": "multi_turn_base_23", "ground_truth": [["touch(file_name='Project_Guide_1.md')", "echo(content='Comprehensive guide for the new initiative.',file_name='Project_Guide_1.md')"], ["du(human_readable=True)"], ["resolve_ticket(ticket_id=7423,resolution='')"]]}
|
25 |
+
{"id": "multi_turn_base_24", "ground_truth": [["diff(file_name1='report_draft.txt', file_name2='report_final.txt')"], ["mv(source='temp_notes.txt', destination='archives')","cd('archives')","mv(source='temp_notes.txt',destination='notes_2024.txt')"], ["get_ticket(ticket_id=987654)"], ["resolve_ticket(ticket_id=987654, resolution='Fixed through manual troubleshooting techniques.')"]]}
|
26 |
+
{"id": "multi_turn_base_25", "ground_truth": [["cat(file_name='summary.txt')"], ["cp(source='summary.txt',destination='Research2023')"], ["cd(folder='Research2023')", "sort(file_name='summary.txt')"], ["wc(file_name='summary.txt',mode='l')"]]}
|
27 |
+
{"id": "multi_turn_base_26", "ground_truth": [["cd(folder='tmp')", "ls(a=True)"], ["cat(file_name='file3.txt')"], ["touch(file_name='file3.docx')", "echo(content='Nothing important here. Yet another line.',file_name='file3.docx')"]]}
|
28 |
+
{"id": "multi_turn_base_27", "ground_truth": [["cd(folder='workspace')", "mv(source='project_plan.md',destination='project_overview.md')"], ["ticket_login(username='tech_guru', password='securePass123')", "create_ticket(title='emergency',description='Initial project plan details.', priority=3)"], ["create_ticket(title='emergency',description='Additional insights.', priority=5)"]]}
|
29 |
+
{"id": "multi_turn_base_28", "ground_truth": [["find(path='.', name='analysis')"], ["cd(folder='data')", "grep(file_name='analysis_report.txt',pattern='error')"], ["du(human_readable=True)", "touch(file_name='usage.txt')", "echo(content='205 bytes',file_name='usage.txt')"]]}
|
30 |
+
{"id": "multi_turn_base_29", "ground_truth": [["cd(folder='VisionX')", "du(human_readable=True)"], ["touch(file_name='79.pdf')"], ["echo(content='Create a file name based on the number of byte used. It should be in \\'number.pdf\\' format.',file_name='79.pdf')"]]}
|
31 |
+
{"id": "multi_turn_base_30", "ground_truth": [["cd(folder='project')", "cat(file_name='test_results.json')"], ["post_tweet(content='{experiment: Apollo Test, result: Success, details: All systems operational.}')"]]}
|
32 |
+
{"id": "multi_turn_base_31", "ground_truth": [["mkdir(dir_name='Reports')", "mv(source='summary.doc', destination='Reports')", "cat(file_name='data.txt')", "grep(pattern='Q4 financials', file_name='data.txt')", "wc(file_name='data.txt',mode='l')"], ["cd('Reports')", "wc(file_name='summary.doc',mode='c')","mean([37])"]]}
|
33 |
+
{"id": "multi_turn_base_32", "ground_truth": [["cat(file_name='Spring2023Draft')", "wc(file_name='Spring2023Draft', mode='c')"], ["logarithm(value=36.0,base=6.0,precision=4)","touch('result.txt')", "echo(content='2.0',file_name='result.txt')"]]}
|
34 |
+
{"id": "multi_turn_base_33", "ground_truth": [["ls()"], ["grep(file_name='deploy.py', pattern='def')"], ["grep(file_name='deploy.py', pattern='update')"], ["send_message(receiver_id='USR003', message='update the system')"], ["view_messages_sent()"]]}
|
35 |
+
{"id": "multi_turn_base_34", "ground_truth": [["tail(file_name='finance_report.txt',lines=1)"], ["cat(file_name='finance_report.txt')", "mean(numbers=[5000,3000,2000])", "touch(file_name='statistics.txt')", "echo(content='3333',file_name='statistics.txt.')"]]}
|
36 |
+
{"id": "multi_turn_base_35", "ground_truth": [["cd(folder='projects')", "cd(folder='deep_folder')", "tail(file_name='config.py',lines=1)"], ["cat(file_name='real_config.py')"], ["diff(file_name1='config.py',file_name2='real_config.py')", "touch(file_name='diff.txt')", "echo(content='- Initialization of the system+ Real Config.',file_name='diff.txt')"]]}
|
37 |
+
{"id": "multi_turn_base_36", "ground_truth": [["cd(folder='documents')", "touch(file_name='project_summary.txt')"], ["cp(source='project_summary.txt', destination='archive')", "cd(folder='archive')", "mv(source='project_summary.txt', destination='summary_2024.txt')"], ["grep(file_name='summary_2024.txt',pattern='Progress')"]]}
|
38 |
+
{"id": "multi_turn_base_37", "ground_truth": [["wc(file_name='dev_summary.txt',mode='l')"], ["grep(file_name='dev_summary.txt',pattern='server error')"], ["touch(file_name='1.txt')", "echo(content='However, a server error was detected in the final testing phase.',file_name='1.txt')"]]}
|
39 |
+
{"id": "multi_turn_base_38", "ground_truth": [["cd(folder='SuperResearch')", "rm(file_name='findings_report')", "cd(folder='..')", "rmdir(dir_name='SuperResearch')"], ["ls(a=True)"]]}
|
40 |
+
{"id": "multi_turn_base_39", "ground_truth": [["mkdir(dir_name='WebDevProjects')"], ["cd(folder='WebDevProjects')", "touch(file_name='styles.css')", "echo(content='Hello World!', file_name='styles.css')", "touch(file_name='index.html')", "echo(content='Hi World!', file_name='index.html')", "touch(file_name='script.js')", "echo(content='Halo World!', file_name='script.js')"], ["ls()"], ["cat(file_name='styles.css')"]]}
|
41 |
+
{"id": "multi_turn_base_40", "ground_truth": [["ls(a=True)"], ["cd(folder='Documents')", "cp(source='annual_report.txt', destination='Reports')"], ["tail(file_name='Q4_summary.doc',lines=1)"], ["message_login(user_id='USR001')", "send_message(receiver_id='USR002', message='The report has been finalized.')"]]}
|
42 |
+
{"id": "multi_turn_base_41", "ground_truth": [["cd(folder='initial_directory')", "cat(file_name='notes')", "get_user_id(user='Bob')", "message_login(user_id='USR001')", "send_message(receiver_id='USR002',message='Meeting notes and project details.')"], ["delete_message(receiver_id='USR002')"]]}
|
43 |
+
{"id": "multi_turn_base_42", "ground_truth": [["touch(file_name='Notes2023.txt')"], ["echo(content='Study diligently, practice programming, master algorithms.',file_name='Notes2023.txt')"], ["wc(file_name='Notes2023.txt',mode='c')"]]}
|
44 |
+
{"id": "multi_turn_base_43", "ground_truth": [["ls(a=True)"], ["find(path='.',name='annual_report.txt')"], ["cd(folder='Documents')", "cat(file_name='annual_report.txt')"], ["message_login(user_id='USR001')", "send_message(receiver_id='USR002', message='This is the annual report. It includes Q4 results and other financial data.')"]]}
|
45 |
+
{"id": "multi_turn_base_44", "ground_truth": [["cd(folder='documents')", "echo(content='Q1: $5000, Q2: $7000, Q3: $6000, Q4: $8000',file_name='annual_report.txt')"], ["mean(numbers=[5000,7000,6000,8000])"], ["touch(file_name='MeanRevenue.txt')", "echo(content='6500',file_name='MeanRevenue.txt')"]]}
|
46 |
+
{"id": "multi_turn_base_45", "ground_truth": [["find(path='ResearchDocs', name='draft')"], ["cd(folder='ResearchDocs')", "cp(source='summary_draft.docx', destination='ultimate_draft.docx')"]]}
|
47 |
+
{"id": "multi_turn_base_46", "ground_truth": [["cd(folder='Drafts')", "rm(file_name='DylanProject.txt')", "cd(folder='..')", "rmdir(dir_name='Drafts')"]]}
|
48 |
+
{"id": "multi_turn_base_47", "ground_truth": [["find(path='.')"], ["cat(file_name='student_record.txt')", "mean(numbers=[100, 95, 85, 90, 88, 92])"], ["standard_deviation(numbers=[100, 95, 85, 90, 88, 92])"]]}
|
49 |
+
{"id": "multi_turn_base_48", "ground_truth": [["ls(a=True)", "cd(folder='test')"], ["wc(file_name='test_file1.txt',mode='c')", "wc(file_name='test_file2.txt',mode='c')"], ["edit_ticket(ticket_id=654321, updates={'priority':2})"]]}
|
50 |
+
{"id": "multi_turn_base_49", "ground_truth": [["ls(a=True)"], ["sort(file_name='file3.txt')", "tail(file_name='file3.txt')"], ["wc(file_name='file3.txt',mode='l')"], ["logarithm(value=20,base=10,precision=2)"]]}
|
51 |
+
{"id": "multi_turn_base_50", "ground_truth": [["lockDoors(unlock=True, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "setHeadlights(mode='on')"]]}
|
52 |
+
{"id": "multi_turn_base_51", "ground_truth": [["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])"], ["pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "find_nearest_tire_shop()"], ["message_login('USR001')", "send_message(receiver_id='USR002', message='I am on my way to your place.')"]]}
|
53 |
+
{"id": "multi_turn_base_52", "ground_truth": [["pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "find_nearest_tire_shop()"], ["post_tweet('Tires checked and engine purring smoothly!', tags=['#RoadTrip'], mentions=['@AutoUpdates'])"], ["comment(tweet_id = 10, comment_content = 'Safety first! Remember tire checks are crucial.')"]]}
|
54 |
+
{"id": "multi_turn_base_53", "ground_truth": [["gallon_to_liter(gallon=30.0)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()"], ["post_tweet('Tire pressures are optimal!', tags=['#CarMaintenance'], mentions=['@VehicleGuru'])"]]}
|
55 |
+
{"id": "multi_turn_base_54", "ground_truth": [["liter_to_gallon(liter=20.0)", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "post_tweet(content='not healthy', tags=['#CarMaintenance'], mentions=['@VehicleGuru'])"], ["retweet(tweet_id=10)"]]}
|
56 |
+
{"id": "multi_turn_base_55", "ground_truth": [["displayCarStatus('fuel')", "fillFuelTank(15.0)", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()"], ["create_ticket(title='Tire Pressure Issue', description='Urgent tire pressure issue.', priority=5)"], ["get_ticket(ticket_id=2)"], ["resolve_ticket(ticket_id=2, resolution='Issue resolved!')"]]}
|
57 |
+
{"id": "multi_turn_base_56", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Rivermist')", "estimate_distance(cityA='94016', cityB='83214')"], ["displayCarStatus('fuel')", "fillFuelTank(fuelAmount=40)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"]]}
|
58 |
+
{"id": "multi_turn_base_57", "ground_truth": [["get_zipcode_based_on_city('Crescent Hollow')", "get_zipcode_based_on_city('Autumnville')", "estimate_distance(cityA='69238', cityB='51479')"], ["logarithm(value=630.0, base=10, precision=5)"]]}
|
59 |
+
{"id": "multi_turn_base_58", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Rivermist')", "estimate_distance(cityA='94016', cityB='83214')"], ["gallon_to_liter(gallon=30)", "fillFuelTank(fuelAmount=50)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["post_tweet(content='Excited for the trip!')"]]}
|
60 |
+
{"id": "multi_turn_base_59", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Rivermist')", "estimate_distance(cityA='94016', cityB='83214')"], ["displayCarStatus(option='fuel')", "gallon_to_liter(gallon=10)"], ["fillFuelTank(fuelAmount=40)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["logarithm(value=980.0, base=20, precision=10)"]]}
|
61 |
+
{"id": "multi_turn_base_60", "ground_truth": [["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()"], ["create_ticket(title='Tire Pressure Issue', description='', priority=5)"], ["get_ticket(ticket_id=2)"], ["close_ticket(ticket_id=2)"]]}
|
62 |
+
{"id": "multi_turn_base_61", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Rivermist')", "estimate_distance(cityA='94016', cityB='83214')", "estimate_drive_feasibility_by_mileage(distance=980.0)"], ["fillFuelTank(fuelAmount=7)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()"]]}
|
63 |
+
{"id": "multi_turn_base_62", "ground_truth": [["get_zipcode_based_on_city('Rivermist')", "get_zipcode_based_on_city('Stonebrook')", "estimate_distance(cityA='83214', cityB='74532')", "send_message(receiver_id='USR002', message='The distance from Rivermist to Stonebrook is 750.0 km.')"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])"], ["pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["view_messages_sent()"]]}
|
64 |
+
{"id": "multi_turn_base_63", "ground_truth": [["liter_to_gallon(liter=166)"], ["fillFuelTank(fuelAmount=43.85)", "activateParkingBrake(mode='engage')", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Rivermist')", "estimate_distance(cityA='94016', cityB='83214')", "estimate_drive_feasibility_by_mileage(distance=980.0)"]]}
|
65 |
+
{"id": "multi_turn_base_64", "ground_truth": [["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "find_nearest_tire_shop()"]]}
|
66 |
+
{"id": "multi_turn_base_65", "ground_truth": [["liter_to_gallon(liter=15)", "fillFuelTank(fuelAmount=3.96)", "check_tire_pressure()", "post_tweet(content='Just filled up the tank and checked the tire pressures. Ready for the next adventure!')", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["retweet(tweet_id=5)", "comment(tweet_id=5, comment_content='Ready for the next adventure!')"]]}
|
67 |
+
{"id": "multi_turn_base_66", "ground_truth": [["estimate_drive_feasibility_by_mileage(distance=450.0)"], ["fillFuelTank(fuelAmount=30)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["set_navigation(destination='2107 Channing Way, Berkeley, CA')"]]}
|
68 |
+
{"id": "multi_turn_base_67", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Silverpine')", "estimate_distance(cityA='94016', cityB='62947')"], ["estimate_drive_feasibility_by_mileage(distance=780.0)"], ["fillFuelTank(fuelAmount=39.5)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"]]}
|
69 |
+
{"id": "multi_turn_base_68", "ground_truth": [["fillFuelTank(fuelAmount=35.0)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "find_nearest_tire_shop()"], ["set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"], ["post_tweet(content='Starting my road trip with a car that is fully prepared and raring to go!', tags=['#Roadtrip', '#Adventure'])"]]}
|
70 |
+
{"id": "multi_turn_base_69", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Rivermist')", "estimate_distance(cityA='94016', cityB='83214')", "liter_to_gallon(liter=40)", "fillFuelTank(fuelAmount=10.57)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')", "post_tweet(content='Just started my journey!', tags=['#RoadTrip'], mentions=['@carenthusiast'])"]]}
|
71 |
+
{"id": "multi_turn_base_70", "ground_truth": [["liter_to_gallon(liter=38)", "fillFuelTank(fuelAmount=10)", "activateParkingBrake(mode='engage')", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "find_nearest_tire_shop()", "set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"]]}
|
72 |
+
{"id": "multi_turn_base_71", "ground_truth": [["get_zipcode_based_on_city('Rivermist')", "get_zipcode_based_on_city('Stonebrook')", "estimate_distance(cityA='83214', cityB='74532')"], ["estimate_drive_feasibility_by_mileage(distance=750.0)"], ["fillFuelTank(fuelAmount=45.0)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["set_navigation(destination='Crescent Hollow, Spring, TX')"]]}
|
73 |
+
{"id": "multi_turn_base_72", "ground_truth": [["fillFuelTank(fuelAmount=10.0)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()"], ["message_login(user_id='USR005')", "send_message(receiver_id='USR007', message='Road trip itinerary update.')"], ["view_messages_sent()"]]}
|
74 |
+
{"id": "multi_turn_base_73", "ground_truth": [["fillFuelTank(fuelAmount=45.0)"], ["activateParkingBrake(mode='engage')", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["set_navigation(destination='123 Pine St, San Francisco, CA 94016')"]]}
|
75 |
+
{"id": "multi_turn_base_74", "ground_truth": [["liter_to_gallon(liter=38)", "fillFuelTank(fuelAmount=10.04)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')", "displayCarStatus(option='climate')"]]}
|
76 |
+
{"id": "multi_turn_base_75", "ground_truth": [["fillFuelTank(fuelAmount=30.0)"], ["check_tire_pressure()", "post_tweet(content='Front Left Tire: 32 PSI, Front Right Tire: 32 PSI, Rear Left Tire: 30 PSI, Rear Right Tire: 30 PSI')"], ["retweet(tweet_id=2)"], ["comment(tweet_id=2, comment_content='Is this pressue too low? Should I take any action?')"]]}
|
77 |
+
{"id": "multi_turn_base_76", "ground_truth": [["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["post_tweet(content='Tire pressure is perfect!', tags=['#CarCare', '#TireHealth'], mentions=['@mike53'])"]]}
|
78 |
+
{"id": "multi_turn_base_77", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Stonebrook')", "estimate_distance(cityA='94016', cityB='74532')"], ["post_tweet(content='Setting forth on an exciting quest from San Francisco to Stonebrook to uncover ancestral stories!', tags=['#GenealogyAdventure', '#FamilyHistory'])"], ["retweet(tweet_id=10)"]]}
|
79 |
+
{"id": "multi_turn_base_78", "ground_truth": [["check_tire_pressure()", "find_nearest_tire_shop()"], ["post_tweet(content='Ensuring my wheels are well-maintained. Maintenance is key to success!', mentions=['#BusinessOnTheMove'])"]]}
|
80 |
+
{"id": "multi_turn_base_79", "ground_truth": [["lockDoors(unlock=True, door=['driver', 'passenger', 'rear_left', 'rear_right'])"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["setCruiseControl(speed=65, activate=True, distanceToNextVehicle=100)"]]}
|
81 |
+
{"id": "multi_turn_base_80", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Rivermist')", "estimate_distance(cityA='83214', cityB='94016')"], ["estimate_drive_feasibility_by_mileage(distance=980.0)"], ["fillFuelTank(fuelAmount=45.0)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["mean(numbers=[750.0, 320.0, 450.0, 290.0])"]]}
|
82 |
+
{"id": "multi_turn_base_81", "ground_truth": [["liter_to_gallon(liter=10)", "fillFuelTank(fuelAmount=2.64)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')", "displayCarStatus(option='climate')"], ["check_tire_pressure()"], ["mean(numbers=[32.0, 32.0, 30.0, 30.0])"]]}
|
83 |
+
{"id": "multi_turn_base_82", "ground_truth": [["check_tire_pressure()", "find_nearest_tire_shop()", "set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"], ["fillFuelTank(fuelAmount=35.0)", "gallon_to_liter(gallon=50.0)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"]]}
|
84 |
+
{"id": "multi_turn_base_83", "ground_truth": [["liter_to_gallon(liter=30)", "fillFuelTank(fuelAmount=7.93)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()"]]}
|
85 |
+
{"id": "multi_turn_base_84", "ground_truth": [["fillFuelTank(fuelAmount=30)", "activateParkingBrake(mode='engage')", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"]]}
|
86 |
+
{"id": "multi_turn_base_85", "ground_truth": [["get_zipcode_based_on_city('San Francisco')", "get_zipcode_based_on_city('Rivermist')", "estimate_distance(cityA='83214', cityB='94016')", "estimate_drive_feasibility_by_mileage(distance=980.0)"], ["fillFuelTank(fuelAmount=40.0)", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"]]}
|
87 |
+
{"id": "multi_turn_base_86", "ground_truth": [["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "activateParkingBrake(mode='engage')", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')", "check_tire_pressure()"], ["find_nearest_tire_shop()", "set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"], ["post_tweet(content='Thank you to our vehicle for a smooth start!', tags=['#Journey', '#SmoothRide', '#Grateful'])"]]}
|
88 |
+
{"id": "multi_turn_base_87", "ground_truth": [["gallon_to_liter(gallon=60.0)"], ["fillFuelTank(fuelAmount=20.0)"], ["activateParkingBrake(mode='engage')", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "find_nearest_tire_shop()"]]}
|
89 |
+
{"id": "multi_turn_base_88", "ground_truth": [["gallon_to_liter(gallon=13.2)"], ["fillFuelTank(fuelAmount=36.8)", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "activateParkingBrake(mode='engage')"], ["pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')", "post_tweet(content='Embarking on an exciting road trip from SF to Rivermist!', tags=['#RoadTrip', '#Adventure', '#Exploring'])"]]}
|
90 |
+
{"id": "multi_turn_base_89", "ground_truth": [["get_zipcode_based_on_city(city='Rivermist')", "get_zipcode_based_on_city(city='Stonebrook')", "estimate_distance(cityA='83214', cityB='74532')"], ["estimate_drive_feasibility_by_mileage(distance=750.0)"], ["fillFuelTank(fuelAmount=30.0)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"]]}
|
91 |
+
{"id": "multi_turn_base_90", "ground_truth": [["liter_to_gallon(liter=150.0)", "fillFuelTank(fuelAmount=40.0)", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["get_zipcode_based_on_city(city='San Francisco')", "get_zipcode_based_on_city(city='Rivermist')", "estimate_distance(cityA='94016', cityB='83214')"], ["post_tweet(content='Excited for my trip from San Francisco to Rivermist!', tags = ['#JourneyAhead'], mentions=['@TravelBuddy'])"], ["mention(tweet_id=10, mentioned_usernames=['@RoadsideAssistance'])"]]}
|
92 |
+
{"id": "multi_turn_base_91", "ground_truth": [["get_outside_temperature_from_google()", "send_message(receiver_id='USR006', message='It is hot outside.')"], ["view_messages_sent()"]]}
|
93 |
+
{"id": "multi_turn_base_92", "ground_truth": [["estimate_distance(cityA='83214', cityB='74532')"], ["estimate_drive_feasibility_by_mileage(distance=750.0)"], ["fillFuelTank(fuelAmount=39.5)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["check_tire_pressure()", "find_nearest_tire_shop()", "set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"]]}
|
94 |
+
{"id": "multi_turn_base_93", "ground_truth": [["displayCarStatus(option='fuel')"], ["fillFuelTank(fuelAmount=39.5)", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')", "check_tire_pressure()"], ["find_nearest_tire_shop()", "set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"]]}
|
95 |
+
{"id": "multi_turn_base_94", "ground_truth": [["estimate_drive_feasibility_by_mileage(distance=300.0)", "fillFuelTank(fuelAmount=30.0)"], ["check_tire_pressure()", "find_nearest_tire_shop()", "set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"], ["pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"]]}
|
96 |
+
{"id": "multi_turn_base_95", "ground_truth": [["pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["get_zipcode_based_on_city(city='Rivermist')"], ["get_zipcode_based_on_city(city='San Francisco')", "estimate_distance(cityA='83214', cityB='94016')"], ["send_message(receiver_id='USR008', message='The estimated distance from Rivermist to San Francisco is 980 miles.')"], ["view_messages_sent()"]]}
|
97 |
+
{"id": "multi_turn_base_96", "ground_truth": [["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["get_zipcode_based_on_city(city='San Francisco')", "get_zipcode_based_on_city(city='Rivermist')", "estimate_distance(cityA='94016', cityB='83214')"]]}
|
98 |
+
{"id": "multi_turn_base_97", "ground_truth": [["get_zipcode_based_on_city(city='Rivermist')", "get_zipcode_based_on_city(city='Stonebrook')", "estimate_distance(cityA='83214', cityB='74532')"], ["estimate_drive_feasibility_by_mileage(distance=750.0)"], ["fillFuelTank(fuelAmount=45.0)"], ["lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])", "pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["send_message(receiver_id='BD732D1888B94DAA', message='I am on my way.')"], ["view_messages_sent()"]]}
|
99 |
+
{"id": "multi_turn_base_98", "ground_truth": [["displayCarStatus(option='doors')", "lockDoors(unlock=False, door=['driver', 'passenger', 'rear_left', 'rear_right'])"], ["pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')"], ["get_zipcode_based_on_city(city='Silverpine')", "get_zipcode_based_on_city(city='Oakendale')", "estimate_distance(cityA='62947', cityB='47329')"]]}
|
100 |
+
{"id": "multi_turn_base_99", "ground_truth": [["estimate_drive_feasibility_by_mileage(distance=380.0)", "fillFuelTank(fuelAmount=35.0)"], ["pressBrakePedal(pedalPosition=1.0)", "startEngine(ignitionMode='START')", "displayCarStatus(option='climate')"], ["check_tire_pressure()"], ["find_nearest_tire_shop()", "set_navigation(destination='456 Oakwood Avenue, Rivermist, 83214')"]]}
|
101 |
+
{"id": "multi_turn_base_100", "ground_truth": [["get_stock_info(symbol='NVDA')"], ["fund_account(amount=2203.4)"]]}
|
102 |
+
{"id": "multi_turn_base_101", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["get_stock_info(symbol='XTC')"], ["send_message(receiver_id='USR003',message='The latest stock price of XTC is $150.75.')"], ["view_messages_sent()"]]}
|
103 |
+
{"id": "multi_turn_base_102", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["place_order(order_type='Buy',symbol='TSLA',price=700,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["get_account_info()"], ["create_ticket(title='Account Information Error',description='User-reported issue where updated account information, such as email and phone number, is not displaying correctly and is not syncing across services despite attempts to log out and back in.')"]]}
|
104 |
+
{"id": "multi_turn_base_103", "ground_truth": [[ "add_to_watchlist(stock='OMEG')"], ["get_watchlist()"], ["get_stock_info('OMEG')", "place_order(order_type='Buy',symbol='OMEG',price=457.23,amount=150)"], ["get_order_details(order_id=12446)"], ["send_message(receiver_id='USR002', message='Dear Customer Service, please confirm the successful execution of my order for 150 shares of Omega Industries at the current market price, and verify the order details under reference ID USR002. Thank you.')"]]}
|
105 |
+
{"id": "multi_turn_base_104", "ground_truth": [["get_stock_info(symbol='QUAS')"], ["add_to_watchlist(stock='QUAS')", "get_watchlist()"]]}
|
106 |
+
{"id": "multi_turn_base_105", "ground_truth": [["get_stock_info(symbol='QUAS')"], ["get_available_stocks('Technology')","add_to_watchlist(stock='AAPL')","add_to_watchlist(stock='GOOG')","add_to_watchlist(stock='MSFT')"]]}
|
107 |
+
{"id": "multi_turn_base_106", "ground_truth": [["get_stock_info(symbol='AAPL')", "place_order(order_type='Buy',symbol='AAPL',price=227.16,amount=100)"], ["get_order_details(order_id=12446)"], ["get_ticket(ticket_id=1)"], ["resolve_ticket(ticket_id=1,resolution='The issue with the trading system query, caused by a brief network delay, has been resolved, and no further action is required as the system is now functioning properly.')"]]}
|
108 |
+
{"id": "multi_turn_base_107", "ground_truth": [["get_stock_info(symbol='ZETA')"], ["place_order(order_type='Buy',symbol='ZETA',price=150.75,amount=50)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["get_account_info()"]]}
|
109 |
+
{"id": "multi_turn_base_108", "ground_truth": [["get_watchlist()"], ["get_stock_info(symbol='NVDA')", "place_order(order_type='Buy',symbol='NVDA',price=220.34,amount=50)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["get_account_info()"]]}
|
110 |
+
{"id": "multi_turn_base_109", "ground_truth": [["get_available_stocks(sector='Technology')"], ["get_stock_info(symbol='MSFT')"], ["place_order(order_type='Buy',symbol='MSFT',price=310.23,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["get_account_info()"], ["post_tweet(content='Just made a move in the tech sector! I initiated and then canceled a 100-share buy order for $MSFT. Always staying sharp with my investment decisions!')"]]}
|
111 |
+
{"id": "multi_turn_base_110", "ground_truth": [["get_watchlist()"], ["get_stock_info(symbol='AAPL')", "place_order(order_type='Buy',symbol='AAPL',price=227.16,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["get_account_info()"], ["ticket_login(username='user123', password='12345')", "create_ticket(title='Urgent: Transaction Issue',description='There is an issue with a recent transaction involving a canceled buy order for 100 shares of AAPL and I am requesting confirmation of the cancellation along with an account summary.',priority=3)"]]}
|
112 |
+
{"id": "multi_turn_base_111", "ground_truth": [["add_to_watchlist(stock='ZETA')"], ["get_order_details(order_id=12345)"], ["send_message(receiver_id='USR002',message='What are the new stock inclusion and the status of my current order?')"], ["view_messages_sent()"]]}
|
113 |
+
{"id": "multi_turn_base_112", "ground_truth": [["update_market_status(current_time_str='10:30 AM')"], ["get_available_stocks(sector='Technology')"], ["get_stock_info(symbol='NVDA')"], ["cancel_order(order_id=12446)"], ["get_account_info()"]]}
|
114 |
+
{"id": "multi_turn_base_113", "ground_truth": [["add_to_watchlist(stock='QUAS')"], ["get_watchlist()", "get_stock_info(symbol='NVDA')", "get_stock_info(symbol='QUAS')"]]}
|
115 |
+
{"id": "multi_turn_base_114", "ground_truth": [["get_stock_info(symbol='QUAS')"], ["add_to_watchlist(stock='QUAS')"], ["get_watchlist()"], ["send_message(receiver_id='USR007',message='NVDA and QUAS.')"], ["view_messages_sent()"]]}
|
116 |
+
{"id": "multi_turn_base_115", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["get_stock_info(symbol='AMZN')"], ["add_to_watchlist(stock='AMZN')"], ["get_order_details(order_id=12446)"]]}
|
117 |
+
{"id": "multi_turn_base_116", "ground_truth": [["get_watchlist()"], ["remove_stock_from_watchlist(symbol='ZETA')"], ["get_stock_info(symbol='OMEG')"], ["get_available_stocks(sector='Technology')"], ["fund_account(amount=10000)"], ["place_order(order_type='Buy', symbol='AAPL', price=150.0, amount=50)"]]}
|
118 |
+
{"id": "multi_turn_base_117", "ground_truth": [[ "remove_stock_from_watchlist(symbol='ZETA')"], ["get_watchlist()"], ["get_available_stocks(sector='Technology')"], ["get_stock_info(symbol='MSFT')"], ["place_order(order_type='Buy',symbol='MSFT',price=320,amount=50)"], ["fund_account(amount=5000)"]]}
|
119 |
+
{"id": "multi_turn_base_118", "ground_truth": [["get_watchlist()"], ["remove_stock_from_watchlist(symbol='NVDA')"], ["get_stock_info(symbol='AAPL')", "place_order(order_type='Buy',symbol='AAPL',price=227.16,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"]]}
|
120 |
+
{"id": "multi_turn_base_119", "ground_truth": [["get_stock_info(symbol='ZETA')"], ["get_available_stocks(sector='Technology')"], ["cancel_order(order_id=12446)"], ["close_ticket(ticket_id=3)"]]}
|
121 |
+
{"id": "multi_turn_base_120", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["get_stock_info(symbol='AAPL')", "place_order(order_type='Buy',symbol='AAPL',price=227.16,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"]]}
|
122 |
+
{"id": "multi_turn_base_121", "ground_truth": [["get_available_stocks(sector='Technology')"], ["get_stock_info(symbol='AAPL')", "place_order(order_type='Buy',symbol='AAPL',price=227.16,amount=150)"], ["get_order_details(order_id=12446)"], ["get_account_info()", "make_transaction(account_id=12345,xact_type='withdrawal',amount=500)"]]}
|
123 |
+
{"id": "multi_turn_base_122", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["place_order(order_type='Buy',symbol='AAPL',price=150,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["trading_logout()"]]}
|
124 |
+
{"id": "multi_turn_base_123", "ground_truth": [["get_account_info()", "get_stock_info(symbol='TSLA')", "place_order(order_type='Buy',symbol='TSLA',price=667.92,amount=150)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["trading_logout()"]]}
|
125 |
+
{"id": "multi_turn_base_124", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["get_stock_info(symbol='AAPL')", "place_order(order_type='Buy',symbol='AAPL',price=227.16,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"]]}
|
126 |
+
{"id": "multi_turn_base_125", "ground_truth": [["get_watchlist()"], ["get_stock_info(symbol='ALPH')", "place_order(order_type='Buy',symbol='ALPH',price=1320.45,amount=100)"], ["get_order_details(order_id=12446)"], ["get_ticket(ticket_id=1)"], ["resolve_ticket(ticket_id=1,resolution='Verified with the trading platform.')"]]}
|
127 |
+
{"id": "multi_turn_base_126", "ground_truth": [["get_watchlist()"], ["get_stock_info(symbol='XYZ')", "place_order(order_type='Buy',symbol='XYZ',price=150.0,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"]]}
|
128 |
+
{"id": "multi_turn_base_127", "ground_truth": [["get_watchlist()"], ["remove_stock_from_watchlist(symbol='BDX')"], ["get_stock_info(symbol='BDX')", "place_order(order_type='Buy',symbol='BDX',price=250.0,amount=150)"], ["get_order_details(order_id=12446)"]]}
|
129 |
+
{"id": "multi_turn_base_128", "ground_truth": [["get_current_time()", "get_available_stocks(sector='Technology')"], ["get_stock_info(symbol='MSFT')", "place_order(order_type='Buy',symbol='MSFT',price=310.23,amount=150)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"]]}
|
130 |
+
{"id": "multi_turn_base_129", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["get_stock_info(symbol='NVDA')", "place_order(order_type='Buy',symbol='NVDA',price=220.34,amount=120)"], ["get_order_details(order_id=12446)"], ["get_ticket(ticket_id=1)"], ["resolve_ticket(ticket_id=1,resolution='The issue related to the previous transaction inquiry has been resolved by verifying the accuracy of the NVDA stock order, and the ticket has been marked as completed with no further action required.')"]]}
|
131 |
+
{"id": "multi_turn_base_130", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["place_order(order_type='Buy',symbol='NEPT',price=25.5,amount=150)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["get_account_info()"], ["fund_account(amount=5000.0)"]]}
|
132 |
+
{"id": "multi_turn_base_131", "ground_truth": [["get_current_time()"], ["get_available_stocks(sector='Technology')"], ["get_stock_info(symbol='MSFT')"], ["place_order(order_type='Buy',symbol='MSFT',price=310.23,amount=150)"], ["get_order_details(order_id=12446)"], ["send_message(receiver_id='USR003',message='I just executed another order. What do you think of it?')"], ["delete_message(receiver_id='USR003')"]]}
|
133 |
+
{"id": "multi_turn_base_132", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["get_stock_info(symbol='SYNX')", "add_to_watchlist(stock='SYNX')"], ["get_order_details(order_id=12446)"]]}
|
134 |
+
{"id": "multi_turn_base_133", "ground_truth": [["add_to_watchlist(stock='AAPL')", "get_watchlist()"], ["get_stock_info(symbol='NVDA')"]]}
|
135 |
+
{"id": "multi_turn_base_134", "ground_truth": [[ "get_stock_info(symbol='QUAS')", "add_to_watchlist(stock='QUAS')"], ["get_order_details(order_id=12446)", "cancel_order(order_id=12446)"], ["get_account_info()"]]}
|
136 |
+
{"id": "multi_turn_base_135", "ground_truth": [["add_to_watchlist(stock='ZETA')", "get_watchlist()"], ["get_available_stocks(sector='Technology')", "get_stock_info(symbol='NVDA')"], ["place_order(order_type='Buy',symbol='ZETA',price=120,amount=100)"], ["get_order_details(order_id=12446)"]]}
|
137 |
+
{"id": "multi_turn_base_136", "ground_truth": [["get_stock_info(symbol='ZETA')", "place_order(order_type='Buy',symbol='ZETA',price=150.75,amount=50)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["get_account_info()"]]}
|
138 |
+
{"id": "multi_turn_base_137", "ground_truth": [["add_to_watchlist(stock='ZETA')"], ["get_watchlist()"], ["get_stock_info(symbol='NVDA')"], ["send_message(receiver_id='USR001',message='I checked all the details. Move forward with the plan as we discussed earlier.')"]]}
|
139 |
+
{"id": "multi_turn_base_138", "ground_truth": [[ "get_stock_info(symbol='SYNX')"], ["place_order(order_type='Buy',symbol='SYNX',price=345.67,amount=150)"], ["get_order_details(order_id=12446)"], ["send_message(receiver_id='USR006',message='Order for purchasing SYNX is completed.')"], ["delete_message(receiver_id='USR006')"]]}
|
140 |
+
{"id": "multi_turn_base_139", "ground_truth": [["add_to_watchlist(stock='ZETA')"], ["get_watchlist()"]]}
|
141 |
+
{"id": "multi_turn_base_140", "ground_truth": [[ "add_to_watchlist(stock='ZETA')"], ["get_account_info()"], ["create_ticket(title='Critical Order Assistance',description='Urgent assistance required.',priority=5)"], ["resolve_ticket(ticket_id=2,resolution='Self-resolved, no longer requiring assistance.')"]]}
|
142 |
+
{"id": "multi_turn_base_141", "ground_truth": [["remove_stock_from_watchlist(symbol='TSLA')"], ["get_watchlist()"], ["get_stock_info(symbol='GOOG')", "place_order(order_type='Buy',symbol='GOOG',price=2840.34,amount=100)"], ["get_order_details(order_id=12446)"], ["send_message(receiver_id='USR005',message='100 shares of GOOG purchased, thoughts?')"]]}
|
143 |
+
{"id": "multi_turn_base_142", "ground_truth": [["add_to_watchlist(stock='ZETA')"], ["get_watchlist()"], ["get_stock_info(symbol='ZETA')"], ["place_order(order_type='Buy',symbol='ZETA',price=150.0,amount=50)"], ["fund_account(amount=5000)"]]}
|
144 |
+
{"id": "multi_turn_base_143", "ground_truth": [[ "add_to_watchlist(stock='ZETA')"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["message_login(user_id='USR001')", "get_account_info()", "send_message(receiver_id='USR003',message='My strategy is shifting due to recent market movements and the cancellation of a specific order. Current balance in my account is $10000.00.')"]]}
|
145 |
+
{"id": "multi_turn_base_144", "ground_truth": [["get_current_time()", "update_market_status(current_time_str='10:30 AM')"], ["get_stock_info(symbol='AAPL')"], ["mean([227.16,2.552,227.11, 227.09])"]]}
|
146 |
+
{"id": "multi_turn_base_145", "ground_truth": [[ "get_stock_info(symbol='ZETA')"], ["add_to_watchlist(stock='ZETA')"], ["get_order_details(order_id=12446)"], ["send_message(receiver_id='USR003',message='Zeta Corp seems to have potential. What do you think of their recent financial report?')"], ["view_messages_sent()"]]}
|
147 |
+
{"id": "multi_turn_base_146", "ground_truth": [["get_watchlist()"], ["remove_stock_from_watchlist(symbol='ZETA')"], [ "get_stock_info(symbol='AAPL')", "place_order(order_type='Buy',symbol='AAPL',price=227.16,amount=50)"], ["get_order_details(order_id=12446)"]]}
|
148 |
+
{"id": "multi_turn_base_147", "ground_truth": [["get_stock_info(symbol='OMEG')", "post_tweet(content='Omega Industries is skyrocketing at $457.23 per share! The tech industry evolution is electrifying, and we are just getting started.',tags=['#TechBoom'],mentions=['@industryexperts'])"], ["mention(tweet_id=1,mentioned_usernames=['@technewsworld'])"]]}
|
149 |
+
{"id": "multi_turn_base_148", "ground_truth": [["get_stock_info(symbol='AAPL')", "place_order(order_type='Buy',symbol='AAPL',price=227.16,amount=100)"], ["get_order_details(order_id=12446)"], ["cancel_order(order_id=12446)"], ["get_account_info()"], ["create_ticket(title='Platform Error',description='Issue with a recent trading platform error following the cancellation of an AAPL order and a request for an account overview.')"]]}
|
150 |
+
{"id": "multi_turn_base_149", "ground_truth": [["remove_stock_from_watchlist(symbol='ZETA')"], ["get_watchlist()"], ["send_message(receiver_id='USR003', message='I\\'ve decided to drop those dipping stocks from my line-up.')"], ["view_messages_sent()"], ["delete_message(receiver_id='USR003')"]]}
|
151 |
+
{"id": "multi_turn_base_150", "ground_truth": [["get_flight_cost(travel_from='RMS', travel_to='SBK', travel_date='2024-10-06', travel_class='economy')"], ["compute_exchange_rate(base_currency='GBP', target_currency='USD', value=15400.0)", "set_budget_limit(access_token='abc123token', budget_limit=22000.0)"]]}
|
152 |
+
{"id": "multi_turn_base_151", "ground_truth": [["get_flight_cost(travel_from='SFO', travel_to='LAX', travel_date='2024-11-10', travel_class='business')", "compute_exchange_rate(base_currency='USD', target_currency='EUR', value=400.0)", "book_flight(access_token='abc123xyz', card_id='144756014165', travel_date='2024-11-10', travel_from='SFO', travel_to='LAX', travel_class='business', travel_cost=400.0)"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"], ["authenticate_twitter(username='john',password='john1234')", "post_tweet(content='Just cancelled my trip to LA',tags=['#TravelUpdate','#BusinessTrip'])"]]}
|
153 |
+
{"id": "multi_turn_base_152", "ground_truth": [["get_flight_cost(travel_from='SFO', travel_to='ORD', travel_date='2024-11-15', travel_class='first')", "book_flight(access_token='secureAccessToken12345',card_id='144756014165', travel_date='2024-11-15', travel_from='SFO', travel_to='ORD', travel_cost=4000.0, travel_class='first')"], ["cancel_booking(access_token='secureAccessToken12345', booking_id='3426812')"], ["ticket_login(username='mthompson', password='securePass123')", "create_ticket(title='Flight Cancellation Alert', description='Request to cancel.',priority=5)"]]}
|
154 |
+
{"id": "multi_turn_base_153", "ground_truth": [["verify_traveler_information(first_name='Michael', last_name='Thompson', date_of_birth='1950-01-01', passport_number='P12345678')"], ["get_flight_cost(travel_from='RMS', travel_to='GFD', travel_date='2024-12-15', travel_class='business')"], ["set_budget_limit(access_token='abc123xyz', budget_limit=5000)"], ["book_flight(access_token='abc123xyz', card_id='card1234', travel_date='2024-12-15', travel_from='RMS', travel_to='GFD', travel_class='business', travel_cost=640.0)"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812')"]]}
|
155 |
+
{"id": "multi_turn_base_154", "ground_truth": [["verify_traveler_information(first_name='Michael', last_name='Smith', date_of_birth='1962-02-14', passport_number='P87654321')"], ["get_flight_cost(travel_from='ORD', travel_to='LAX', travel_date='2024-08-10', travel_class='economy')"], ["set_budget_limit(access_token='token_ABC123XYZ', budget_limit=1500)"], ["book_flight(access_token='token_ABC123XYZ', card_id='card1', travel_date='2024-08-10', travel_from='ORD', travel_to='LAX', travel_class='economy', travel_cost=180.0)"], ["view_messages_sent()"]]}
|
156 |
+
{"id": "multi_turn_base_155", "ground_truth": [["get_flight_cost(travel_from='LAX', travel_to='JFK', travel_date='2024-11-15', travel_class='business')", "book_flight(access_token='abc123xyz', card_id='id15583', travel_date='2024-11-15', travel_from='LAX', travel_to='JFK', travel_class='business', travel_cost=2400.0)"], ["purchase_insurance(access_token='abc123xyz', insurance_type='comprehensive', insurance_cost=120.0, booking_id='3426812', card_id='id15583')"]]}
|
157 |
+
{"id": "multi_turn_base_156", "ground_truth": [["get_flight_cost(travel_from='SFO', travel_to='LAX', travel_date='2024-10-15', travel_class='first')", "book_flight(access_token='abc123xyz456', card_id='travel_card_12345', travel_date='2024-10-15', travel_from='SFO', travel_to='LAX', travel_class='first', travel_cost=1000.0)"], ["retrieve_invoice(access_token='abc123xyz456', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Urgent: last-minute complication with my reservation.')"], ["ticket_login(username='mthompson', password='securePass123')", "create_ticket(title='Urgent Flight Issue', priority=4)"], ["edit_ticket(ticket_id=0, updates={'status':'Urgent', 'priority':5})"]]}
|
158 |
+
{"id": "multi_turn_base_157", "ground_truth": [["list_all_airports()"], ["get_nearest_airport_by_city(location='Crescent Hollow')"], ["get_flight_cost(travel_from='CRH', travel_to='PHV', travel_date='2024-03-03', travel_class='business')"]]}
|
159 |
+
{"id": "multi_turn_base_158", "ground_truth": [["verify_traveler_information(first_name='Theodore', last_name='Collins', date_of_birth='1985-09-14', passport_number='US876543')"], ["get_flight_cost(travel_from='JFK',travel_to='LAX',travel_date='2024-10-15',travel_class='first')", "book_flight(access_token='abc123xyz', card_id='primary', travel_date='2024-10-15', travel_from='JFK',travel_to='LAX',travel_class='first',travel_cost=2850.0)"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"]]}
|
160 |
+
{"id": "multi_turn_base_159", "ground_truth": [["list_all_airports()", "get_flight_cost(travel_from='RMS', travel_to='SBK', travel_date='2024-11-15', travel_class='economy')"], ["book_flight(access_token='abc123xyz', card_id='card_3456', travel_date='2024-11-15', travel_from='SFO', travel_to='LAX', travel_class='economy', travel_cost=400.0)"], ["purchase_insurance(access_token='abc123xyz', insurance_type='comprehensive', booking_id='3426812', insurance_cost=500.0, card_id='card_3456')"]]}
|
161 |
+
{"id": "multi_turn_base_160", "ground_truth": [["compute_exchange_rate(base_currency='RMB', target_currency='USD', value=20000.0)", "set_budget_limit(access_token='abc123xyz', budget_limit=2857.14)"], ["book_flight(access_token='abc123xyz', card_id='card_3478', travel_date='2024-02-28', travel_from='JFK', travel_to='LAX', travel_class='business', travel_cost=2280.0)"], ["close_ticket(ticket_id=83912)"]]}
|
162 |
+
{"id": "multi_turn_base_161", "ground_truth": [["authenticate_travel(client_id='client_520', client_secret='rise_to_sky', refresh_token='token990125', grant_type='read_write', user_first_name='Michael', user_last_name='Thompson')"], ["get_credit_card_balance(access_token='251675', card_id='card_4455')"], ["mean(numbers=[45.99, 78.25, 102.5, 38.75, 92.1])"]]}
|
163 |
+
{"id": "multi_turn_base_162", "ground_truth": [["list_all_airports()"], ["get_nearest_airport_by_city(location='Rivermist')"], ["get_flight_cost(travel_from='RMS',travel_to='JFK',travel_date='2024-09-10',travel_class='economy')"], ["compute_exchange_rate(base_currency='USD', target_currency='RMB', value=420.0)", "set_budget_limit(access_token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', budget_limit=2940.0)"], ["book_flight(access_token='eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', card_id='card6749', travel_date='2024-09-10', travel_from='RMS', travel_to='JFK', travel_class='economy', travel_cost=420.0)"], ["close_ticket(ticket_id=458219)"]]}
|
164 |
+
{"id": "multi_turn_base_163", "ground_truth": [["get_flight_cost(travel_from='SFO', travel_to='LAX', travel_date='2024-11-16', travel_class='business')", "book_flight(access_token='abc123xyz', card_id='AMEX123456789', travel_date='2024-11-16', travel_from='SFO', travel_to='LAX', travel_class='business', travel_cost=400.0)"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"]]}
|
165 |
+
{"id": "multi_turn_base_164", "ground_truth": [["get_flight_cost(travel_from='RMS', travel_to='JFK', travel_date='2024-12-01', travel_class='first')"], ["compute_exchange_rate(base_currency='RMB', target_currency='USD', value=10000.0)", "set_budget_limit(access_token='abc123', budget_limit=1428.57)"], ["book_flight(access_token='abc123', card_id='card_3456', travel_date='2024-12-01', travel_from='RMS', travel_to='JFK', travel_class='first', travel_cost=2100.0)"], ["retrieve_invoice(access_token='abc123', booking_id='3426812')"]]}
|
166 |
+
{"id": "multi_turn_base_165", "ground_truth": [["verify_traveler_information(first_name='Eleanor', last_name='Smith', date_of_birth='1985-03-15', passport_number='US123456789')"], ["get_nearest_airport_by_city(location='Crescent Hollow')"], ["set_budget_limit(access_token='abc123xyz',budget_limit=1000)", "book_flight(access_token='abc123xyz', card_id='primary', travel_date='2024-12-15', travel_from='CRH', travel_to='HKG', travel_class='economy', travel_cost=850.0)"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Urgent: Discrepancy encountered with the booking. Please resolve.')"]]}
|
167 |
+
{"id": "multi_turn_base_166", "ground_truth": [["get_flight_cost(travel_from='CRH',travel_to='RMS',travel_date='2022-07-15',travel_class='business')"], ["set_budget_limit(access_token='access_token_abc123', budget_limit=2000.0)"], ["book_flight(access_token='access_token_abc123', card_id='card7320', travel_date='2022-07-15',travel_from='CRH',travel_to='RMS', travel_class='business',travel_cost=560.0)"], ["retrieve_invoice(access_token='access_token_abc123', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Concern regarding seating arrangements')"]]}
|
168 |
+
{"id": "multi_turn_base_167", "ground_truth": [["get_flight_cost(travel_from='RMS', travel_to='LAX', travel_date='2024-12-15', travel_class='business')"], ["compute_exchange_rate(base_currency='RMB', target_currency='USD', value=20000.0)", "set_budget_limit(access_token='abc123xyz456', budget_limit=2857.14)"], ["book_flight(access_token='abc123xyz456', card_id='card_0064', travel_date='2024-12-15', travel_from='RMS', travel_to='LAX', travel_class='business', travel_cost=660.0)"], ["cancel_booking(access_token='abc123xyz456', booking_id='3426812')"], []]}
|
169 |
+
{"id": "multi_turn_base_168", "ground_truth": [["compute_exchange_rate(base_currency='USD', target_currency='EUR', value=1500.0)"], ["book_flight(access_token='abc123xyz456', card_id='card5638', travel_date='2024-07-01', travel_from='SFO', travel_to='BOS', travel_class='business', travel_cost=1800.0)"], ["retrieve_invoice(access_token='abc123xyz456', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Require assistance with transaction particulars')"], ["message_login(user_id='USR100145')", "send_message(receiver_id='travel_advisor', message='Details regarding problems faced with the flight booking transaction.')"]]}
|
170 |
+
{"id": "multi_turn_base_169", "ground_truth": [["book_flight(access_token='2278-9812-3456-4567', card_id='card_6789', travel_date='2024-11-10', travel_from='RMS', travel_to='LAX', travel_class='business', travel_cost=1200.0)", "retrieve_invoice(access_token='2278-9812-3456-4567', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Inquiry regarding luggage restrictions for my flight')"]]}
|
171 |
+
{"id": "multi_turn_base_170", "ground_truth": [["get_flight_cost(travel_from='SFO',travel_to='LAX',travel_date='2024-11-15',travel_class='first')", "book_flight(access_token='access_token_abc123', card_id='card123', travel_date='2024-11-15', travel_from='SFO', travel_to='LAX', travel_class='first', travel_cost=2000.0)"], ["retrieve_invoice(access_token='access_token_abc123', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Please assist with my confirmed booking.')"], ["cancel_booking(access_token='access_token_abc123', booking_id='3426812')"], ["authenticate_twitter(username='michael_smith', password='michael1234')", "post_tweet(content='Exploring the world, one city at a time!', tags=['#Travel', '#Adventure'])"], ["retweet(tweet_id=0)"]]}
|
172 |
+
{"id": "multi_turn_base_171", "ground_truth": [["compute_exchange_rate(base_currency='RMB', target_currency='USD', value=10000.0)", "set_budget_limit(access_token='897362', budget_limit=1428.57)", "get_flight_cost(travel_from='JFK',travel_to='PEK',travel_date='2024-06-15',travel_class='first')", "book_flight(access_token='897362', card_id='card_8283', travel_date='2024-06-15', travel_from='JFK', travel_to='PEK', travel_class='first', travel_cost=10000.0)"], ["purchase_insurance(access_token='897362', insurance_type='comprehensive', insurance_cost=250.0, booking_id='3426812', card_id='card_8283')", "retrieve_invoice(access_token='897362', booking_id='3426812')"], ["message_login(user_id='USR001')", "send_message(receiver_id='travel_agent', message='Thank you for your efficient handling of my booking to Beijing. My trip is confirmed for June 15th from JFK to PEK in first class.')", "view_messages_sent()"]]}
|
173 |
+
{"id": "multi_turn_base_172", "ground_truth": [["authenticate_travel(client_id='trav3lMaxID2023', client_secret='M@xSecret!', refresh_token='r3freshM3n0w', grant_type='read_write', user_first_name='Maxwell', user_last_name='Edison')"], ["register_credit_card(access_token='251675', card_number='2345-6789-1234-5678', expiration_date='08/2025', cardholder_name='Maxwell Edison', card_verification_number=567)", "book_flight(access_token='251675', card_id='391310425148', travel_date='2024-12-15', travel_from='SFO', travel_to='LAX', travel_class='business', travel_cost=400.0)"], ["send_message(receiver_id='m0llyTr@vel2k24', message='Everything for our trip is sorted and ready!')"], ["view_messages_sent()"]]}
|
174 |
+
{"id": "multi_turn_base_173", "ground_truth": [["get_flight_cost(travel_from='LAX', travel_to='JFK', travel_date='2024-11-15', travel_class='business')"], ["compute_exchange_rate(base_currency='USD', target_currency='GBP', value=2400.0)", "set_budget_limit(access_token='abc123xyz', budget_limit=10000.0)"], ["book_flight(access_token='abc123xyz', card_id='card_1496', travel_date='2024-11-15', travel_from='LAX', travel_to='JFK', travel_class='business', travel_cost=2400.0)"], ["close_ticket(ticket_id='ticket_001')"]]}
|
175 |
+
{"id": "multi_turn_base_174", "ground_truth": [["get_flight_cost(travel_from='SFO', travel_to='CIA', travel_date='2024-10-10', travel_class='business')", "compute_exchange_rate(base_currency='USD', target_currency='EUR', value=2800.0)", "book_flight(access_token='abc123xyz', card_id='card_7243', travel_date='2024-10-10', travel_from='SFO', travel_to='CIA', travel_class='business', travel_cost=2800.0)"], ["purchase_insurance(access_token='abc123xyz', insurance_type='travel', insurance_cost=187.5, card_id='card_7243', booking_id='3426812')"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812',insurance_id='498276044')"], ["authenticate_twitter(username='bookworm_traveler', password='Tr@v3lB00ks2023')", "post_tweet(content='Off to Rome! Can\\'t wait to explore the ancient wonders and dive into Italian cuisine!')"], ["comment(tweet_id=10, comment_content='Safe travels and enjoy every moment!')"]]}
|
176 |
+
{"id": "multi_turn_base_175", "ground_truth": [["get_flight_cost(travel_from='SFO', travel_to='LAX', travel_date='2024-11-25', travel_class='business')", "book_flight(access_token='1293', card_id='card_3487', travel_date='2024-11-25', travel_from='SFO', travel_to='LAX', travel_class='business', travel_cost=400.0)", "retrieve_invoice(access_token='1293', booking_id='3426812')"], ["authenticate_twitter(username='john', password='john1234')", "post_tweet(content='Loved my flight journey!',tags=['#TravelDiaries'])", "retweet(tweet_id=10)"]]}
|
177 |
+
{"id": "multi_turn_base_176", "ground_truth": [["book_flight(access_token='ABCD1234', card_id='id_1234', travel_date='2024-12-15', travel_from='JFK', travel_to='LAX', travel_class='business', travel_cost=4500.0)", "cancel_booking(access_token='ABCD1234', booking_id='3426812')"], ["create_ticket(priority=5, title='Urgent Flight Cancellation', description='Due to unexpected changes in schedule, the flight from JFK to LAX on December 15, 2023, needs to be canceled immediately.')"]]}
|
178 |
+
{"id": "multi_turn_base_177", "ground_truth": [["book_flight(access_token='abc123xyz', card_id='card_7629', travel_date='2024-12-15', travel_from='LAX', travel_to='HND', travel_class='business', travel_cost=1200.0)"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812')"]]}
|
179 |
+
{"id": "multi_turn_base_178", "ground_truth": [["register_credit_card(access_token='abc123xyz', card_number='4012888888881881', expiration_date='12/2028', card_verification_number=465, cardholder_name='Michael Smith')"], ["purchase_insurance(access_token='abc123xyz', insurance_type='comprehensive', booking_id='flight_001', insurance_cost=200.0, card_id='262919693687')", "retrieve_invoice(access_token='abc123xyz', booking_id='flight_001')"], ["contact_customer_support(booking_id='flight_001', message='Insurance-related issues that need resolution')"], ["ticket_login(username='msmith', password='SecurePass123')", "create_ticket(priority=4, title='Unsatisfactory Customer Support', description='')"], ["cancel_booking(access_token='abc123xyz', booking_id='flight_001')"]]}
|
180 |
+
{"id": "multi_turn_base_179", "ground_truth": [["book_flight(access_token='abc123xyz', card_id='card_6789', travel_date='2024-11-12', travel_from='CRH', travel_to='JFK', travel_class='economy', travel_cost=850.0)"], ["purchase_insurance(access_token='abc123xyz', insurance_type='comprehensive', booking_id='3426812', insurance_cost=100.0, card_id='card_6789')"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Request for itinerary adjustments or refund due to family emergency.')"]]}
|
181 |
+
{"id": "multi_turn_base_180", "ground_truth": [["set_budget_limit(access_token='abc123xyz', budget_limit=2857.14)"], ["get_flight_cost(travel_from='LAX', travel_to='JFK', travel_date='2024-10-12', travel_class='business')", "book_flight(access_token='abc123xyz', card_id='main_card', travel_date='2024-10-12', travel_from='LAX', travel_to='JFK', travel_class='business', travel_cost=2400.0)"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"], [], [], ["ticket_login(username='mzhang', password='SecurePass123')", "create_ticket(priority=3, title='Invoice Discrepancy', description='Problem encountered with invoicing.')"]]}
|
182 |
+
{"id": "multi_turn_base_181", "ground_truth": [["verify_traveler_information(first_name='Carlos', last_name='Martinez', date_of_birth='1968-03-23', passport_number='123456')"], ["get_flight_cost(travel_from='JFK', travel_to='LAX', travel_date='2024-10-10', travel_class='first')"], ["book_flight(access_token='abc123xyz', card_id='card_3456', travel_date='2024-10-10', travel_from='JFK', travel_to='LAX', travel_class='first', travel_cost=5700.0)"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"], ["ticket_login(username='cmartinez', password='SecurePass123')", "create_ticket(title='Flight Cancellation Experience', description='The abrupt cancellation caused significant inconvenience, disrupting my travel plans and causing financial loss.')"]]}
|
183 |
+
{"id": "multi_turn_base_182", "ground_truth": [["get_flight_cost(travel_from='ORD', travel_to='SVP', travel_date='2024-07-14', travel_class='business')"], ["set_budget_limit(access_token='abc123xyz456', budget_limit=20000.0)"]]}
|
184 |
+
{"id": "multi_turn_base_183", "ground_truth": [["verify_traveler_information(first_name='Matt', last_name='Bradley', date_of_birth='1995-04-23', passport_number='US9148817941')"], ["get_flight_cost(travel_from='RMS', travel_to='LAX', travel_date='2024-11-15', travel_class='economy')", "book_flight(access_token='abc123xyz456', card_id='card_2023', travel_date='2024-11-15', travel_from='RMS', travel_to='LAX', travel_class='economy', travel_cost=660.0)"], ["retrieve_invoice(access_token='abc123xyz456', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Requesting clarification on booking details')"], ["cancel_booking(access_token='abc123xyz456', booking_id='3426812')"], ["authenticate_twitter(username='john', password='john1234')", "post_tweet(content='Just booked a flight to LA!', tags=['#TravelSuccess', '#RivermistJourney'])"]]}
|
185 |
+
{"id": "multi_turn_base_184", "ground_truth": [["get_flight_cost(travel_from='JFK', travel_to='LAX', travel_date='2024-12-15', travel_class='business')", "book_flight(access_token='abc123xyz', card_id='card_2108', travel_date='2024-12-15', travel_from='JFK', travel_to='LAX', travel_class='business', travel_cost=1140.0)"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812')"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"], ["send_message(receiver_id='USR006', message='Hi Sam, my travel plans have changed. I\\'ll update you soon.')"], ["view_messages_sent()"], ["delete_message(receiver_id='USR006')"]]}
|
186 |
+
{"id": "multi_turn_base_185", "ground_truth": [["list_all_airports()", "get_flight_cost(travel_from='RMS', travel_to='SBK', travel_date='2024-12-15', travel_class='business')", "set_budget_limit(access_token='12345-67890', budget_limit=2000.0)"], ["purchase_insurance(access_token='12345-67890', insurance_type='comprehensive', booking_id='d184e2c0-2ebb-4f39-a525-d5e01b67dc6c', insurance_cost=300.0, card_id='0001')"], ["retrieve_invoice(access_token='12345-67890', booking_id='d184e2c0-2ebb-4f39-a525-d5e01b67dc6c')"]]}
|
187 |
+
{"id": "multi_turn_base_186", "ground_truth": [[ "get_flight_cost(travel_from='RMS', travel_to='JFK', travel_date='2024-12-15', travel_class='first')"], ["book_flight(access_token='secure_access_token_987654321', card_id='card_4526', travel_date='2024-12-15', travel_from='RMS', travel_to='JFK', travel_class='first', travel_cost=1050.0)"], ["retrieve_invoice(access_token='secure_access_token_987654321', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='No feedback yet on my inquiry regarding my flight arrangements. Please expedite the process.')"], ["cancel_booking(access_token='secure_access_token_987654321', booking_id='3426812')"], ["authenticate_twitter(username='john', password='john1234')", "post_tweet(content='Postponing my plans.', tags=['#Travel', '#PlansChanged'], mentions=['@AirlineSupport'])"]]}
|
188 |
+
{"id": "multi_turn_base_187", "ground_truth": [["purchase_insurance(access_token='token_abc123', insurance_type='comprehensive', booking_id='insurance_12345', insurance_cost=1500.0, card_id='card_4893')"], ["retrieve_invoice(access_token='token_abc123', booking_id='insurance_12345')"], ["contact_customer_support(booking_id='insurance_12345', message='There are discrepancies in my travel-related costs. Please assist.')"], ["ticket_login(username='mthompson', password='SecurePass123')", "create_ticket(priority=4, title='Discrepancy in Travel Costs', description='Feedback from customer support was unsatisfactory regarding discrepancies in travel costs.')"]]}
|
189 |
+
{"id": "multi_turn_base_188", "ground_truth": [["list_all_airports()", "get_flight_cost(travel_from='RMS', travel_to='SBK', travel_date='2024-09-19', travel_class='first')"], ["set_budget_limit(access_token='abc123xyz', budget_limit=10000.0)"], ["purchase_insurance(access_token='abc123xyz', booking_id='latest_reservation', insurance_type='comprehensive', insurance_cost=500.0, card_id='primary')"], ["retrieve_invoice(access_token='abc123xyz', booking_id='latest_reservation')"], ["authenticate_twitter(username='michael_smith', password='michael_cant_smith_smith')", "post_tweet(content='Excited for my upcoming adventure!', tags=['#TravelGoals'], mentions=['@TravelBuddy'])"], ["retweet(tweet_id=0)"]]}
|
190 |
+
{"id": "multi_turn_base_189", "ground_truth": [[ "get_flight_cost(travel_from='JFK',travel_to='HND',travel_date='2024-12-24',travel_class='first')", "book_flight(access_token='abc123xyz', card_id='card_5678', travel_date='2024-12-24', travel_from='JFK', travel_to='HND', travel_class='first', travel_cost=4000.0)"], ["authenticate_twitter(username='john', password='john1234')", "post_tweet(content='Flexibility is key! Plans changed, but the adventure continues.', tags=['#TravelBlog'], mentions=['@Spontaneity'])"], ["retweet(tweet_id=10)"]]}
|
191 |
+
{"id": "multi_turn_base_190", "ground_truth": [["book_flight(access_token='abc123xyz', card_id='crd6789', travel_date='2024-11-15', travel_from='OKD', travel_to='LAX', travel_class='business', travel_cost=880.0)"], ["purchase_insurance(access_token='abc123xyz', insurance_type='comprehensive protection', booking_id='3426812', insurance_cost=50.0, card_id='crd6789')"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Unexpected charge found on the invoice.')"], ["create_ticket(priority=2, title='Billing Concern', description='Detailed exchange with customer support regarding unexpected charge.')"]]}
|
192 |
+
{"id": "multi_turn_base_191", "ground_truth": [["verify_traveler_information(first_name='Michael', last_name='Thompson', date_of_birth='1995-08-15', passport_number='US1234')"], ["get_nearest_airport_by_city(location='San Francisco')"], ["get_flight_cost(travel_from='LAX', travel_to='SFO', travel_date='2024-12-15', travel_class='first')"], ["book_flight(access_token='auth_token_987654321', card_id='card_9012', travel_date='2024-12-15', travel_from='LAX', travel_to='SFO', travel_class='first', travel_cost=500.0)"], ["cancel_booking(access_token='auth_token_987654321', booking_id='3426812')"]]}
|
193 |
+
{"id": "multi_turn_base_192", "ground_truth": [["get_nearest_airport_by_city(location='Rivermist')", "get_nearest_airport_by_city(location='Stonebrook')"], ["get_flight_cost(travel_from='RMS', travel_to='LAX', travel_date='2024-08-15', travel_class='business')"], ["set_budget_limit(access_token='ABCDE12345', budget_limit=1500.0)"], ["book_flight(access_token='ABCDE12345', card_id='1432', travel_date='2024-08-15', travel_from='RMS', travel_to='LAX', travel_class='business', travel_cost=1320.0)"], ["retrieve_invoice(access_token='ABCDE12345', booking_id='3426812')"]]}
|
194 |
+
{"id": "multi_turn_base_193", "ground_truth": [["authenticate_travel(client_id='my_client_id', client_secret='my_client_secret', refresh_token='my_refresh_token', grant_type='read_write', user_first_name='Michael', user_last_name='Thompson')"], ["book_flight(access_token='251675', card_id='credit_9988', travel_date='2024-12-25', travel_from='JFK', travel_to='MPC', travel_class='first', travel_cost=3000.5)"], ["cancel_booking(access_token='251675', booking_id='5431449')"], ["create_ticket(priority=4, title='Urgent Change in Travel Plans', description='An unexpected change has arisen, and I need to cancel my booking for the trip to the Maldives.')"]]}
|
195 |
+
{"id": "multi_turn_base_194", "ground_truth": [["list_all_airports()", "get_flight_cost(travel_from='RMS', travel_to='BOS', travel_date='2024-10-31', travel_class='business')"], ["book_flight(access_token='abc123xyz', card_id='main1234', travel_date='2024-10-31', travel_from='RMS', travel_to='BOS', travel_class='business', travel_cost=400.0)"], ["purchase_insurance(access_token='abc123xyz', insurance_type='comprehensive', booking_id='3426812', insurance_cost=769.0, card_id='main1234')"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='Booking-related query.')"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"]]}
|
196 |
+
{"id": "multi_turn_base_195", "ground_truth": [["get_flight_cost(travel_from='RMS',travel_to='LAX',travel_date='2024-11-15',travel_class='business')", "book_flight(access_token='abc123xyz', card_id='1_3456', travel_date='2024-11-15', travel_from='RMS', travel_to='LAX', travel_class='business', travel_cost=1320.0)"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"], ["authenticate_twitter(username='michael_t', password='michaelSecurePass123')", "post_tweet(content='Just booked a flight to Los Angeles! Excited for the trip.')"], ["retweet(tweet_id=1)"]]}
|
197 |
+
{"id": "multi_turn_base_196", "ground_truth": [["compute_exchange_rate(base_currency='RMB', target_currency='USD', value=50000.0)", "set_budget_limit(access_token='abc123xyz', budget_limit=7142.86)"], ["get_flight_cost(travel_from='LHR',travel_to='CDG',travel_date='2024-11-15',travel_class='business')", "book_flight(access_token='abc123xyz', card_id='primary_8970', travel_date='2024-11-15', travel_from='LHR', travel_to='CDG', travel_class='business', travel_cost=400.0)"], ["cancel_booking(access_token='abc123xyz', booking_id='3426812')"], ["create_ticket(title='Cancellation Issue', description='Error encountered during flight cancellation process.')"], ["get_ticket(ticket_id=1)", "resolve_ticket(ticket_id=1, resolution='')"]]}
|
198 |
+
{"id": "multi_turn_base_197", "ground_truth": [["register_credit_card(access_token='abc123xyz456', card_number='1432-7890-6543-9876', expiration_date='12/2025', card_verification_number=321, cardholder_name='Michael Thompson')", "purchase_insurance(access_token='abc123xyz456', insurance_type='comprehensive', insurance_cost=2000.0, booking_id='insurance_12345',card_id='262919693687')"], ["retrieve_invoice(access_token='abc123xyz456', booking_id='insurance_12345')"], ["contact_customer_support(booking_id='insurance_12345', message='Unexpected hiccup during travel. Please prioritize our case for immediate attention.')"]]}
|
199 |
+
{"id": "multi_turn_base_198", "ground_truth": [["get_flight_cost(travel_from='SFO', travel_to='LAX', travel_date='2024-12-25', travel_class='first')", "book_flight(access_token='abc123token', card_id='6789', travel_date='2024-12-25', travel_from='SFO', travel_to='LAX', travel_class='first', travel_cost=2000.0)", "cancel_booking(access_token='abc123token', booking_id='3426812')", "authenticate_twitter(username='john', password='john1234')", "post_tweet(content='Disappointed over my canceled plans.', tags=['#TravelWoes'], mentions=['@CarlinaYates'])"]]}
|
200 |
+
{"id": "multi_turn_base_199", "ground_truth": [["get_flight_cost(travel_from='LAX', travel_to='JFK', travel_date='2024-04-15', travel_class='business')", "book_flight(access_token='abc123xyz', card_id='card_123456789', travel_date='2024-04-15', travel_from='LAX', travel_to='JFK', travel_class='business', travel_cost=2400.0)"], ["retrieve_invoice(access_token='abc123xyz', booking_id='3426812')"], ["contact_customer_support(booking_id='3426812', message='There were hiccups during the booking process. Please assist.')"], ["message_login(user_id='USR001')", "send_message(receiver_id='USR003', message='Update on flight issue and customer support contact.')"], ["view_messages_sent()"]]}
|
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 5.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
1 |
---
|
2 |
+
title: Gorilla Single Window
|
3 |
+
emoji: 🌍
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: pink
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.0.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
api_info.csv
ADDED
@@ -0,0 +1,1369 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
File,Class Name,Function Name,Description
|
2 |
+
gorilla_file_system.py,GorillaFileSystem,pwd(),"Return the current working directory path.
|
3 |
+
|
4 |
+
Returns:
|
5 |
+
|
6 |
+
• current_working_directory (str): The current working directory path
|
7 |
+
|
8 |
+
"
|
9 |
+
gorilla_file_system.py,GorillaFileSystem,ls(a: bool),"List the contents of the current directory.
|
10 |
+
|
11 |
+
Args:
|
12 |
+
|
13 |
+
• a (bool): Show hidden files and directories
|
14 |
+
|
15 |
+
Returns:
|
16 |
+
|
17 |
+
• current_directory_content (list): A list of the contents of the specified directory
|
18 |
+
|
19 |
+
"
|
20 |
+
gorilla_file_system.py,GorillaFileSystem,cd(folder: str),"Change the current working directory to the specified folder.
|
21 |
+
|
22 |
+
Args:
|
23 |
+
|
24 |
+
• folder (str): The folder of the directory to change to
|
25 |
+
|
26 |
+
Returns:
|
27 |
+
|
28 |
+
• current_working_directory (str): The new current working directory path
|
29 |
+
|
30 |
+
"
|
31 |
+
gorilla_file_system.py,GorillaFileSystem,mkdir(dir_name: str),"Create a new directory in the current directory.
|
32 |
+
|
33 |
+
Args:
|
34 |
+
|
35 |
+
• dir_name (str): The name of the new directory at current directory
|
36 |
+
|
37 |
+
Returns:
|
38 |
+
|
39 |
+
• error (dict): None if successful, or error message if directory already exists
|
40 |
+
|
41 |
+
"
|
42 |
+
gorilla_file_system.py,GorillaFileSystem,touch(file_name: str),"Create a new file in the current directory.
|
43 |
+
|
44 |
+
Args:
|
45 |
+
|
46 |
+
• file_name (str): The name of the new file in the current directory
|
47 |
+
|
48 |
+
Returns:
|
49 |
+
|
50 |
+
• error (dict): None if successful, or error message if file already exists
|
51 |
+
|
52 |
+
"
|
53 |
+
gorilla_file_system.py,GorillaFileSystem,"echo(content: str, file_name: str)","Write content to a file at current directory or display it in the terminal.
|
54 |
+
|
55 |
+
Args:
|
56 |
+
|
57 |
+
• content (str): The content to write or display
|
58 |
+
|
59 |
+
• file_name (str): The name of the file at current directory to write the content to
|
60 |
+
|
61 |
+
Returns:
|
62 |
+
|
63 |
+
• terminal_output (str): The content if no file name is provided, or None if written to file
|
64 |
+
|
65 |
+
"
|
66 |
+
gorilla_file_system.py,GorillaFileSystem,cat(file_name: str),"Display the contents of a file from currrent directory.
|
67 |
+
|
68 |
+
Args:
|
69 |
+
|
70 |
+
• file_name (str): The name of the file from current directory to display
|
71 |
+
|
72 |
+
Returns:
|
73 |
+
|
74 |
+
• file_content (str): The content of the file
|
75 |
+
|
76 |
+
"
|
77 |
+
gorilla_file_system.py,GorillaFileSystem,find(path: str),"Find any file or directories under specific path that contain name in its file name.This method searches for files and directories within a specified path that matchthe given name. If no name is provided, it returns all files and directoriesin the specified path and its subdirectories.
|
78 |
+
|
79 |
+
Args:
|
80 |
+
|
81 |
+
• path (str): The directory path to start the search
|
82 |
+
|
83 |
+
"
|
84 |
+
gorilla_file_system.py,GorillaFileSystem,"wc(file_name: str, mode: str)","Count the number of lines, words, and characters in a file from current directory.
|
85 |
+
|
86 |
+
Args:
|
87 |
+
|
88 |
+
• file_name (str): Name of the file of current directory to perform wc operation on
|
89 |
+
|
90 |
+
• mode (str): Mode of operation ('l' for lines, 'w' for words, 'c' for characters)
|
91 |
+
|
92 |
+
"
|
93 |
+
gorilla_file_system.py,GorillaFileSystem,sort(file_name: str),"Sort the contents of a file line by line.
|
94 |
+
|
95 |
+
Args:
|
96 |
+
|
97 |
+
• file_name (str): The name of the file appeared at current directory to sort
|
98 |
+
|
99 |
+
Returns:
|
100 |
+
|
101 |
+
• sorted_content (str): The sorted content of the file
|
102 |
+
|
103 |
+
"
|
104 |
+
gorilla_file_system.py,GorillaFileSystem,"grep(file_name: str, pattern: str)","Search for lines in a file at current directory that contain the specified pattern.
|
105 |
+
|
106 |
+
Args:
|
107 |
+
|
108 |
+
• file_name (str): The name of the file to search
|
109 |
+
|
110 |
+
• pattern (str): The pattern to search for
|
111 |
+
|
112 |
+
Returns:
|
113 |
+
|
114 |
+
• matching_lines (list): Lines that match the pattern
|
115 |
+
|
116 |
+
"
|
117 |
+
gorilla_file_system.py,GorillaFileSystem,"xargs(command: str, file_name: str)","Execute a command with arguments read from a file or standard input.
|
118 |
+
|
119 |
+
Args:
|
120 |
+
|
121 |
+
• command (str): The command to execute with arguments
|
122 |
+
|
123 |
+
• file_name (str): The file containing arguments
|
124 |
+
|
125 |
+
Returns:
|
126 |
+
|
127 |
+
• output (str): The result of the command execution
|
128 |
+
|
129 |
+
"
|
130 |
+
gorilla_file_system.py,GorillaFileSystem,du(human_readable: bool),"Estimate the disk usage of a directory and its contents.
|
131 |
+
|
132 |
+
Args:
|
133 |
+
|
134 |
+
• human_readable (bool): If True, returns the size in human-readable format (e
|
135 |
+
|
136 |
+
Returns:
|
137 |
+
|
138 |
+
• disk_usage (str): The estimated disk usage
|
139 |
+
|
140 |
+
"
|
141 |
+
gorilla_file_system.py,GorillaFileSystem,"tail(file_name: str, lines: int)","Display the last part of a file.
|
142 |
+
|
143 |
+
Args:
|
144 |
+
|
145 |
+
• file_name (str): The name of the file to display
|
146 |
+
|
147 |
+
• lines (int): The number of lines to display from the end of the file
|
148 |
+
|
149 |
+
Returns:
|
150 |
+
|
151 |
+
• last_lines (str): The last part of the file
|
152 |
+
|
153 |
+
"
|
154 |
+
gorilla_file_system.py,GorillaFileSystem,"diff(file_name1: str, file_name2: str)","Compare two files line by line at the current directory.
|
155 |
+
|
156 |
+
Args:
|
157 |
+
|
158 |
+
• file_name1 (str): The name of the first file in current directory
|
159 |
+
|
160 |
+
• file_name2 (str): The name of the second file in current directorry
|
161 |
+
|
162 |
+
Returns:
|
163 |
+
|
164 |
+
• diff_lines (str): The differences between the two files
|
165 |
+
|
166 |
+
"
|
167 |
+
gorilla_file_system.py,GorillaFileSystem,"mv(source: str, destination: str)","Move a file or directory from one location to another. so
|
168 |
+
|
169 |
+
Args:
|
170 |
+
|
171 |
+
• source (str): Source name of the file or directory to move
|
172 |
+
|
173 |
+
��� destination (str): The destination name to move the file or directory to
|
174 |
+
|
175 |
+
Returns:
|
176 |
+
|
177 |
+
• result (str): The result of the move operation
|
178 |
+
|
179 |
+
"
|
180 |
+
gorilla_file_system.py,GorillaFileSystem,rm(file_name: str),"Remove a file or directory.
|
181 |
+
|
182 |
+
Args:
|
183 |
+
|
184 |
+
• file_name (str): The name of the file or directory to remove
|
185 |
+
|
186 |
+
Returns:
|
187 |
+
|
188 |
+
• result (str): The result of the remove operation
|
189 |
+
|
190 |
+
"
|
191 |
+
gorilla_file_system.py,GorillaFileSystem,rmdir(dir_name: str),"Remove a directory at current directory.
|
192 |
+
|
193 |
+
Args:
|
194 |
+
|
195 |
+
• dir_name (str): The name of the directory to remove
|
196 |
+
|
197 |
+
Returns:
|
198 |
+
|
199 |
+
• result (str): The result of the remove operation
|
200 |
+
|
201 |
+
"
|
202 |
+
gorilla_file_system.py,GorillaFileSystem,"cp(source: str, destination: str)","Copy a file or directory from one location to another.If the destination is a directory, the source file or directory will be copied into the destination directory.Both source and destination must be local to the current directory.
|
203 |
+
|
204 |
+
Args:
|
205 |
+
|
206 |
+
• source (str): The name of the file or directory to copy
|
207 |
+
|
208 |
+
• destination (str): The destination anem to copy the file or directory to
|
209 |
+
|
210 |
+
Returns:
|
211 |
+
|
212 |
+
• result (str): The result of the copy operation or an error message if the operation fails
|
213 |
+
|
214 |
+
"
|
215 |
+
math_api.py,MathAPI,"logarithm(value: float, base: float, precision: int)","Compute the logarithm of a number with adjustable precision using mpmath.
|
216 |
+
|
217 |
+
Args:
|
218 |
+
|
219 |
+
• value (float): The number to compute the logarithm of
|
220 |
+
|
221 |
+
• base (float): The base of the logarithm
|
222 |
+
|
223 |
+
• precision (int): Desired precision for the result
|
224 |
+
|
225 |
+
"
|
226 |
+
math_api.py,MathAPI,mean(),"Calculate the mean of a list of numbers.
|
227 |
+
|
228 |
+
Returns:
|
229 |
+
|
230 |
+
• result (float): Mean of the numbers
|
231 |
+
|
232 |
+
"
|
233 |
+
math_api.py,MathAPI,standard_deviation(),"Calculate the standard deviation of a list of numbers.
|
234 |
+
|
235 |
+
Returns:
|
236 |
+
|
237 |
+
• result (float): Standard deviation of the numbers
|
238 |
+
|
239 |
+
"
|
240 |
+
math_api.py,MathAPI,"si_unit_conversion(value: float, unit_in: str, unit_out: str)","Convert a value from one SI unit to another.
|
241 |
+
|
242 |
+
Args:
|
243 |
+
|
244 |
+
• value (float): Value to be converted
|
245 |
+
|
246 |
+
• unit_in (str): Unit of the input value
|
247 |
+
|
248 |
+
• unit_out (str): Unit to convert the value to
|
249 |
+
|
250 |
+
Returns:
|
251 |
+
|
252 |
+
• result (float): Converted value in the new unit
|
253 |
+
|
254 |
+
"
|
255 |
+
math_api.py,MathAPI,"imperial_si_conversion(value: float, unit_in: str, unit_out: str)","Convert a value between imperial and SI units.
|
256 |
+
|
257 |
+
Args:
|
258 |
+
|
259 |
+
• value (float): Value to be converted
|
260 |
+
|
261 |
+
• unit_in (str): Unit of the input value
|
262 |
+
|
263 |
+
• unit_out (str): Unit to convert the value to
|
264 |
+
|
265 |
+
Returns:
|
266 |
+
|
267 |
+
• result (float): Converted value in the new unit
|
268 |
+
|
269 |
+
"
|
270 |
+
math_api.py,MathAPI,"add(a: float, b: float)","Add two numbers.
|
271 |
+
|
272 |
+
Args:
|
273 |
+
|
274 |
+
• a (float): First number
|
275 |
+
|
276 |
+
• b (float): Second number
|
277 |
+
|
278 |
+
Returns:
|
279 |
+
|
280 |
+
• result (float): Sum of the two numbers
|
281 |
+
|
282 |
+
"
|
283 |
+
math_api.py,MathAPI,"subtract(a: float, b: float)","Subtract one number from another.
|
284 |
+
|
285 |
+
Args:
|
286 |
+
|
287 |
+
• a (float): Number to subtract from
|
288 |
+
|
289 |
+
• b (float): Number to subtract
|
290 |
+
|
291 |
+
Returns:
|
292 |
+
|
293 |
+
• result (float): Difference between the two numbers
|
294 |
+
|
295 |
+
"
|
296 |
+
math_api.py,MathAPI,"multiply(a: float, b: float)","Multiply two numbers.
|
297 |
+
|
298 |
+
Args:
|
299 |
+
|
300 |
+
• a (float): First number
|
301 |
+
|
302 |
+
• b (float): Second number
|
303 |
+
|
304 |
+
Returns:
|
305 |
+
|
306 |
+
• result (float): Product of the two numbers
|
307 |
+
|
308 |
+
"
|
309 |
+
math_api.py,MathAPI,"divide(a: float, b: float)","Divide one number by another.
|
310 |
+
|
311 |
+
Args:
|
312 |
+
|
313 |
+
• a (float): Numerator
|
314 |
+
|
315 |
+
• b (float): Denominator
|
316 |
+
|
317 |
+
Returns:
|
318 |
+
|
319 |
+
• result (float): Quotient of the division
|
320 |
+
|
321 |
+
"
|
322 |
+
math_api.py,MathAPI,"power(base: float, exponent: float)","Raise a number to a power.
|
323 |
+
|
324 |
+
Args:
|
325 |
+
|
326 |
+
• base (float): The base number
|
327 |
+
|
328 |
+
• exponent (float): The exponent
|
329 |
+
|
330 |
+
Returns:
|
331 |
+
|
332 |
+
• result (float): The base raised to the power of the exponent
|
333 |
+
|
334 |
+
"
|
335 |
+
math_api.py,MathAPI,"square_root(number: float, precision: int)","Calculate the square root of a number with adjustable precision using the decimal module.
|
336 |
+
|
337 |
+
Args:
|
338 |
+
|
339 |
+
• number (float): The number to calculate the square root of
|
340 |
+
|
341 |
+
• precision (int): Desired precision for the result
|
342 |
+
|
343 |
+
"
|
344 |
+
math_api.py,MathAPI,absolute_value(number: float),"Calculate the absolute value of a number.
|
345 |
+
|
346 |
+
Args:
|
347 |
+
|
348 |
+
• number (float): The number to calculate the absolute value of
|
349 |
+
|
350 |
+
Returns:
|
351 |
+
|
352 |
+
• result (float): The absolute value of the number
|
353 |
+
|
354 |
+
"
|
355 |
+
math_api.py,MathAPI,"round_number(number: float, decimal_places: int)","Round a number to a specified number of decimal places.
|
356 |
+
|
357 |
+
Args:
|
358 |
+
|
359 |
+
• number (float): The number to round
|
360 |
+
|
361 |
+
• decimal_places (int): The number of decimal places to round to
|
362 |
+
|
363 |
+
Returns:
|
364 |
+
|
365 |
+
• result (float): The rounded number
|
366 |
+
|
367 |
+
"
|
368 |
+
math_api.py,MathAPI,"percentage(part: float, whole: float)","Calculate the percentage of a part relative to a whole.
|
369 |
+
|
370 |
+
Args:
|
371 |
+
|
372 |
+
• part (float): The part value
|
373 |
+
|
374 |
+
• whole (float): The whole value
|
375 |
+
|
376 |
+
Returns:
|
377 |
+
|
378 |
+
• result (float): The percentage of the part relative to the whole
|
379 |
+
|
380 |
+
"
|
381 |
+
math_api.py,MathAPI,min_value(),"Find the minimum value in a list of numbers.
|
382 |
+
|
383 |
+
Returns:
|
384 |
+
|
385 |
+
• result (float): The minimum value in the list
|
386 |
+
|
387 |
+
"
|
388 |
+
math_api.py,MathAPI,max_value(),"Find the maximum value in a list of numbers.
|
389 |
+
|
390 |
+
Returns:
|
391 |
+
|
392 |
+
• result (float): The maximum value in the list
|
393 |
+
|
394 |
+
"
|
395 |
+
math_api.py,MathAPI,sum_values(),"Calculate the sum of a list of numbers.
|
396 |
+
|
397 |
+
Returns:
|
398 |
+
|
399 |
+
• result (float): The sum of all numbers in the list
|
400 |
+
|
401 |
+
"
|
402 |
+
message_api.py,MessageAPI,generate_id,"No description provided.
|
403 |
+
|
404 |
+
"
|
405 |
+
message_api.py,MessageAPI,list_users(),"List all users in the workspace.
|
406 |
+
|
407 |
+
"
|
408 |
+
message_api.py,MessageAPI,get_user_id(user: str),"Get user ID from user name.
|
409 |
+
|
410 |
+
Args:
|
411 |
+
|
412 |
+
• user (str): User name of the user
|
413 |
+
|
414 |
+
"
|
415 |
+
message_api.py,MessageAPI,login(user_id: str),"Log in a user with the given user ID.
|
416 |
+
|
417 |
+
Args:
|
418 |
+
|
419 |
+
• user_id (str): User ID of the user to log in
|
420 |
+
|
421 |
+
Returns:
|
422 |
+
|
423 |
+
• login_status (bool): True if login was successful, False otherwise
|
424 |
+
|
425 |
+
• message (str): A message describing the result of the login attempt
|
426 |
+
|
427 |
+
"
|
428 |
+
message_api.py,MessageAPI,"send_message(sender_id: str, receiver_id: str, message: str)","Send a message to a user.
|
429 |
+
|
430 |
+
Args:
|
431 |
+
|
432 |
+
• sender_id (str): User ID of the user sending the message
|
433 |
+
|
434 |
+
• receiver_id (str): User ID of the user to send the message to
|
435 |
+
|
436 |
+
• message (str): Message to be sent
|
437 |
+
|
438 |
+
Returns:
|
439 |
+
|
440 |
+
• sent_status (bool): True if the message was sent successfully, False otherwise
|
441 |
+
|
442 |
+
• message_id (int): ID of the sent message
|
443 |
+
|
444 |
+
• message (str): A message describing the result of the send attempt
|
445 |
+
|
446 |
+
"
|
447 |
+
message_api.py,MessageAPI,"delete_message(sender_id: str, receiver_id: str, message_id: int)","Delete a message sent to a user.
|
448 |
+
|
449 |
+
Args:
|
450 |
+
|
451 |
+
• sender_id (str): User ID of the user sending the message
|
452 |
+
|
453 |
+
• receiver_id (str): User ID of the user to send the message to
|
454 |
+
|
455 |
+
• message_id (int): ID of the message to be deleted
|
456 |
+
|
457 |
+
Returns:
|
458 |
+
|
459 |
+
• deleted_status (bool): True if the message was deleted successfully, False otherwise
|
460 |
+
|
461 |
+
• message_id (int): ID of the deleted message
|
462 |
+
|
463 |
+
• message (str): A message describing the result of the deletion attempt
|
464 |
+
|
465 |
+
"
|
466 |
+
message_api.py,MessageAPI,view_messages_received(),"View all messages sent to the current user.
|
467 |
+
|
468 |
+
"
|
469 |
+
message_api.py,MessageAPI,view_messages_sent(),"View all historical messages sent by the current user.
|
470 |
+
|
471 |
+
"
|
472 |
+
message_api.py,MessageAPI,add_contact(user_name: str),"Add a contact to the workspace.
|
473 |
+
|
474 |
+
Args:
|
475 |
+
|
476 |
+
• user_name (str): User name of contact to be added
|
477 |
+
|
478 |
+
Returns:
|
479 |
+
|
480 |
+
• added_status (bool): True if the contact was added successfully, False otherwise
|
481 |
+
|
482 |
+
• user_id (str): User ID of the added contact
|
483 |
+
|
484 |
+
• message (str): A message describing the result of the addition attempt
|
485 |
+
|
486 |
+
"
|
487 |
+
message_api.py,MessageAPI,search_messages(keyword: str),"Search for messages containing a specific keyword.
|
488 |
+
|
489 |
+
Args:
|
490 |
+
|
491 |
+
• keyword (str): The keyword to search for in messages
|
492 |
+
|
493 |
+
Returns:
|
494 |
+
|
495 |
+
• sender_id (str): The ID of the user who sent the message
|
496 |
+
|
497 |
+
• receiver_id (str): The ID of the user who received the message
|
498 |
+
|
499 |
+
"
|
500 |
+
message_api.py,MessageAPI,"get_message_stats(sent_count: int, received_count: int, total_contacts: int)","Get statistics about messages for the current user.
|
501 |
+
|
502 |
+
Args:
|
503 |
+
|
504 |
+
• sent_count (int): Number of messages sent by the current user
|
505 |
+
|
506 |
+
• received_count (int): Number of messages received by the current user
|
507 |
+
|
508 |
+
• total_contacts (int): Total number of contacts the user has interacted with
|
509 |
+
|
510 |
+
"
|
511 |
+
posting_api.py,TwitterAPI,"authenticate(username: str, password: str)","Authenticate a user with username and password.
|
512 |
+
|
513 |
+
Args:
|
514 |
+
|
515 |
+
• username (str): Username of the user
|
516 |
+
|
517 |
+
• password (str): Password of the user
|
518 |
+
|
519 |
+
Returns:
|
520 |
+
|
521 |
+
• authentication_status (bool): True if authenticated, False otherwise
|
522 |
+
|
523 |
+
"
|
524 |
+
posting_api.py,TwitterAPI,post_tweet(content: str),"Post a tweet for the authenticated user.
|
525 |
+
|
526 |
+
Args:
|
527 |
+
|
528 |
+
• content (str): Content of the tweet
|
529 |
+
|
530 |
+
Returns:
|
531 |
+
|
532 |
+
• id (int): ID of the posted tweet
|
533 |
+
|
534 |
+
• username (str): Username of the poster
|
535 |
+
|
536 |
+
• content (str): Content of the tweet
|
537 |
+
|
538 |
+
"
|
539 |
+
posting_api.py,TwitterAPI,retweet(tweet_id: int),"Retweet a tweet for the authenticated user.
|
540 |
+
|
541 |
+
Args:
|
542 |
+
|
543 |
+
• tweet_id (int): ID of the tweet to retweet
|
544 |
+
|
545 |
+
Returns:
|
546 |
+
|
547 |
+
• retweet_status (str): Status of the retweet action
|
548 |
+
|
549 |
+
"
|
550 |
+
posting_api.py,TwitterAPI,"comment(tweet_id: int, comment_content: str)","Comment on a tweet for the authenticated user.
|
551 |
+
|
552 |
+
Args:
|
553 |
+
|
554 |
+
• tweet_id (int): ID of the tweet to comment on
|
555 |
+
|
556 |
+
• comment_content (str): Content of the comment
|
557 |
+
|
558 |
+
Returns:
|
559 |
+
|
560 |
+
• comment_status (str): Status of the comment action
|
561 |
+
|
562 |
+
"
|
563 |
+
posting_api.py,TwitterAPI,mention(tweet_id: int),"Mention specified users in a tweet.
|
564 |
+
|
565 |
+
Args:
|
566 |
+
|
567 |
+
• tweet_id (int): ID of the tweet where users are mentioned
|
568 |
+
|
569 |
+
Returns:
|
570 |
+
|
571 |
+
• mention_status (str): Status of the mention action
|
572 |
+
|
573 |
+
"
|
574 |
+
posting_api.py,TwitterAPI,follow_user(username_to_follow: str),"Follow a user for the authenticated user.
|
575 |
+
|
576 |
+
Args:
|
577 |
+
|
578 |
+
• username_to_follow (str): Username of the user to follow
|
579 |
+
|
580 |
+
Returns:
|
581 |
+
|
582 |
+
• follow_status (bool): True if followed, False if already following
|
583 |
+
|
584 |
+
"
|
585 |
+
posting_api.py,TwitterAPI,list_all_following(),"List all users that the authenticated user is following.
|
586 |
+
|
587 |
+
"
|
588 |
+
posting_api.py,TwitterAPI,unfollow_user(username_to_unfollow: str),"Unfollow a user for the authenticated user.
|
589 |
+
|
590 |
+
Args:
|
591 |
+
|
592 |
+
• username_to_unfollow (str): Username of the user to unfollow
|
593 |
+
|
594 |
+
Returns:
|
595 |
+
|
596 |
+
• unfollow_status (bool): True if unfollowed, False if not following
|
597 |
+
|
598 |
+
"
|
599 |
+
posting_api.py,TwitterAPI,get_tweet(tweet_id: int),"Retrieve a specific tweet.
|
600 |
+
|
601 |
+
Args:
|
602 |
+
|
603 |
+
• tweet_id (int): ID of the tweet to retrieve
|
604 |
+
|
605 |
+
Returns:
|
606 |
+
|
607 |
+
• id (int): ID of the retrieved tweet
|
608 |
+
|
609 |
+
• username (str): Username of the tweet's author
|
610 |
+
|
611 |
+
• content (str): Content of the tweet
|
612 |
+
|
613 |
+
"
|
614 |
+
posting_api.py,TwitterAPI,get_user_tweets(username: str),"Retrieve all tweets from a specific user.
|
615 |
+
|
616 |
+
Args:
|
617 |
+
|
618 |
+
• username (str): Username of the user whose tweets to retrieve
|
619 |
+
|
620 |
+
"
|
621 |
+
posting_api.py,TwitterAPI,search_tweets(keyword: str),"Search for tweets containing a specific keyword.
|
622 |
+
|
623 |
+
Args:
|
624 |
+
|
625 |
+
• keyword (str): Keyword to search for in tweets
|
626 |
+
|
627 |
+
"
|
628 |
+
posting_api.py,TwitterAPI,get_tweet_comments(tweet_id: int),"Retrieve all comments for a specific tweet.
|
629 |
+
|
630 |
+
Args:
|
631 |
+
|
632 |
+
• tweet_id (int): ID of the tweet to retrieve comments for
|
633 |
+
|
634 |
+
"
|
635 |
+
posting_api.py,TwitterAPI,get_user_stats(username: str),"Get statistics for a specific user.
|
636 |
+
|
637 |
+
Args:
|
638 |
+
|
639 |
+
• username (str): Username of the user to get statistics for
|
640 |
+
|
641 |
+
Returns:
|
642 |
+
|
643 |
+
• tweet_count (int): Number of tweets posted by the user
|
644 |
+
|
645 |
+
• following_count (int): Number of users the specified user is following
|
646 |
+
|
647 |
+
• retweet_count (int): Number of retweets made by the user
|
648 |
+
|
649 |
+
"
|
650 |
+
ticket_api.py,TicketAPI,"create_ticket(title: str, description: str, priority: int)","Create a ticket in the system and queue it.
|
651 |
+
|
652 |
+
Args:
|
653 |
+
|
654 |
+
• title (str): Title of the ticket
|
655 |
+
|
656 |
+
• description (str): Description of the ticket
|
657 |
+
|
658 |
+
• priority (int): Priority of the ticket, from 1 to 5
|
659 |
+
|
660 |
+
Returns:
|
661 |
+
|
662 |
+
• id (int): Unique identifier of the ticket
|
663 |
+
|
664 |
+
• title (str): Title of the ticket
|
665 |
+
|
666 |
+
• description (str): Description of the ticket
|
667 |
+
|
668 |
+
• status (str): Current status of the ticket
|
669 |
+
|
670 |
+
• priority (int): Priority level of the ticket
|
671 |
+
|
672 |
+
"
|
673 |
+
ticket_api.py,TicketAPI,get_ticket(ticket_id: int),"Get a specific ticket by its ID.
|
674 |
+
|
675 |
+
Args:
|
676 |
+
|
677 |
+
• ticket_id (int): ID of the ticket to retrieve
|
678 |
+
|
679 |
+
Returns:
|
680 |
+
|
681 |
+
• id (int): Unique identifier of the ticket
|
682 |
+
|
683 |
+
• title (str): Title of the ticket
|
684 |
+
|
685 |
+
• description (str): Description of the ticket
|
686 |
+
|
687 |
+
• status (str): Current status of the ticket
|
688 |
+
|
689 |
+
• priority (int): Priority level of the ticket
|
690 |
+
|
691 |
+
• created_by (str): Username of the ticket creator
|
692 |
+
|
693 |
+
"
|
694 |
+
ticket_api.py,TicketAPI,close_ticket(ticket_id: int),"Close a ticket.
|
695 |
+
|
696 |
+
Args:
|
697 |
+
|
698 |
+
• ticket_id (int): ID of the ticket to be closed
|
699 |
+
|
700 |
+
Returns:
|
701 |
+
|
702 |
+
• status (str): Status of the close operation
|
703 |
+
|
704 |
+
"
|
705 |
+
ticket_api.py,TicketAPI,"resolve_ticket(ticket_id: int, resolution: str)","Resolve a ticket with a resolution.
|
706 |
+
|
707 |
+
Args:
|
708 |
+
|
709 |
+
• ticket_id (int): ID of the ticket to be resolved
|
710 |
+
|
711 |
+
• resolution (str): Resolution details for the ticket
|
712 |
+
|
713 |
+
Returns:
|
714 |
+
|
715 |
+
• status (str): Status of the resolve operation
|
716 |
+
|
717 |
+
"
|
718 |
+
ticket_api.py,TicketAPI,edit_ticket(ticket_id: int),"Modify the details of an existing ticket.
|
719 |
+
|
720 |
+
Args:
|
721 |
+
|
722 |
+
• ticket_id (int): ID of the ticket to be changed
|
723 |
+
|
724 |
+
Returns:
|
725 |
+
|
726 |
+
• status (str): Status of the update operation
|
727 |
+
|
728 |
+
"
|
729 |
+
ticket_api.py,TicketAPI,find_ticket(ticket_id: int),"Find a ticket by its ID.
|
730 |
+
|
731 |
+
Args:
|
732 |
+
|
733 |
+
• ticket_id (int): ID of the ticket to find
|
734 |
+
|
735 |
+
"
|
736 |
+
ticket_api.py,TicketAPI,"login(username: str, password: str)","Authenticate a user.
|
737 |
+
|
738 |
+
Args:
|
739 |
+
|
740 |
+
• username (str): Username of the user
|
741 |
+
|
742 |
+
• password (str): Password of the user
|
743 |
+
|
744 |
+
Returns:
|
745 |
+
|
746 |
+
• success (bool): True if login was successful, False otherwise
|
747 |
+
|
748 |
+
"
|
749 |
+
ticket_api.py,TicketAPI,logout(success: bool),"Log out the current user.
|
750 |
+
|
751 |
+
Args:
|
752 |
+
|
753 |
+
• success (bool): True if logout was successful, False otherwise
|
754 |
+
|
755 |
+
"
|
756 |
+
ticket_api.py,TicketAPI,get_user_tickets(),"Get all tickets created by the current user, optionally filtered by status.
|
757 |
+
|
758 |
+
"
|
759 |
+
trading_bot.py,TradingBot,get_current_time(current_time: str),"Get the current time.
|
760 |
+
|
761 |
+
Args:
|
762 |
+
|
763 |
+
• current_time (str): Current time in HH:MM AM/PM format
|
764 |
+
|
765 |
+
"
|
766 |
+
trading_bot.py,TradingBot,update_market_status(current_time_str: str),"Update the market status based on the current time.
|
767 |
+
|
768 |
+
Args:
|
769 |
+
|
770 |
+
• current_time_str (str): Current time in HH:MM AM/PM format
|
771 |
+
|
772 |
+
Returns:
|
773 |
+
|
774 |
+
• status (str): Status of the market ('Open' or 'Closed')
|
775 |
+
|
776 |
+
"
|
777 |
+
trading_bot.py,TradingBot,get_symbol_by_name(name: str),"Get the symbol of a stock by company name.
|
778 |
+
|
779 |
+
Args:
|
780 |
+
|
781 |
+
• name (str): Name of the company
|
782 |
+
|
783 |
+
Returns:
|
784 |
+
|
785 |
+
• symbol (str): Symbol of the stock or ""Stock not found"" if not available
|
786 |
+
|
787 |
+
"
|
788 |
+
trading_bot.py,TradingBot,get_stock_info(symbol: str),"Get the details of a stock.
|
789 |
+
|
790 |
+
Args:
|
791 |
+
|
792 |
+
• symbol (str): Symbol that uniquely identifies the stock
|
793 |
+
|
794 |
+
Returns:
|
795 |
+
|
796 |
+
• price (float): Current price of the stock
|
797 |
+
|
798 |
+
• percent_change (float): Percentage change in stock price
|
799 |
+
|
800 |
+
• volume (float): Trading volume of the stock
|
801 |
+
|
802 |
+
• MA5 (float): 5-day Moving Average of the stock
|
803 |
+
|
804 |
+
• MA20 (float): 20-day Moving Average of the stock
|
805 |
+
|
806 |
+
"
|
807 |
+
trading_bot.py,TradingBot,get_order_details(order_id: int),"Get the details of an order.
|
808 |
+
|
809 |
+
Args:
|
810 |
+
|
811 |
+
• order_id (int): ID of the order
|
812 |
+
|
813 |
+
Returns:
|
814 |
+
|
815 |
+
• symbol (str): Symbol of the stock in the order
|
816 |
+
|
817 |
+
• price (float): Price at which the order was placed
|
818 |
+
|
819 |
+
• num_shares (int): Number of shares in the order
|
820 |
+
|
821 |
+
• status (str): Current status of the order
|
822 |
+
|
823 |
+
"
|
824 |
+
trading_bot.py,TradingBot,cancel_order(order_id: int),"Cancel an order.
|
825 |
+
|
826 |
+
Args:
|
827 |
+
|
828 |
+
• order_id (int): ID of the order to cancel
|
829 |
+
|
830 |
+
Returns:
|
831 |
+
|
832 |
+
• order_id (int): ID of the cancelled order
|
833 |
+
|
834 |
+
• status (str): New status of the order after cancellation attempt
|
835 |
+
|
836 |
+
"
|
837 |
+
trading_bot.py,TradingBot,"place_order(order_type: str, symbol: str, price: float, amount: int)","Place an order.
|
838 |
+
|
839 |
+
Args:
|
840 |
+
|
841 |
+
• order_type (str): Type of the order (Buy/Sell)
|
842 |
+
|
843 |
+
• symbol (str): Symbol of the stock to trade
|
844 |
+
|
845 |
+
• price (float): Price at which to place the order
|
846 |
+
|
847 |
+
• amount (int): Number of shares to trade
|
848 |
+
|
849 |
+
Returns:
|
850 |
+
|
851 |
+
• order_id (int): ID of the newly placed order
|
852 |
+
|
853 |
+
• order_type (str): Type of the order (Buy/Sell)
|
854 |
+
|
855 |
+
• status (str): Initial status of the order
|
856 |
+
|
857 |
+
• price (float): Price at which the order was placed
|
858 |
+
|
859 |
+
• amount (int): Number of shares in the order
|
860 |
+
|
861 |
+
"
|
862 |
+
trading_bot.py,TradingBot,"make_transaction(account_id: int, xact_type: str, amount: float)","Make a deposit or withdrawal based on specified amount.
|
863 |
+
|
864 |
+
Args:
|
865 |
+
|
866 |
+
• account_id (int): ID of the account
|
867 |
+
|
868 |
+
• xact_type (str): Transaction type (deposit or withdrawal)
|
869 |
+
|
870 |
+
• amount (float): Amount to deposit or withdraw
|
871 |
+
|
872 |
+
Returns:
|
873 |
+
|
874 |
+
• status (str): Status of the transaction
|
875 |
+
|
876 |
+
• new_balance (float): Updated account balance after the transaction
|
877 |
+
|
878 |
+
"
|
879 |
+
trading_bot.py,TradingBot,"get_account_info(account_id: int, balance: float, binding_card: int)","Get account information.
|
880 |
+
|
881 |
+
Args:
|
882 |
+
|
883 |
+
• account_id (int): ID of the account
|
884 |
+
|
885 |
+
• balance (float): Current balance of the account
|
886 |
+
|
887 |
+
• binding_card (int): Card number associated with the account
|
888 |
+
|
889 |
+
"
|
890 |
+
trading_bot.py,TradingBot,"login(username: str, password: str)","Handle user login.
|
891 |
+
|
892 |
+
Args:
|
893 |
+
|
894 |
+
• username (str): Username for authentication
|
895 |
+
|
896 |
+
• password (str): Password for authentication
|
897 |
+
|
898 |
+
Returns:
|
899 |
+
|
900 |
+
• status (str): Login status message
|
901 |
+
|
902 |
+
"
|
903 |
+
trading_bot.py,TradingBot,logout(status: str),"Handle user logout.
|
904 |
+
|
905 |
+
Args:
|
906 |
+
|
907 |
+
• status (str): Logout status message
|
908 |
+
|
909 |
+
"
|
910 |
+
trading_bot.py,TradingBot,fund_account(amount: float),"Fund the account with the specified amount.
|
911 |
+
|
912 |
+
Args:
|
913 |
+
|
914 |
+
• amount (float): Amount to fund the account with
|
915 |
+
|
916 |
+
Returns:
|
917 |
+
|
918 |
+
• status (str): Status of the funding operation
|
919 |
+
|
920 |
+
• new_balance (float): Updated account balance after funding
|
921 |
+
|
922 |
+
"
|
923 |
+
trading_bot.py,TradingBot,add_stock_to_watchlist(symbol: str),"Add a stock to the watchlist.
|
924 |
+
|
925 |
+
Args:
|
926 |
+
|
927 |
+
• symbol (str): Symbol of the stock to add
|
928 |
+
|
929 |
+
Returns:
|
930 |
+
|
931 |
+
• status (str): Status of the addition operation
|
932 |
+
|
933 |
+
"
|
934 |
+
trading_bot.py,TradingBot,remove_stock_from_watchlist(symbol: str),"Remove a stock from the watchlist.
|
935 |
+
|
936 |
+
Args:
|
937 |
+
|
938 |
+
• symbol (str): Symbol of the stock to remove
|
939 |
+
|
940 |
+
Returns:
|
941 |
+
|
942 |
+
• status (str): Status of the removal operation
|
943 |
+
|
944 |
+
"
|
945 |
+
trading_bot.py,TradingBot,get_watchlist(),"Get the watchlist.
|
946 |
+
|
947 |
+
"
|
948 |
+
trading_bot.py,TradingBot,get_transaction_history(),"Get the transaction history within a specified date range.
|
949 |
+
|
950 |
+
"
|
951 |
+
trading_bot.py,TradingBot,"update_stock_price(symbol: str, new_price: float)","Update the price of a stock.
|
952 |
+
|
953 |
+
Args:
|
954 |
+
|
955 |
+
• symbol (str): Symbol of the stock to update
|
956 |
+
|
957 |
+
• new_price (float): New price of the stock
|
958 |
+
|
959 |
+
Returns:
|
960 |
+
|
961 |
+
• symbol (str): Symbol of the updated stock
|
962 |
+
|
963 |
+
• old_price (float): Previous price of the stock
|
964 |
+
|
965 |
+
• new_price (float): Updated price of the stock
|
966 |
+
|
967 |
+
"
|
968 |
+
trading_bot.py,TradingBot,get_available_stocks(sector: str),"Get a list of stock symbols in the given sector.
|
969 |
+
|
970 |
+
Args:
|
971 |
+
|
972 |
+
• sector (str): The sector to retrieve stocks from (e
|
973 |
+
|
974 |
+
"
|
975 |
+
trading_bot.py,TradingBot,"filter_stocks_by_price(min_price: float, max_price: float)","Filter stocks based on a price range.
|
976 |
+
|
977 |
+
Args:
|
978 |
+
|
979 |
+
• min_price (float): Minimum stock price
|
980 |
+
|
981 |
+
• max_price (float): Maximum stock price
|
982 |
+
|
983 |
+
"
|
984 |
+
trading_bot.py,TradingBot,add_to_watchlist(),"Add a list of stocks to the watchlist.
|
985 |
+
|
986 |
+
"
|
987 |
+
trading_bot.py,TradingBot,notify_price_change(threshold: float),"Notify if there is a significant price change in the stocks.
|
988 |
+
|
989 |
+
Args:
|
990 |
+
|
991 |
+
• threshold (float): Percentage change threshold to trigger a notification
|
992 |
+
|
993 |
+
"
|
994 |
+
travel_booking.py,TravelAPI,"authenticate(client_id: str, user_first_name: str)","Authenticate the user with the travel API
|
995 |
+
|
996 |
+
Args:
|
997 |
+
|
998 |
+
• client_id (str): Required The client applications client_id supplied by App Management client_secret (str): Required The client applications client_secret supplied by App Management refresh_token (str): Required The refresh token obtained from the initial authentication grant_type (str): Required The grant type of the authentication request
|
999 |
+
|
1000 |
+
• user_first_name (str): Required The first name of the user user_last_name (str): Required The last name of the user
|
1001 |
+
|
1002 |
+
Returns:
|
1003 |
+
|
1004 |
+
• expires_in (int): The number of time it can use until the access token expires access_token (str): The access token to be used in the Authorization header of future requests token_type (str): The type of token scope (str): The scope of the token
|
1005 |
+
|
1006 |
+
"
|
1007 |
+
travel_booking.py,TravelAPI,get_budget_fiscal_year(),"Get the budget fiscal year
|
1008 |
+
|
1009 |
+
"
|
1010 |
+
travel_booking.py,TravelAPI,register_credit_card(access_token: str),"Register a credit card
|
1011 |
+
|
1012 |
+
Args:
|
1013 |
+
|
1014 |
+
• access_token (str): Required The access token obtained from the authenticate method card_number (str): Required The credit card number expiration_date (str): Required The expiration date of the credit card in the format MM/YYYY cardholder_name (str): Required The name of the cardholder card_verification_number (int): Required The card verification number
|
1015 |
+
|
1016 |
+
Returns:
|
1017 |
+
|
1018 |
+
• card_id (str): The ID of the registered credit card
|
1019 |
+
|
1020 |
+
"
|
1021 |
+
travel_booking.py,TravelAPI,get_flight_cost(travel_from: str),"Get the cost of a flight in USD based on date, location, and class
|
1022 |
+
|
1023 |
+
Args:
|
1024 |
+
|
1025 |
+
• travel_from (str): Required The location the travel is from travel_to (str): Required The location the travel is to travel_date (str): Required The date of the travel in the format YYYY-MM-DD travel_class (str): Required The class of the travel
|
1026 |
+
|
1027 |
+
Returns:
|
1028 |
+
|
1029 |
+
• travel_cost (float): The cost of the travel
|
1030 |
+
|
1031 |
+
"
|
1032 |
+
travel_booking.py,TravelAPI,get_credit_card_balance(access_token: str),"Get the balance of a credit card
|
1033 |
+
|
1034 |
+
Args:
|
1035 |
+
|
1036 |
+
• access_token (str): Required The access token obtained from the authenticate card_id (str): Required The ID of the credit card
|
1037 |
+
|
1038 |
+
Returns:
|
1039 |
+
|
1040 |
+
• card_balance (float): The balance of the credit card
|
1041 |
+
|
1042 |
+
"
|
1043 |
+
travel_booking.py,TravelAPI,book_flight(access_token: str),"Book a flight given the travel information. From and To should be the airport codes in the IATA format.
|
1044 |
+
|
1045 |
+
Args:
|
1046 |
+
|
1047 |
+
• access_token (str): Required The access token obtained from the authenticate card_id (str): Required The ID of the credit card to use for the booking travel_date (str): Required The date of the travel in the format YYYY-MM-DD travel_from (str): Required The location the travel is from travel_to (str): Required The location the travel is to travel_class (str): Required The class of the travel travel_cost (float): Required The cost of the travel
|
1048 |
+
|
1049 |
+
Returns:
|
1050 |
+
|
1051 |
+
• booking_id (str): The ID of the booking transaction_id (str): The ID of the transaction booking_status (bool): The status of the booking, True if successful, False if failed error (str): The error message if the booking failed
|
1052 |
+
|
1053 |
+
"
|
1054 |
+
travel_booking.py,TravelAPI,retrieve_invoice(access_token: str),"Retrieve the invoice for a booking
|
1055 |
+
|
1056 |
+
Args:
|
1057 |
+
|
1058 |
+
• access_token (str): Required The access token obtained from the authenticate booking_id (Optional[str]): Optional The ID of the booking insurance_id (Optional[str]): Optional The ID of the insurance
|
1059 |
+
|
1060 |
+
Returns:
|
1061 |
+
|
1062 |
+
• invoice (dict): The invoice for the booking error (str): The error message if the booking was not found
|
1063 |
+
|
1064 |
+
"
|
1065 |
+
travel_booking.py,TravelAPI,list_all_airports(),"List all available airports
|
1066 |
+
|
1067 |
+
"
|
1068 |
+
travel_booking.py,TravelAPI,cancel_booking(access_token: str),"Cancel a booking
|
1069 |
+
|
1070 |
+
Args:
|
1071 |
+
|
1072 |
+
• access_token (str): Required The access token obtained from the authenticate booking_id (str): Required The ID of the booking
|
1073 |
+
|
1074 |
+
Returns:
|
1075 |
+
|
1076 |
+
• cancel_status (bool): The status of the cancellation, True if successful, False if failed error (str): The error message if the cancellation failed
|
1077 |
+
|
1078 |
+
"
|
1079 |
+
travel_booking.py,TravelAPI,compute_exchange_rate(base_currency: str),"Compute the exchange rate between two currencies
|
1080 |
+
|
1081 |
+
Args:
|
1082 |
+
|
1083 |
+
• base_currency (str): Required The base currency target_currency (str): Required The target currency value (float): Required The value to convert
|
1084 |
+
|
1085 |
+
Returns:
|
1086 |
+
|
1087 |
+
• exchanged_value (float): The value after the exchange
|
1088 |
+
|
1089 |
+
"
|
1090 |
+
travel_booking.py,TravelAPI,verify_traveler_information(first_name: str),"Verify the traveler information
|
1091 |
+
|
1092 |
+
Args:
|
1093 |
+
|
1094 |
+
• first_name (str): Required The first name of the traveler last_name (str): Required The last name of the traveler date_of_birth (str): Required The date of birth of the traveler in the format YYYY-MM-DD passport_number (str): Required The passport number of the traveler
|
1095 |
+
|
1096 |
+
Returns:
|
1097 |
+
|
1098 |
+
• verification_status (bool): The status of the verification, True if successful, False if failed verification_failure (str): The reason for the verification failure
|
1099 |
+
|
1100 |
+
"
|
1101 |
+
travel_booking.py,TravelAPI,set_budget_limit(access_token: str),"Set the budget limit for the user
|
1102 |
+
|
1103 |
+
Args:
|
1104 |
+
|
1105 |
+
• access_token (str): Required The access token obtained from the authenticate budget_limit (float): Required The budget limit to set in USD
|
1106 |
+
|
1107 |
+
Returns:
|
1108 |
+
|
1109 |
+
• budget_limit (float): The budget limit set in USD
|
1110 |
+
|
1111 |
+
"
|
1112 |
+
travel_booking.py,TravelAPI,get_nearest_airport_by_city(location: str),"Get the nearest airport to a location
|
1113 |
+
|
1114 |
+
Args:
|
1115 |
+
|
1116 |
+
• location (str): Required The location to find the nearest airport to
|
1117 |
+
|
1118 |
+
Returns:
|
1119 |
+
|
1120 |
+
• nearest_airport (str): The nearest airport to the location
|
1121 |
+
|
1122 |
+
"
|
1123 |
+
travel_booking.py,TravelAPI,purchase_insurance(access_token: str),"Purchase insurance
|
1124 |
+
|
1125 |
+
Args:
|
1126 |
+
|
1127 |
+
• access_token (str): Required The access token obtained from the authenticate insurance_type (str): Required The type of insurance to purchase insurance_cost (float): Required The cost of the insurance booking_id (str): Required The ID of the booking credit_card_id (str): Required The ID of the credit card to use for the
|
1128 |
+
|
1129 |
+
Returns:
|
1130 |
+
|
1131 |
+
• insurance_id (str): The ID of the insurance insurance_status (bool): The status of the insurance purchase, True if successful, False if failed error (str): The error message if the insurance purchase failed
|
1132 |
+
|
1133 |
+
"
|
1134 |
+
travel_booking.py,TravelAPI,contact_customer_support(booking_id: str),"Contact customer support
|
1135 |
+
|
1136 |
+
Args:
|
1137 |
+
|
1138 |
+
• booking_id (str): Required The ID of the booking message (str): Required The message to send to customer support
|
1139 |
+
|
1140 |
+
Returns:
|
1141 |
+
|
1142 |
+
• customer_support_message (str): The message from customer support
|
1143 |
+
|
1144 |
+
"
|
1145 |
+
travel_booking.py,TravelAPI,get_all_credit_cards(),"Get all registered credit cards
|
1146 |
+
|
1147 |
+
"
|
1148 |
+
vehicle_control.py,VehicleControlAPI,startEngine(ignitionMode: str),"Starts the engine of the vehicle.
|
1149 |
+
|
1150 |
+
Args:
|
1151 |
+
|
1152 |
+
• ignitionMode (str): The ignition mode of the vehicle
|
1153 |
+
|
1154 |
+
Returns:
|
1155 |
+
|
1156 |
+
• engineState (str): The state of the engine
|
1157 |
+
|
1158 |
+
• fuelLevel (float): The fuel level of the vehicle in gallons
|
1159 |
+
|
1160 |
+
• batteryVoltage (float): The battery voltage of the vehicle in volts
|
1161 |
+
|
1162 |
+
"
|
1163 |
+
vehicle_control.py,VehicleControlAPI,fillFuelTank(fuelAmount: float),"Fills the fuel tank of the vehicle. The fuel tank can hold up to 50 gallons.
|
1164 |
+
|
1165 |
+
Args:
|
1166 |
+
|
1167 |
+
• fuelAmount (float): The amount of fuel to fill in gallons
|
1168 |
+
|
1169 |
+
Returns:
|
1170 |
+
|
1171 |
+
• fuelLevel (float): The fuel level of the vehicle in gallons
|
1172 |
+
|
1173 |
+
"
|
1174 |
+
vehicle_control.py,VehicleControlAPI,lockDoors(unlock: bool),"Locks the doors of the vehicle.
|
1175 |
+
|
1176 |
+
Args:
|
1177 |
+
|
1178 |
+
• unlock (bool): True if the doors are to be unlocked, False otherwise
|
1179 |
+
|
1180 |
+
Returns:
|
1181 |
+
|
1182 |
+
• lockStatus (str): The status of the lock
|
1183 |
+
|
1184 |
+
• remainingUnlockedDoors (int): The number of remaining unlocked doors
|
1185 |
+
|
1186 |
+
"
|
1187 |
+
vehicle_control.py,VehicleControlAPI,"adjustClimateControl(temperature: float, unit: str, fanSpeed: int, mode: str)","Adjusts the climate control of the vehicle.
|
1188 |
+
|
1189 |
+
Args:
|
1190 |
+
|
1191 |
+
• temperature (float): The temperature to set in degree
|
1192 |
+
|
1193 |
+
• unit (str): The unit of temperature
|
1194 |
+
|
1195 |
+
• fanSpeed (int): The fan speed to set from 0 to 100
|
1196 |
+
|
1197 |
+
• mode (str): The climate mode to set
|
1198 |
+
|
1199 |
+
Returns:
|
1200 |
+
|
1201 |
+
• currentTemperature (float): The current temperature set in degree Celsius
|
1202 |
+
|
1203 |
+
• climateMode (str): The current climate mode set
|
1204 |
+
|
1205 |
+
• humidityLevel (float): The humidity level in percentage
|
1206 |
+
|
1207 |
+
"
|
1208 |
+
vehicle_control.py,VehicleControlAPI,get_outside_temperature_from_google(outsideTemperature: float),"Gets the outside temperature.
|
1209 |
+
|
1210 |
+
Args:
|
1211 |
+
|
1212 |
+
• outsideTemperature (float): The outside temperature in degree Celsius
|
1213 |
+
|
1214 |
+
"
|
1215 |
+
vehicle_control.py,VehicleControlAPI,get_outside_temperature_from_weather_com(outsideTemperature: float),"Gets the outside temperature.
|
1216 |
+
|
1217 |
+
Args:
|
1218 |
+
|
1219 |
+
• outsideTemperature (float): The outside temperature in degree Celsius
|
1220 |
+
|
1221 |
+
"
|
1222 |
+
vehicle_control.py,VehicleControlAPI,setHeadlights(mode: str),"Sets the headlights of the vehicle.
|
1223 |
+
|
1224 |
+
Args:
|
1225 |
+
|
1226 |
+
• mode (str): The mode of the headlights
|
1227 |
+
|
1228 |
+
Returns:
|
1229 |
+
|
1230 |
+
• headlightStatus (str): The status of the headlights
|
1231 |
+
|
1232 |
+
"
|
1233 |
+
vehicle_control.py,VehicleControlAPI,displayCarStatus(option: str),"Displays the status of the vehicle based on the provided display option.
|
1234 |
+
|
1235 |
+
Args:
|
1236 |
+
|
1237 |
+
• option (str): The option to display
|
1238 |
+
|
1239 |
+
Returns:
|
1240 |
+
|
1241 |
+
• status (dict): The status of the vehicle based on the option
|
1242 |
+
|
1243 |
+
"
|
1244 |
+
vehicle_control.py,VehicleControlAPI,activateParkingBrake(mode: str),"Activates the parking brake of the vehicle.
|
1245 |
+
|
1246 |
+
Args:
|
1247 |
+
|
1248 |
+
• mode (str): The mode to set
|
1249 |
+
|
1250 |
+
Returns:
|
1251 |
+
|
1252 |
+
• brakeStatus (str): The status of the brake
|
1253 |
+
|
1254 |
+
• brakeForce (float): The force applied to the brake in Newtons
|
1255 |
+
|
1256 |
+
• slopeAngle (float): The slope angle in degrees
|
1257 |
+
|
1258 |
+
"
|
1259 |
+
vehicle_control.py,VehicleControlAPI,"setCruiseControl(speed: float, activate: bool, distanceToNextVehicle: float)","Sets the cruise control of the vehicle.
|
1260 |
+
|
1261 |
+
Args:
|
1262 |
+
|
1263 |
+
• speed (float): The speed to set in m/h
|
1264 |
+
|
1265 |
+
• activate (bool): True to activate the cruise control, False to deactivate
|
1266 |
+
|
1267 |
+
• distanceToNextVehicle (float): The distance to the next vehicle in meters
|
1268 |
+
|
1269 |
+
Returns:
|
1270 |
+
|
1271 |
+
• cruiseStatus (str): The status of the cruise control
|
1272 |
+
|
1273 |
+
• currentSpeed (float): The current speed of the vehicle in km/h
|
1274 |
+
|
1275 |
+
• distanceToNextVehicle (float): The distance to the next vehicle in meters
|
1276 |
+
|
1277 |
+
"
|
1278 |
+
vehicle_control.py,VehicleControlAPI,get_current_speed(currentSpeed: float),"Gets the current speed of the vehicle.
|
1279 |
+
|
1280 |
+
Args:
|
1281 |
+
|
1282 |
+
• currentSpeed (float): The current speed of the vehicle in km/h
|
1283 |
+
|
1284 |
+
"
|
1285 |
+
vehicle_control.py,VehicleControlAPI,display_log(),"Displays the log messages.
|
1286 |
+
|
1287 |
+
"
|
1288 |
+
vehicle_control.py,VehicleControlAPI,estimate_drive_feasibility_by_mileage(distance: float),"Estimates the milage of the vehicle given the distance needed to drive.
|
1289 |
+
|
1290 |
+
Args:
|
1291 |
+
|
1292 |
+
• distance (float): The distance to travel in miles
|
1293 |
+
|
1294 |
+
Returns:
|
1295 |
+
|
1296 |
+
• canDrive (bool): True if the vehicle can drive the distance, False otherwise
|
1297 |
+
|
1298 |
+
"
|
1299 |
+
vehicle_control.py,VehicleControlAPI,liter_to_gallon(liter: float),"Converts the liter to gallon.
|
1300 |
+
|
1301 |
+
Args:
|
1302 |
+
|
1303 |
+
• liter (float): The amount of liter to convert
|
1304 |
+
|
1305 |
+
Returns:
|
1306 |
+
|
1307 |
+
• gallon (float): The amount of gallon converted
|
1308 |
+
|
1309 |
+
"
|
1310 |
+
vehicle_control.py,VehicleControlAPI,gallon_to_liter(gallon: float),"Converts the gallon to liter.
|
1311 |
+
|
1312 |
+
Args:
|
1313 |
+
|
1314 |
+
• gallon (float): The amount of gallon to convert
|
1315 |
+
|
1316 |
+
Returns:
|
1317 |
+
|
1318 |
+
• liter (float): The amount of liter converted
|
1319 |
+
|
1320 |
+
"
|
1321 |
+
vehicle_control.py,VehicleControlAPI,"estimate_distance(cityA: str, cityB: str)","Estimates the distance between two cities.
|
1322 |
+
|
1323 |
+
Args:
|
1324 |
+
|
1325 |
+
• cityA (str): The zipcode of the first city
|
1326 |
+
|
1327 |
+
• cityB (str): The zipcode of the second city
|
1328 |
+
|
1329 |
+
Returns:
|
1330 |
+
|
1331 |
+
• distance (float): The distance between the two cities in km
|
1332 |
+
|
1333 |
+
"
|
1334 |
+
vehicle_control.py,VehicleControlAPI,get_zipcode_based_on_city(city: str),"Gets the zipcode based on the city.
|
1335 |
+
|
1336 |
+
Args:
|
1337 |
+
|
1338 |
+
• city (str): The name of the city
|
1339 |
+
|
1340 |
+
Returns:
|
1341 |
+
|
1342 |
+
• zipcode (str): The zipcode of the city
|
1343 |
+
|
1344 |
+
"
|
1345 |
+
vehicle_control.py,VehicleControlAPI,set_navigation(destination: str),"Navigates to the destination.
|
1346 |
+
|
1347 |
+
Args:
|
1348 |
+
|
1349 |
+
• destination (str): The destination to navigate in the format of street, city, state
|
1350 |
+
|
1351 |
+
Returns:
|
1352 |
+
|
1353 |
+
• status (dict): The status of the navigation
|
1354 |
+
|
1355 |
+
"
|
1356 |
+
vehicle_control.py,VehicleControlAPI,check_tire_pressure(tirePressure: dict),"Checks the tire pressure of the vehicle.
|
1357 |
+
|
1358 |
+
Args:
|
1359 |
+
|
1360 |
+
• tirePressure (dict): The tire pressure of the vehicle
|
1361 |
+
|
1362 |
+
"
|
1363 |
+
vehicle_control.py,VehicleControlAPI,find_nearest_tire_shop(shopLocation: str),"Finds the nearest tire shop.
|
1364 |
+
|
1365 |
+
Args:
|
1366 |
+
|
1367 |
+
• shopLocation (str): The location of the nearest tire shop
|
1368 |
+
|
1369 |
+
"
|
app.py
ADDED
@@ -0,0 +1,469 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from backend import get_handler
|
3 |
+
import time
|
4 |
+
import uuid
|
5 |
+
import json
|
6 |
+
import os
|
7 |
+
import queue
|
8 |
+
from db import collection
|
9 |
+
from info_table import api_info, api_samples
|
10 |
+
|
11 |
+
custom_css = """
|
12 |
+
/* Highlight the entire message box for the bot */
|
13 |
+
.bot-highlight {
|
14 |
+
background-color: yellow !important;
|
15 |
+
padding: 0px;
|
16 |
+
border-radius: 8px;
|
17 |
+
}
|
18 |
+
"""
|
19 |
+
|
20 |
+
# Initialize test_entry and handler
|
21 |
+
def initialize_empty_test_entry():
|
22 |
+
return {
|
23 |
+
"initial_config": {},
|
24 |
+
"involved_classes": [],
|
25 |
+
"id": str(uuid.uuid4()), # Generate unique ID
|
26 |
+
"question": [],
|
27 |
+
"function": []
|
28 |
+
}
|
29 |
+
|
30 |
+
test_entry_1 = initialize_empty_test_entry()
|
31 |
+
test_entry_2 = initialize_empty_test_entry()
|
32 |
+
|
33 |
+
inference_data_1 = {"message": []} # Do not change this
|
34 |
+
inference_data_2 = {"message": []} # Do not change this
|
35 |
+
|
36 |
+
# Define available models and categories
|
37 |
+
models = ["gpt-4o-mini-2024-07-18-FC", "gpt-4o-2024-08-06-FC", "gpt-4o-mini-2024-07-18-FC", "gpt-4-turbo-2024-04-09-FC", "gpt-3.5-turbo-0125-FC"]
|
38 |
+
categories = ["GorillaFileSystem", "MathAPI", "MessageAPI", "TwitterAPI", "TicketAPI", "TradingBot", "TravelAPI", "VehicleControlAPI"]
|
39 |
+
|
40 |
+
initial_chat_history = [
|
41 |
+
{"role": "user", "content": "Hi, can you help me with some tasks?"},
|
42 |
+
{"role": "assistant", "content": "Hello there! How can I assist you today?"},
|
43 |
+
]
|
44 |
+
|
45 |
+
shared_queue = queue.Queue()
|
46 |
+
|
47 |
+
def get_initial_state():
|
48 |
+
return initial_chat_history
|
49 |
+
|
50 |
+
DEFAULT_MODEL_1 = models[0]
|
51 |
+
DEFAULT_MODEL_2 = models[1]
|
52 |
+
DEFAULT_TEMPERATURE_1 = 0.7
|
53 |
+
DEFAULT_TEMPERATURE_2 = 0.4
|
54 |
+
|
55 |
+
current_model_1 = models[0]
|
56 |
+
current_model_2 = models[0]
|
57 |
+
current_category = categories[0]
|
58 |
+
current_temperature = DEFAULT_TEMPERATURE_1
|
59 |
+
current_temperature = DEFAULT_TEMPERATURE_2
|
60 |
+
|
61 |
+
# Initialize handler
|
62 |
+
handler_1 = get_handler(DEFAULT_MODEL_1, DEFAULT_TEMPERATURE_1)
|
63 |
+
handler_2 = get_handler(DEFAULT_MODEL_2, DEFAULT_TEMPERATURE_2)
|
64 |
+
|
65 |
+
def print_like_dislike(x: gr.LikeData):
|
66 |
+
print(x.index, x.value, x.liked)
|
67 |
+
|
68 |
+
|
69 |
+
def add_message(history1, history2, message, target):
|
70 |
+
|
71 |
+
if target in ["Model 1", "Both"]:
|
72 |
+
for x in message["files"]:
|
73 |
+
history1.append({"role": "user", "content": {"path": x}})
|
74 |
+
if message["text"] is not None:
|
75 |
+
history1.append({"role": "user", "content": message["text"]})
|
76 |
+
test_entry_1["question"] = [{"role": "user", "content": message["text"]}]
|
77 |
+
|
78 |
+
if target in ["Model 2", "Both"]:
|
79 |
+
for x in message["files"]:
|
80 |
+
history2.append({"role": "user", "content": {"path": x}})
|
81 |
+
if message["text"] is not None:
|
82 |
+
history2.append({"role": "user", "content": message["text"]})
|
83 |
+
test_entry_2["question"] = [{"role": "user", "content": message["text"]}]
|
84 |
+
|
85 |
+
return history1, history2, gr.MultimodalTextbox(value=None, interactive=False)
|
86 |
+
|
87 |
+
def equalize_and_zip(list1, list2):
|
88 |
+
# Determine the maximum length of the two lists
|
89 |
+
if list1 == None:
|
90 |
+
list1 = []
|
91 |
+
if list2 == None:
|
92 |
+
list2 = []
|
93 |
+
|
94 |
+
if isinstance(list1, str):
|
95 |
+
list1 = [list1]
|
96 |
+
if isinstance(list2, str):
|
97 |
+
list2 = [list2]
|
98 |
+
|
99 |
+
max_len = max(len(list1), len(list2))
|
100 |
+
|
101 |
+
# Extend both lists to the same length by appending None
|
102 |
+
list1.extend([None] * (max_len - len(list1)))
|
103 |
+
list2.extend([None] * (max_len - len(list2)))
|
104 |
+
|
105 |
+
# Zip the lists together
|
106 |
+
return list(zip(list1, list2))
|
107 |
+
|
108 |
+
def consume_data(shared_queue):
|
109 |
+
none_list = []
|
110 |
+
while True:
|
111 |
+
data = shared_queue.get()
|
112 |
+
if data is None:
|
113 |
+
if data in none_list:
|
114 |
+
print("[Consumer] No more data to consume. Exiting.")
|
115 |
+
break
|
116 |
+
else:
|
117 |
+
none_list.append(data)
|
118 |
+
yield data
|
119 |
+
|
120 |
+
def bot(history1: list, history2: list, target):
|
121 |
+
|
122 |
+
if target == "Model 1":
|
123 |
+
gen = bot_response(history1, handler_1, test_entry_1, inference_data_1, "Model 1")
|
124 |
+
print("gen: ", gen)
|
125 |
+
while True:
|
126 |
+
stop = True
|
127 |
+
try:
|
128 |
+
gen_his_1 = next(gen)
|
129 |
+
stop = False
|
130 |
+
yield gen_his_1, history2
|
131 |
+
except StopIteration:
|
132 |
+
pass
|
133 |
+
if stop:
|
134 |
+
break
|
135 |
+
elif target == "Model 2":
|
136 |
+
gen = bot_response(history2, handler_2, test_entry_2, inference_data_2, "Model 2")
|
137 |
+
while True:
|
138 |
+
stop = True
|
139 |
+
try:
|
140 |
+
gen_his_2 = next(gen)
|
141 |
+
stop = False
|
142 |
+
yield history1, gen_his_2
|
143 |
+
except StopIteration:
|
144 |
+
pass
|
145 |
+
if stop:
|
146 |
+
break
|
147 |
+
elif target == "Both":
|
148 |
+
gen1 = bot_response(history1, handler_1, test_entry_1, inference_data_1, "Model 1")
|
149 |
+
gen2 = bot_response(history2, handler_2, test_entry_2, inference_data_2, "Model 2")
|
150 |
+
while True:
|
151 |
+
stop = True
|
152 |
+
try:
|
153 |
+
gen_his_1 = next(gen1)
|
154 |
+
stop = False
|
155 |
+
except StopIteration:
|
156 |
+
pass
|
157 |
+
try:
|
158 |
+
gen_his_2 = next(gen2)
|
159 |
+
stop = False
|
160 |
+
except StopIteration:
|
161 |
+
pass
|
162 |
+
yield gen_his_1, gen_his_2
|
163 |
+
if stop:
|
164 |
+
break
|
165 |
+
|
166 |
+
|
167 |
+
def bot_response(history, handler, test_entry, inference_data, model_target):
|
168 |
+
|
169 |
+
global inference_data_1, inference_data_2
|
170 |
+
|
171 |
+
for item in handler.inference(test_entry, inference_data):
|
172 |
+
# Processing logic remains the same
|
173 |
+
if item[0] == "regular":
|
174 |
+
responses_results = equalize_and_zip(item[1], item[2])
|
175 |
+
for (model_res, exec_res) in responses_results:
|
176 |
+
if model_res is not None:
|
177 |
+
response = model_res
|
178 |
+
history.append({"role": "assistant", "content": "<b>Model Response🤖: </b><br>"})
|
179 |
+
for character in response:
|
180 |
+
history[-1]["content"] += character
|
181 |
+
time.sleep(0.01)
|
182 |
+
yield history
|
183 |
+
if exec_res is not None:
|
184 |
+
response = exec_res
|
185 |
+
history[-1]["content"] += "<br><br><b>Model Execution💻: </b><br>"
|
186 |
+
yield history
|
187 |
+
# history.append({"role": "assistant", "content": "<span class='bot-highlight'> Model Execution: </span>"})
|
188 |
+
for character in response:
|
189 |
+
# history[-1]["content"] = history[-1]["content"][0:-7] + character + "</span>"
|
190 |
+
history[-1]["content"] += character
|
191 |
+
time.sleep(0.01)
|
192 |
+
yield history
|
193 |
+
elif item[0] == 'summary':
|
194 |
+
response = item[1]
|
195 |
+
if response is not None:
|
196 |
+
history.append({"role": "assistant", "content": "<b>Summary✅: </b><br>"})
|
197 |
+
for character in response:
|
198 |
+
history[-1]["content"] += character
|
199 |
+
time.sleep(0.01)
|
200 |
+
yield history
|
201 |
+
|
202 |
+
elif item[0] == "final":
|
203 |
+
# Update inference data based on the target
|
204 |
+
if model_target == "Model 1":
|
205 |
+
inference_data_1 = item[2]
|
206 |
+
elif model_target == "Model 2":
|
207 |
+
inference_data_2 = item[2]
|
208 |
+
|
209 |
+
# Saves the model, cateogry, temperature, and history to the database
|
210 |
+
def save_1(history):
|
211 |
+
if len(history) > 2:
|
212 |
+
document = {"model": current_model_1,
|
213 |
+
"category": current_category,
|
214 |
+
"temperature": current_temperature_1,
|
215 |
+
"history": history}
|
216 |
+
# Have error in database connection
|
217 |
+
collection.insert_one(document)
|
218 |
+
|
219 |
+
def save_2(history):
|
220 |
+
if len(history) > 2:
|
221 |
+
document = {"model": current_model_2,
|
222 |
+
"category": current_category,
|
223 |
+
"temperature": current_temperature_2,
|
224 |
+
"history": history}
|
225 |
+
# Have error in database connection
|
226 |
+
collection.insert_one(document)
|
227 |
+
|
228 |
+
# Function to assign new unique ID on restart or at the start
|
229 |
+
def restart_chat_1(history):
|
230 |
+
global test_entry_1
|
231 |
+
test_entry_1["id"] = str(uuid.uuid4()) # Reinitialize test_entry with new ID
|
232 |
+
global handler_1
|
233 |
+
handler_1 = get_handler(model_dropdown_1.value, temperature_slider_1.value)
|
234 |
+
# print("test: entry", test_entry_1)
|
235 |
+
return [{"role": "user", "content": "Hi, can you help me with some tasks?"},
|
236 |
+
{"role": "assistant", "content": "Hello there! How can I assist you today?"}]
|
237 |
+
|
238 |
+
# Saves history before restarting chat,
|
239 |
+
def restart_chat_and_save_1(history):
|
240 |
+
save_1(history)
|
241 |
+
return restart_chat_1(history)
|
242 |
+
|
243 |
+
def restart_chat_2(history):
|
244 |
+
global test_entry_2
|
245 |
+
test_entry_2["id"] = str(uuid.uuid4()) # Reinitialize test_entry with new ID
|
246 |
+
global handler_2
|
247 |
+
handler_2 = get_handler(model_dropdown_2.value, temperature_slider_2.value)
|
248 |
+
# print("test: entry", test_entry_2)
|
249 |
+
return [{"role": "user", "content": "Hi, can you help me with some tasks?"},
|
250 |
+
{"role": "assistant", "content": "Hello there! How can I assist you today?"}]
|
251 |
+
|
252 |
+
# Saves history before restarting chat,
|
253 |
+
def restart_chat_and_save_2(history):
|
254 |
+
save_2(history)
|
255 |
+
return restart_chat_2(history)
|
256 |
+
|
257 |
+
# Function to report an issue
|
258 |
+
def report_issue():
|
259 |
+
return gr.Info("Thank you for reporting the issue. Our team will look into it.")
|
260 |
+
|
261 |
+
# Update handler 1 when model or temperature is changed
|
262 |
+
def update_handler_1(model, temp_slider, history):
|
263 |
+
global current_model_1
|
264 |
+
current_model_1 = model
|
265 |
+
global current_temperature_1
|
266 |
+
current_temperature_1 = temp_slider
|
267 |
+
print("update handler 1: ", model, temp_slider)
|
268 |
+
global handler_1
|
269 |
+
handler_1 = get_handler(model, temp_slider) # Reinitialize handler with new model and temperature
|
270 |
+
restart_history = restart_chat_1(history)
|
271 |
+
return model, restart_history
|
272 |
+
|
273 |
+
# Update handler 2 when model or temperature is changed
|
274 |
+
def update_handler_2(model, temp_slider, history):
|
275 |
+
global current_model_2
|
276 |
+
current_model_2 = model
|
277 |
+
global current_temperature_2
|
278 |
+
current_temperature_2 = temp_slider
|
279 |
+
print("update handler 2: ", model, temp_slider)
|
280 |
+
global handler_2
|
281 |
+
handler_2 = get_handler(model, temp_slider) # Reinitialize handler with new model and temperature
|
282 |
+
restart_history = restart_chat_2(history)
|
283 |
+
return model, restart_history
|
284 |
+
|
285 |
+
# Update involved_classes and load config based on category
|
286 |
+
def update_category_and_load_config(category):
|
287 |
+
global current_category
|
288 |
+
current_category = category
|
289 |
+
print("update category: ", category)
|
290 |
+
|
291 |
+
global test_entry_1, test_entry_2
|
292 |
+
# Update involved_classes
|
293 |
+
test_entry_1["initial_config"] = {category: {}}
|
294 |
+
test_entry_1["involved_classes"] = [category]
|
295 |
+
|
296 |
+
test_entry_2["initial_config"] = {category: {}}
|
297 |
+
test_entry_2["involved_classes"] = [category]
|
298 |
+
|
299 |
+
# Load the JSON file from the config folder corresponding to the category
|
300 |
+
config_path = os.path.join("config", f"{category}.json")
|
301 |
+
|
302 |
+
if os.path.exists(config_path):
|
303 |
+
with open(config_path, 'r') as config_file:
|
304 |
+
data = json.load(config_file)
|
305 |
+
test_entry_1["function"] = data.copy() # Load JSON content into test_entry["function"]
|
306 |
+
test_entry_2["function"] = data.copy()
|
307 |
+
|
308 |
+
return category
|
309 |
+
|
310 |
+
def load_example(example):
|
311 |
+
if example == "Example 1 - GFSFileSystem":
|
312 |
+
return models[0], 0.8, models[1], 0.3, categories[0], "Move final_report.pdf' within document directory to 'temp' directory in document. Make sure to create the directory"
|
313 |
+
elif example == "Example 2 - TradingBot":
|
314 |
+
return models[1], 0.9, models[2], 0.7, categories[5], "I'm contemplating enhancing my investment portfolio with some tech industry assets, and I've got my eye on Nvidia Corp. I'm keen to know its current stock price, and would appreciate if you could source this information for me."
|
315 |
+
elif example == "Example 3 - TravelAPI":
|
316 |
+
return models[2], 0.7, models[0], 0.2, categories[6], "As I plan a getaway, I'm curious about all the airports available for my travel. Would you share that information with me?"
|
317 |
+
return models[0], 0.7, models[2], 0.36, categories[0], "Move final_report.pdf' within document directory to 'temp' directory in document. Make sure to create the directory"
|
318 |
+
|
319 |
+
# Add logic to load examples when example buttons are clicked
|
320 |
+
def load_example_and_update(example, history_1, history_2):
|
321 |
+
save_1(history_1)
|
322 |
+
save_2(history_2)
|
323 |
+
# Load the example configuration
|
324 |
+
model_1, temp_1, model_2, temp_2, category, message = load_example(example)
|
325 |
+
update_category_and_load_config(category)
|
326 |
+
# Update the interface components
|
327 |
+
return model_1, temp_1, model_2, temp_2, category, message
|
328 |
+
|
329 |
+
# initialize test entry with default configurations
|
330 |
+
update_category_and_load_config(categories[0])
|
331 |
+
|
332 |
+
with gr.Blocks(css=custom_css) as demo:
|
333 |
+
gr.Markdown("# Multiturn LLM Chat Interface")
|
334 |
+
|
335 |
+
with gr.Row():
|
336 |
+
with gr.Column(scale=1):
|
337 |
+
gr.Markdown("## Configurations")
|
338 |
+
|
339 |
+
model_dropdown_1 = gr.Dropdown(choices=models, label="Select Model 1", value=DEFAULT_MODEL_1, interactive=True)
|
340 |
+
temperature_slider_1 = gr.Slider(0, 1, value=DEFAULT_TEMPERATURE_1, label="Temperature 1", interactive=True)
|
341 |
+
|
342 |
+
model_dropdown_2 = gr.Dropdown(choices=models, label="Select Model 2", value=DEFAULT_MODEL_2, interactive=True)
|
343 |
+
temperature_slider_2 = gr.Slider(0, 1, value=DEFAULT_TEMPERATURE_2, label="Temperature 2", interactive=True)
|
344 |
+
|
345 |
+
category_dropdown = gr.Dropdown(choices=categories, label="Select Category", value=categories[0], interactive=True)
|
346 |
+
|
347 |
+
with gr.Column(scale=3):
|
348 |
+
|
349 |
+
with gr.Row():
|
350 |
+
|
351 |
+
with gr.Column():
|
352 |
+
gr.Markdown("### Model 1")
|
353 |
+
chatbot1 = gr.Chatbot(elem_id="chatbot1", bubble_full_width=False, type="messages")
|
354 |
+
|
355 |
+
with gr.Row():
|
356 |
+
restart_btn_1 = gr.Button("Restart")
|
357 |
+
report_btn_1 = gr.Button("Report Issue")
|
358 |
+
|
359 |
+
with gr.Column():
|
360 |
+
gr.Markdown("### Model 2")
|
361 |
+
chatbot2 = gr.Chatbot(elem_id="chatbot2", bubble_full_width=False, type="messages")
|
362 |
+
|
363 |
+
with gr.Row():
|
364 |
+
restart_btn_2 = gr.Button("Restart")
|
365 |
+
report_btn_2 = gr.Button("Report Issue")
|
366 |
+
with gr.Row():
|
367 |
+
|
368 |
+
target_dropdown = gr.Dropdown(choices=["Model 1", "Model 2", "Both"], container=False, value="Both", interactive=True, scale=1)
|
369 |
+
chat_input = gr.MultimodalTextbox(
|
370 |
+
interactive=True,
|
371 |
+
file_count="multiple",
|
372 |
+
placeholder="Enter message or upload file...",
|
373 |
+
show_label=False,
|
374 |
+
scale=4
|
375 |
+
)
|
376 |
+
|
377 |
+
demo.load(lambda: get_initial_state(), outputs=chatbot1)
|
378 |
+
demo.load(lambda: get_initial_state(), outputs=chatbot2)
|
379 |
+
|
380 |
+
chat_msg = chat_input.submit(
|
381 |
+
add_message, [chatbot1, chatbot2, chat_input, target_dropdown], [chatbot1, chatbot2, chat_input]
|
382 |
+
)
|
383 |
+
|
384 |
+
bot_msg = chat_msg.then(bot, inputs=[chatbot1, chatbot2, target_dropdown], outputs=[chatbot1, chatbot2])
|
385 |
+
|
386 |
+
bot_msg.then(lambda: gr.MultimodalTextbox(interactive=True), None, [chat_input])
|
387 |
+
|
388 |
+
chatbot1.like(print_like_dislike, None, None, like_user_message=True)
|
389 |
+
chatbot2.like(print_like_dislike, None, None, like_user_message=True)
|
390 |
+
|
391 |
+
with gr.Row():
|
392 |
+
example_btn1 = gr.Button("Example 1 - GFSFileSystem")
|
393 |
+
example_btn2 = gr.Button("Example 2 - TradingBot")
|
394 |
+
example_btn3 = gr.Button("Example 3 - TravelAPI")
|
395 |
+
|
396 |
+
gr.Markdown("<br><br>")
|
397 |
+
|
398 |
+
for category in categories:
|
399 |
+
with gr.Tab(category):
|
400 |
+
with gr.Group():
|
401 |
+
category_info = api_info[api_info["Class Name"] == category]
|
402 |
+
with gr.Accordion("Function description", open=False):
|
403 |
+
with gr.Group():
|
404 |
+
for i in range(len(category_info)):
|
405 |
+
with gr.Accordion(category_info.iloc[i]["Function Name"], open=False):
|
406 |
+
gr.Markdown(category_info.iloc[i]["Description"])
|
407 |
+
|
408 |
+
# Sample demo, limit 5 per categories
|
409 |
+
samples = [[sample['question'], sample['ground_truth']] for _, sample in api_samples.iterrows() if category in sample['involved_classes']][:5]
|
410 |
+
gr.Dataset(
|
411 |
+
components=[gr.HTML(), gr.Markdown()],
|
412 |
+
headers= ["Prompt", "API Use"],
|
413 |
+
samples= samples
|
414 |
+
)
|
415 |
+
|
416 |
+
|
417 |
+
# Update handler when the model or temperature is changed
|
418 |
+
model_dropdown_1.change(
|
419 |
+
update_handler_1,
|
420 |
+
[model_dropdown_1, temperature_slider_1, chatbot1],
|
421 |
+
[model_dropdown_1, chatbot1]
|
422 |
+
)
|
423 |
+
|
424 |
+
# Update handler when the model or temperature is changed
|
425 |
+
model_dropdown_2.change(
|
426 |
+
update_handler_2,
|
427 |
+
[model_dropdown_2, temperature_slider_2, chatbot2],
|
428 |
+
[model_dropdown_2, chatbot2]
|
429 |
+
)
|
430 |
+
|
431 |
+
temperature_slider_1.change(
|
432 |
+
update_handler_1,
|
433 |
+
[model_dropdown_1, temperature_slider_1, chatbot1],
|
434 |
+
[model_dropdown_1, chatbot1]
|
435 |
+
)
|
436 |
+
|
437 |
+
temperature_slider_2.change(
|
438 |
+
update_handler_2,
|
439 |
+
[model_dropdown_2, temperature_slider_2, chatbot2],
|
440 |
+
[model_dropdown_2, chatbot2]
|
441 |
+
)
|
442 |
+
|
443 |
+
# Update category and load config when a category is selected
|
444 |
+
category_dropdown.change(
|
445 |
+
update_category_and_load_config,
|
446 |
+
inputs=category_dropdown,
|
447 |
+
outputs=category_dropdown
|
448 |
+
)
|
449 |
+
|
450 |
+
# Set up the event handler for the restart button to reset the chat and test_entry
|
451 |
+
restart_btn_1.click(restart_chat_and_save_1, [chatbot1], [chatbot1])
|
452 |
+
report_btn_1.click(report_issue, None, None)
|
453 |
+
|
454 |
+
restart_btn_2.click(restart_chat_and_save_2, [chatbot2], [chatbot2])
|
455 |
+
report_btn_2.click(report_issue, None, None)
|
456 |
+
|
457 |
+
example_btn1.click(load_example_and_update, inputs=[example_btn1, chatbot1, chatbot2],
|
458 |
+
outputs=[model_dropdown_1, temperature_slider_1, model_dropdown_2, temperature_slider_2, category_dropdown, chat_input])
|
459 |
+
example_btn2.click(load_example_and_update, inputs=[example_btn2, chatbot1, chatbot2],
|
460 |
+
outputs=[model_dropdown_1, temperature_slider_1, model_dropdown_2, temperature_slider_2, category_dropdown, chat_input])
|
461 |
+
example_btn3.click(load_example_and_update, inputs=[example_btn3, chatbot1, chatbot2],
|
462 |
+
outputs=[model_dropdown_1, temperature_slider_1, model_dropdown_2, temperature_slider_2, category_dropdown, chat_input])
|
463 |
+
|
464 |
+
demo.launch(share=False)
|
465 |
+
|
466 |
+
|
467 |
+
|
468 |
+
|
469 |
+
|
backend.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from openai_helper import OpenAIHandler
|
2 |
+
from claude import ClaudeHandler
|
3 |
+
|
4 |
+
def get_handler(model_name, temperature):
|
5 |
+
if "claude" in model_name:
|
6 |
+
return ClaudeHandler(model_name, temperature)
|
7 |
+
else:
|
8 |
+
return OpenAIHandler(model_name, temperature)
|
base_handler.py
ADDED
@@ -0,0 +1,445 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import time
|
3 |
+
from copy import deepcopy
|
4 |
+
|
5 |
+
from multi_turn_eval.multi_turn_utils import (
|
6 |
+
STATELESS_CLASSES,
|
7 |
+
execute_multi_turn_func_call,
|
8 |
+
is_empty_execute_response,
|
9 |
+
)
|
10 |
+
from constant import (
|
11 |
+
DEFAULT_USER_PROMPT_FOR_ADDITIONAL_FUNCTION_FC,
|
12 |
+
DEFAULT_USER_PROMPT_FOR_ADDITIONAL_FUNCTION_PROMPTING,
|
13 |
+
MAXIMUM_STEP_LIMIT,
|
14 |
+
)
|
15 |
+
from model_style import ModelStyle
|
16 |
+
from overrides import final
|
17 |
+
|
18 |
+
|
19 |
+
class BaseHandler:
|
20 |
+
model_name: str
|
21 |
+
model_style: ModelStyle
|
22 |
+
|
23 |
+
def __init__(self, model_name, temperature) -> None:
|
24 |
+
self.model_name = model_name
|
25 |
+
# Replace the slash with underscore to avoid creating subdirectories
|
26 |
+
# Replace the dash and dot with underscore for valid variable name
|
27 |
+
self.model_name_underline_replaced = (
|
28 |
+
model_name.replace("/", "_").replace("-", "_").replace(".", "_")
|
29 |
+
)
|
30 |
+
self.temperature = temperature
|
31 |
+
self.is_fc_model = False # Whether the model is a function calling model
|
32 |
+
|
33 |
+
@final
|
34 |
+
def inference(self, test_entry: dict, include_input_log: bool=False, include_state_log: bool=False):
|
35 |
+
# This method is used to retrive model response for each model.
|
36 |
+
return self.inference_multi_turn_FC(test_entry, include_input_log, include_state_log)
|
37 |
+
|
38 |
+
|
39 |
+
@final
|
40 |
+
def inference_multi_turn_FC(
|
41 |
+
self, test_entry: dict, include_input_log: bool, include_state_log: bool
|
42 |
+
):
|
43 |
+
initial_config: dict = test_entry["initial_config"]
|
44 |
+
involved_classes: list = test_entry["involved_classes"]
|
45 |
+
test_entry_id: str = test_entry["id"]
|
46 |
+
test_category: str = test_entry_id.rsplit("_", 1)[0]
|
47 |
+
|
48 |
+
# This is only for the miss function category
|
49 |
+
# A mapping from turn index to function to holdout
|
50 |
+
holdout_function: dict[int, list] = test_entry.get("missed_function", {})
|
51 |
+
|
52 |
+
total_input_token_count: list[list[float]] = []
|
53 |
+
total_output_token_count: list[list[float]] = []
|
54 |
+
total_latency: list[list[float]] = []
|
55 |
+
all_model_response: list[list] = (
|
56 |
+
[]
|
57 |
+
) # The model response that will be used for later evaluation
|
58 |
+
all_inference_log: list[list[dict]] = (
|
59 |
+
[]
|
60 |
+
) # The debugging log for human to understand
|
61 |
+
force_quit = False # Whether the model has been forced to quit. If True, this whole entry will be failed.
|
62 |
+
|
63 |
+
# Execute no function call, but just to get a reference to all the instances to get the initial state for logging purpose
|
64 |
+
if include_state_log:
|
65 |
+
_, involved_instances = execute_multi_turn_func_call(
|
66 |
+
[],
|
67 |
+
initial_config,
|
68 |
+
involved_classes,
|
69 |
+
self.model_name_underline_replaced,
|
70 |
+
test_entry_id,
|
71 |
+
long_context=(
|
72 |
+
"long_context" in test_category or "composite" in test_category
|
73 |
+
),
|
74 |
+
is_evaL_run=False,
|
75 |
+
)
|
76 |
+
state_log = []
|
77 |
+
for class_name, class_instance in involved_instances.items():
|
78 |
+
if class_name in STATELESS_CLASSES:
|
79 |
+
continue
|
80 |
+
class_instance = deepcopy(class_instance) # Avoid modification in future turns
|
81 |
+
state_log.append(
|
82 |
+
{
|
83 |
+
"role": "state_info",
|
84 |
+
"class_name": class_name,
|
85 |
+
"content": {
|
86 |
+
key: value
|
87 |
+
for key, value in vars(class_instance).items()
|
88 |
+
if not key.startswith("_")
|
89 |
+
},
|
90 |
+
}
|
91 |
+
)
|
92 |
+
all_inference_log.append(state_log)
|
93 |
+
|
94 |
+
inference_data: dict = {}
|
95 |
+
inference_data = self._pre_query_processing_FC(inference_data, test_entry)
|
96 |
+
inference_data = self._compile_tools(inference_data, test_entry)
|
97 |
+
|
98 |
+
all_multi_turn_messages: list[list[dict]] = test_entry["question"]
|
99 |
+
for turn_idx, current_turn_message in enumerate(all_multi_turn_messages):
|
100 |
+
current_turn_message: list[dict]
|
101 |
+
|
102 |
+
if str(turn_idx) in holdout_function:
|
103 |
+
test_entry["function"].extend(holdout_function[str(turn_idx)])
|
104 |
+
# Since we have added new functions, we need to recompile the tools
|
105 |
+
inference_data = self._compile_tools(inference_data, test_entry)
|
106 |
+
assert (
|
107 |
+
len(current_turn_message) == 0
|
108 |
+
), "Holdout turn should not have user message."
|
109 |
+
current_turn_message = [
|
110 |
+
{
|
111 |
+
"role": "user",
|
112 |
+
"content": DEFAULT_USER_PROMPT_FOR_ADDITIONAL_FUNCTION_FC,
|
113 |
+
}
|
114 |
+
]
|
115 |
+
|
116 |
+
if turn_idx == 0:
|
117 |
+
inference_data = self.add_first_turn_message_FC(
|
118 |
+
inference_data, current_turn_message
|
119 |
+
)
|
120 |
+
else:
|
121 |
+
inference_data = self._add_next_turn_user_message_FC(
|
122 |
+
inference_data, current_turn_message
|
123 |
+
)
|
124 |
+
|
125 |
+
current_turn_response = []
|
126 |
+
current_turn_inference_log: list[dict] = {"begin_of_turn_query": current_turn_message}
|
127 |
+
current_turn_input_token_count: list[float] = []
|
128 |
+
current_turn_output_token_count: list[float] = []
|
129 |
+
current_turn_latency: list[float] = []
|
130 |
+
|
131 |
+
count = 0
|
132 |
+
while True:
|
133 |
+
print("-" * 100)
|
134 |
+
print(
|
135 |
+
f"ID: {test_entry_id.replace('multi_turn_', '')}, Turn: {turn_idx}, Step: {count}"
|
136 |
+
)
|
137 |
+
current_step_inference_log: list[dict] = []
|
138 |
+
# Add to the current_turn_inference_log at beginning of each step so that we don't need to bother dealing with the break statements
|
139 |
+
current_turn_inference_log[f"step_{count}"] = current_step_inference_log
|
140 |
+
|
141 |
+
start_time = time.time()
|
142 |
+
api_response = self._query_FC(inference_data)
|
143 |
+
query_latency = time.time() - start_time
|
144 |
+
|
145 |
+
# This part of logging is disabled by default because it is too verbose and will make the result file extremely large
|
146 |
+
# It is only useful to see if the inference pipeline is working as expected (eg, does it convert all the inputs correctly)
|
147 |
+
if include_input_log:
|
148 |
+
current_step_inference_log.append(
|
149 |
+
{
|
150 |
+
"role": "handler_log",
|
151 |
+
"content": inference_data.get("inference_input_log", ""),
|
152 |
+
}
|
153 |
+
)
|
154 |
+
|
155 |
+
# Try parsing the model response
|
156 |
+
model_response_data = self._parse_query_response_FC(api_response)
|
157 |
+
model_responses = model_response_data["model_responses"]
|
158 |
+
|
159 |
+
# Add the assistant message to the chat history
|
160 |
+
inference_data = self._add_assistant_message_FC(
|
161 |
+
inference_data, model_response_data
|
162 |
+
)
|
163 |
+
|
164 |
+
# Process the metadata
|
165 |
+
current_turn_input_token_count.append(model_response_data["input_token"])
|
166 |
+
current_turn_output_token_count.append(model_response_data["output_token"])
|
167 |
+
current_turn_latency.append(query_latency)
|
168 |
+
|
169 |
+
current_turn_response.append(model_responses)
|
170 |
+
current_step_inference_log.append(
|
171 |
+
{"role": "assistant", "content": model_responses}
|
172 |
+
)
|
173 |
+
|
174 |
+
# Try decoding the model response
|
175 |
+
try:
|
176 |
+
decoded_model_responses = self.decode_execute(model_responses)
|
177 |
+
current_step_inference_log.append(
|
178 |
+
{
|
179 |
+
"role": "handler_log",
|
180 |
+
"content": "Successfully decoded model response.",
|
181 |
+
"model_response_decoded": decoded_model_responses,
|
182 |
+
}
|
183 |
+
)
|
184 |
+
|
185 |
+
if is_empty_execute_response(decoded_model_responses):
|
186 |
+
print("Empty response from the model. Proceed to next turn.")
|
187 |
+
current_step_inference_log.append(
|
188 |
+
{
|
189 |
+
"role": "handler_log",
|
190 |
+
"content": f"Empty response from the model. Proceed to next turn.",
|
191 |
+
"model_response_decoded": decoded_model_responses,
|
192 |
+
}
|
193 |
+
)
|
194 |
+
break
|
195 |
+
|
196 |
+
except Exception as e:
|
197 |
+
print("Failed to decode the model response. Proceed to next turn.")
|
198 |
+
current_step_inference_log.append(
|
199 |
+
{
|
200 |
+
"role": "handler_log",
|
201 |
+
"content": f"Error decoding the model response. Proceed to next turn.",
|
202 |
+
"error": str(e),
|
203 |
+
}
|
204 |
+
)
|
205 |
+
yield ("summary", model_responses, None, self.model_name)
|
206 |
+
break
|
207 |
+
|
208 |
+
# Obtain the execution results
|
209 |
+
execution_results, involved_instances = execute_multi_turn_func_call(
|
210 |
+
decoded_model_responses,
|
211 |
+
initial_config,
|
212 |
+
involved_classes,
|
213 |
+
self.model_name_underline_replaced,
|
214 |
+
test_entry_id,
|
215 |
+
long_context=(
|
216 |
+
"long_context" in test_category or "composite" in test_category
|
217 |
+
),
|
218 |
+
is_evaL_run=False,
|
219 |
+
)
|
220 |
+
|
221 |
+
# Add the execution results to the chat history for the next turn
|
222 |
+
inference_data = self._add_execution_results_FC(
|
223 |
+
inference_data, execution_results, model_response_data
|
224 |
+
)
|
225 |
+
|
226 |
+
for execution_result in execution_results:
|
227 |
+
current_step_inference_log.append(
|
228 |
+
{
|
229 |
+
"role": "tool",
|
230 |
+
"content": execution_result,
|
231 |
+
}
|
232 |
+
)
|
233 |
+
execution_results = deepcopy(execution_results)
|
234 |
+
for i in range(len(execution_results)):
|
235 |
+
if "error" in execution_results[i]:
|
236 |
+
execution_results[i] = execution_results[i].replace("error", "error❗️")
|
237 |
+
yield ("regular", decoded_model_responses, execution_results, self.model_name)
|
238 |
+
|
239 |
+
count += 1
|
240 |
+
# Force quit after too many steps
|
241 |
+
if count > MAXIMUM_STEP_LIMIT:
|
242 |
+
force_quit = True
|
243 |
+
current_step_inference_log.append(
|
244 |
+
{
|
245 |
+
"role": "handler_log",
|
246 |
+
"content": f"Model has been forced to quit after {MAXIMUM_STEP_LIMIT} steps.",
|
247 |
+
}
|
248 |
+
)
|
249 |
+
|
250 |
+
break
|
251 |
+
|
252 |
+
# Add to the total list
|
253 |
+
all_model_response.append(current_turn_response)
|
254 |
+
all_inference_log.append(current_turn_inference_log)
|
255 |
+
total_input_token_count.append(current_turn_input_token_count)
|
256 |
+
total_output_token_count.append(current_turn_output_token_count)
|
257 |
+
total_latency.append(current_turn_latency)
|
258 |
+
|
259 |
+
if include_state_log:
|
260 |
+
state_log = []
|
261 |
+
for class_name, class_instance in involved_instances.items():
|
262 |
+
if class_name in STATELESS_CLASSES:
|
263 |
+
continue
|
264 |
+
class_instance = deepcopy(class_instance) # Avoid modification in future turns
|
265 |
+
state_log.append(
|
266 |
+
{
|
267 |
+
"role": "state_info",
|
268 |
+
"class_name": class_name,
|
269 |
+
"content": {
|
270 |
+
key: value
|
271 |
+
for key, value in vars(class_instance).items()
|
272 |
+
if not key.startswith("_")
|
273 |
+
},
|
274 |
+
}
|
275 |
+
)
|
276 |
+
all_inference_log.append(state_log)
|
277 |
+
|
278 |
+
if force_quit:
|
279 |
+
break
|
280 |
+
|
281 |
+
metadata = {
|
282 |
+
"input_token_count": total_input_token_count,
|
283 |
+
"output_token_count": total_output_token_count,
|
284 |
+
"latency": total_latency,
|
285 |
+
"inference_log": all_inference_log,
|
286 |
+
}
|
287 |
+
|
288 |
+
yield ("final", current_round_response, inference_data, involved_instances)
|
289 |
+
|
290 |
+
|
291 |
+
def decode_ast(self, result, language="Python"):
|
292 |
+
# This method takes raw model output and convert it to standard AST checker input.
|
293 |
+
raise NotImplementedError
|
294 |
+
|
295 |
+
def decode_execute(self, result):
|
296 |
+
# This method takes raw model output and convert it to standard execute checker input.
|
297 |
+
raise NotImplementedError
|
298 |
+
|
299 |
+
|
300 |
+
#### FC methods ####
|
301 |
+
|
302 |
+
def _query_FC(self, inference_data: dict):
|
303 |
+
"""
|
304 |
+
Call the model API in FC mode to get the response.
|
305 |
+
Return the response object that can be used to feed into the decode method.
|
306 |
+
"""
|
307 |
+
raise NotImplementedError
|
308 |
+
|
309 |
+
def _pre_query_processing_FC(self, inference_data: dict, test_entry: dict) -> dict:
|
310 |
+
"""
|
311 |
+
Preprocess the testset entry before sending it to the model.
|
312 |
+
This includes transforming the input user message into the format expected by the model, and any other necessary preprocessing steps.
|
313 |
+
The inference_data dict is updated in place and returned.
|
314 |
+
"""
|
315 |
+
raise NotImplementedError
|
316 |
+
|
317 |
+
def _compile_tools(self, inference_data: dict, test_entry: dict) -> dict:
|
318 |
+
"""
|
319 |
+
Compile the tools from the test entry and add them to the inference data.
|
320 |
+
This method is used to prepare the tools for the model query in FC mode.
|
321 |
+
The inference_data dict is updated in place and returned.
|
322 |
+
"""
|
323 |
+
raise NotImplementedError
|
324 |
+
|
325 |
+
def _parse_query_response_FC(self, api_response: any) -> dict:
|
326 |
+
"""
|
327 |
+
Parses the raw response from the model API to extract the result, input token count, and output token count.
|
328 |
+
|
329 |
+
Args:
|
330 |
+
api_response (any): The raw response from the model API.
|
331 |
+
|
332 |
+
Returns:
|
333 |
+
A dict containing the following elements:
|
334 |
+
- model_responses (any): The parsed result that can be directly used as input to the decode method.
|
335 |
+
- input_token (int): The number of tokens used in the input to the model.
|
336 |
+
- output_token (int): The number of tokens generated by the model as output.
|
337 |
+
- tool_call_ids (list[str]): The IDs of the tool calls that are generated by the model. Optional.
|
338 |
+
- Any other metadata that is specific to the model.
|
339 |
+
"""
|
340 |
+
raise NotImplementedError
|
341 |
+
|
342 |
+
def add_first_turn_message_FC(
|
343 |
+
self, inference_data: dict, first_turn_message: list[dict]
|
344 |
+
) -> dict:
|
345 |
+
"""
|
346 |
+
Add the first turn message to the chat history.
|
347 |
+
"""
|
348 |
+
raise NotImplementedError
|
349 |
+
|
350 |
+
def _add_next_turn_user_message_FC(
|
351 |
+
self, inference_data: dict, user_message: list[dict]
|
352 |
+
) -> dict:
|
353 |
+
"""
|
354 |
+
[Only for multi-turn]
|
355 |
+
Add next turn user message to the chat history for query.
|
356 |
+
user_message is a list of 1 element, which is the user message.
|
357 |
+
"""
|
358 |
+
raise NotImplementedError
|
359 |
+
|
360 |
+
def _add_assistant_message_FC(
|
361 |
+
self, inference_data: dict, model_response_data: dict
|
362 |
+
) -> dict:
|
363 |
+
"""
|
364 |
+
Add assistant message to the chat history.
|
365 |
+
"""
|
366 |
+
raise NotImplementedError
|
367 |
+
|
368 |
+
def _add_execution_results_FC(
|
369 |
+
self, inference_data: dict, execution_results: list[str], model_response_data: dict
|
370 |
+
) -> dict:
|
371 |
+
"""
|
372 |
+
Add the execution results to the chat history to prepare for the next turn of query.
|
373 |
+
Some models may need to add additional information to the chat history, such as tool call IDs.
|
374 |
+
"""
|
375 |
+
raise NotImplementedError
|
376 |
+
|
377 |
+
#### Prompting methods ####
|
378 |
+
|
379 |
+
def _query_prompting(self, inference_data: dict):
|
380 |
+
"""
|
381 |
+
Call the model API in prompting mode to get the response.
|
382 |
+
Return the response object that can be used to feed into the decode method.
|
383 |
+
"""
|
384 |
+
raise NotImplementedError
|
385 |
+
|
386 |
+
def _pre_query_processing_prompting(self, test_entry: dict) -> dict:
|
387 |
+
"""
|
388 |
+
Preprocess the testset entry before sending it to the model.
|
389 |
+
Returns a dict that contains all the necessary information for the query method.
|
390 |
+
`tools` and `message` must be included in the returned dict.
|
391 |
+
Things like `system_prompt` and `chat_history` are optional, specific to the model.
|
392 |
+
"""
|
393 |
+
raise NotImplementedError
|
394 |
+
|
395 |
+
def _parse_query_response_prompting(self, api_response: any) -> dict:
|
396 |
+
"""
|
397 |
+
Parses the raw response from the model API to extract the result, input token count, and output token count.
|
398 |
+
|
399 |
+
Args:
|
400 |
+
api_response (any): The raw response from the model API.
|
401 |
+
|
402 |
+
Returns:
|
403 |
+
A dict containing the following elements:
|
404 |
+
- model_responses (any): The parsed result that can be directly used as input to the decode method.
|
405 |
+
- input_token (int): The number of tokens used in the input to the model.
|
406 |
+
- output_token (int): The number of tokens generated by the model as output.
|
407 |
+
- tool_call_ids (list[str]): The IDs of the tool calls that are generated by the model. Optional.
|
408 |
+
- Any other metadata that is specific to the model.
|
409 |
+
"""
|
410 |
+
raise NotImplementedError
|
411 |
+
|
412 |
+
def add_first_turn_message_prompting(
|
413 |
+
self, inference_data: dict, first_turn_message: list[dict]
|
414 |
+
) -> dict:
|
415 |
+
"""
|
416 |
+
Add the first turn message to the chat history.
|
417 |
+
"""
|
418 |
+
raise NotImplementedError
|
419 |
+
|
420 |
+
def _add_next_turn_user_message_prompting(
|
421 |
+
self, inference_data: dict, user_message: list[dict]
|
422 |
+
) -> dict:
|
423 |
+
"""
|
424 |
+
[Only for multi-turn]
|
425 |
+
Add next turn user message to the chat history for query.
|
426 |
+
user_message is a list of 1 element, which is the user message.
|
427 |
+
"""
|
428 |
+
raise NotImplementedError
|
429 |
+
|
430 |
+
def _add_assistant_message_prompting(
|
431 |
+
self, inference_data: dict, model_response_data: dict
|
432 |
+
) -> dict:
|
433 |
+
"""
|
434 |
+
Add assistant message to the chat history.
|
435 |
+
"""
|
436 |
+
raise NotImplementedError
|
437 |
+
|
438 |
+
def _add_execution_results_prompting(
|
439 |
+
self, inference_data: dict, execution_results: list[str], model_response_data: dict
|
440 |
+
) -> dict:
|
441 |
+
"""
|
442 |
+
Add the execution results to the chat history to prepare for the next turn of query.
|
443 |
+
Some models may need to add additional information to the chat history, such as tool call IDs.
|
444 |
+
"""
|
445 |
+
raise NotImplementedError
|
claude.py
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
|
4 |
+
from anthropic import Anthropic
|
5 |
+
from anthropic.types import TextBlock, ToolUseBlock
|
6 |
+
from base_handler import BaseHandler
|
7 |
+
from constant import GORILLA_TO_OPENAPI
|
8 |
+
from model_style import ModelStyle
|
9 |
+
from utils import (
|
10 |
+
ast_parse,
|
11 |
+
combine_consecutive_user_prompts,
|
12 |
+
convert_system_prompt_into_user_prompt,
|
13 |
+
convert_to_function_call,
|
14 |
+
convert_to_tool,
|
15 |
+
extract_system_prompt,
|
16 |
+
format_execution_results_prompting,
|
17 |
+
func_doc_language_specific_pre_processing,
|
18 |
+
system_prompt_pre_processing_chat_model,
|
19 |
+
)
|
20 |
+
|
21 |
+
|
22 |
+
class ClaudeHandler(BaseHandler):
|
23 |
+
def __init__(self, model_name, temperature) -> None:
|
24 |
+
super().__init__(model_name, temperature)
|
25 |
+
self.model_style = ModelStyle.Anthropic
|
26 |
+
self.client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
|
27 |
+
|
28 |
+
def decode_ast(self, result, language="Python"):
|
29 |
+
if "FC" not in self.model_name:
|
30 |
+
func = result
|
31 |
+
if " " == func[0]:
|
32 |
+
func = func[1:]
|
33 |
+
if not func.startswith("["):
|
34 |
+
func = "[" + func
|
35 |
+
if not func.endswith("]"):
|
36 |
+
func = func + "]"
|
37 |
+
decode_output = ast_parse(func, language)
|
38 |
+
return decode_output
|
39 |
+
|
40 |
+
else:
|
41 |
+
decoded_output = []
|
42 |
+
for invoked_function in result:
|
43 |
+
name = list(invoked_function.keys())[0]
|
44 |
+
params = json.loads(invoked_function[name])
|
45 |
+
decoded_output.append({name: params})
|
46 |
+
return decoded_output
|
47 |
+
|
48 |
+
def decode_execute(self, result):
|
49 |
+
if "FC" not in self.model_name:
|
50 |
+
func = result
|
51 |
+
if " " == func[0]:
|
52 |
+
func = func[1:]
|
53 |
+
if not func.startswith("["):
|
54 |
+
func = "[" + func
|
55 |
+
if not func.endswith("]"):
|
56 |
+
func = func + "]"
|
57 |
+
decode_output = ast_parse(func)
|
58 |
+
execution_list = []
|
59 |
+
for function_call in decode_output:
|
60 |
+
for key, value in function_call.items():
|
61 |
+
execution_list.append(
|
62 |
+
f"{key}({','.join([f'{k}={repr(v)}' for k, v in value.items()])})"
|
63 |
+
)
|
64 |
+
return execution_list
|
65 |
+
|
66 |
+
else:
|
67 |
+
function_call = convert_to_function_call(result)
|
68 |
+
return function_call
|
69 |
+
|
70 |
+
#### FC methods ####
|
71 |
+
|
72 |
+
def _query_FC(self, inference_data: dict):
|
73 |
+
inference_data["inference_input_log"] = {
|
74 |
+
"message": repr(inference_data["message"]),
|
75 |
+
"tools": inference_data["tools"],
|
76 |
+
}
|
77 |
+
messages = inference_data["message"]
|
78 |
+
|
79 |
+
if inference_data["caching_enabled"]:
|
80 |
+
# Only add cache control to the last two user messages
|
81 |
+
# Remove previously set cache control flags from all user messages except the last two
|
82 |
+
count = 0
|
83 |
+
for message in reversed(messages):
|
84 |
+
if message["role"] == "user":
|
85 |
+
if count < 2:
|
86 |
+
message["content"][0]["cache_control"] = {"type": "ephemeral"}
|
87 |
+
else:
|
88 |
+
if "cache_control" in message["content"][0]:
|
89 |
+
del message["content"][0]["cache_control"]
|
90 |
+
count += 1
|
91 |
+
|
92 |
+
return self.client.beta.prompt_caching.messages.create(
|
93 |
+
model=self.model_name.strip("-FC"),
|
94 |
+
max_tokens=(
|
95 |
+
8192 if "claude-3-5" in self.model_name else 4096
|
96 |
+
), # 3.5 Sonnet has a higher max token limit
|
97 |
+
tools=inference_data["tools"],
|
98 |
+
messages=messages,
|
99 |
+
)
|
100 |
+
|
101 |
+
def _pre_query_processing_FC(self, inference_data: dict, test_entry: dict) -> dict:
|
102 |
+
for round_idx in range(len(test_entry["question"])):
|
103 |
+
test_entry["question"][round_idx] = convert_system_prompt_into_user_prompt(
|
104 |
+
test_entry["question"][round_idx]
|
105 |
+
)
|
106 |
+
test_entry["question"][round_idx] = combine_consecutive_user_prompts(
|
107 |
+
test_entry["question"][round_idx]
|
108 |
+
)
|
109 |
+
inference_data["message"] = []
|
110 |
+
|
111 |
+
test_entry_id: str = test_entry["id"]
|
112 |
+
test_category: str = test_entry_id.rsplit("_", 1)[0]
|
113 |
+
# caching enabled only for multi_turn category
|
114 |
+
inference_data["caching_enabled"] = (
|
115 |
+
"claude-3-sonnet" not in self.model_name
|
116 |
+
)
|
117 |
+
|
118 |
+
return inference_data
|
119 |
+
|
120 |
+
def _compile_tools(self, inference_data: dict, test_entry: dict) -> dict:
|
121 |
+
functions: list = test_entry["function"]
|
122 |
+
test_category: str = test_entry["id"].rsplit("_", 1)[0]
|
123 |
+
|
124 |
+
functions = func_doc_language_specific_pre_processing(functions, test_category)
|
125 |
+
tools = convert_to_tool(functions, GORILLA_TO_OPENAPI, self.model_style)
|
126 |
+
|
127 |
+
if inference_data["caching_enabled"]:
|
128 |
+
# First time compiling tools, so adding cache control flag to the last tool
|
129 |
+
if "tools" not in inference_data:
|
130 |
+
tools[-1]["cache_control"] = {"type": "ephemeral"}
|
131 |
+
# This is the situation where the tools are already compiled and we are adding more tools to the existing tools (in miss_func category)
|
132 |
+
# We add the cache control flag to the last tool in the previous existing tools and the last tool in the new tools to maximize cache hit
|
133 |
+
else:
|
134 |
+
existing_tool_len = len(inference_data["tools"])
|
135 |
+
tools[existing_tool_len - 1]["cache_control"] = {"type": "ephemeral"}
|
136 |
+
tools[-1]["cache_control"] = {"type": "ephemeral"}
|
137 |
+
|
138 |
+
inference_data["tools"] = tools
|
139 |
+
|
140 |
+
return inference_data
|
141 |
+
|
142 |
+
def _parse_query_response_FC(self, api_response: any) -> dict:
|
143 |
+
text_outputs = []
|
144 |
+
tool_call_outputs = []
|
145 |
+
tool_call_ids = []
|
146 |
+
|
147 |
+
for content in api_response.content:
|
148 |
+
if isinstance(content, TextBlock):
|
149 |
+
text_outputs.append(content.text)
|
150 |
+
elif isinstance(content, ToolUseBlock):
|
151 |
+
tool_call_outputs.append({content.name: json.dumps(content.input)})
|
152 |
+
tool_call_ids.append(content.id)
|
153 |
+
|
154 |
+
model_responses = tool_call_outputs if tool_call_outputs else text_outputs
|
155 |
+
|
156 |
+
model_responses_message_for_chat_history = api_response.content
|
157 |
+
|
158 |
+
return {
|
159 |
+
"model_responses": model_responses,
|
160 |
+
"model_responses_message_for_chat_history": model_responses_message_for_chat_history,
|
161 |
+
"tool_call_ids": tool_call_ids,
|
162 |
+
"input_token": api_response.usage.input_tokens,
|
163 |
+
"output_token": api_response.usage.output_tokens,
|
164 |
+
}
|
165 |
+
|
166 |
+
def add_first_turn_message_FC(
|
167 |
+
self, inference_data: dict, first_turn_message: list[dict]
|
168 |
+
) -> dict:
|
169 |
+
for message in first_turn_message:
|
170 |
+
message["content"] = [{"type": "text", "text": message["content"]}]
|
171 |
+
inference_data["message"].extend(first_turn_message)
|
172 |
+
return inference_data
|
173 |
+
|
174 |
+
def _add_next_turn_user_message_FC(
|
175 |
+
self, inference_data: dict, user_message: list[dict]
|
176 |
+
) -> dict:
|
177 |
+
for message in user_message:
|
178 |
+
message["content"] = [{"type": "text", "text": message["content"]}]
|
179 |
+
inference_data["message"].extend(user_message)
|
180 |
+
return inference_data
|
181 |
+
|
182 |
+
def _add_assistant_message_FC(
|
183 |
+
self, inference_data: dict, model_response_data: dict
|
184 |
+
) -> dict:
|
185 |
+
inference_data["message"].append(
|
186 |
+
{
|
187 |
+
"role": "assistant",
|
188 |
+
"content": model_response_data["model_responses_message_for_chat_history"],
|
189 |
+
}
|
190 |
+
)
|
191 |
+
return inference_data
|
192 |
+
|
193 |
+
def _add_execution_results_FC(
|
194 |
+
self,
|
195 |
+
inference_data: dict,
|
196 |
+
execution_results: list[str],
|
197 |
+
model_response_data: dict,
|
198 |
+
) -> dict:
|
199 |
+
# Claude don't use the tool role; it uses the user role to send the tool output
|
200 |
+
tool_message = {
|
201 |
+
"role": "user",
|
202 |
+
"content": [],
|
203 |
+
}
|
204 |
+
for execution_result, tool_call_id in zip(
|
205 |
+
execution_results, model_response_data["tool_call_ids"]
|
206 |
+
):
|
207 |
+
tool_message["content"].append(
|
208 |
+
{
|
209 |
+
"type": "tool_result",
|
210 |
+
"content": execution_result,
|
211 |
+
"tool_use_id": tool_call_id,
|
212 |
+
}
|
213 |
+
)
|
214 |
+
|
215 |
+
inference_data["message"].append(tool_message)
|
216 |
+
|
217 |
+
return inference_data
|
218 |
+
|
219 |
+
|
config/gorilla_file_system.json
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"name": "cat", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Display the contents of a file of any extension from currrent directory.", "parameters": {"type": "dict", "properties": {"file_name": {"type": "string", "description": "The name of the file from current directory to display. No path is allowed. "}}, "required": ["file_name"]}, "response": {"type": "dict", "properties": {"file_content": {"type": "string", "description": "The content of the file."}}}}
|
2 |
+
{"name": "cd", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Change the current working directory to the specified folder.", "parameters": {"type": "dict", "properties": {"folder": {"type": "string", "description": "The folder of the directory to change to. You can only change one folder at a time. "}}, "required": ["folder"]}, "response": {"type": "dict", "properties": {"current_working_directory": {"type": "string", "description": "The new current working directory path."}}}}
|
3 |
+
{"name": "cp", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Copy a file or directory from one location to another. If the destination is a directory, the source file or directory will be copied into the destination directory. Both source and destination must be local to the current directory.", "parameters": {"type": "dict", "properties": {"source": {"type": "string", "description": "The name of the file or directory to copy."}, "destination": {"type": "string", "description": "The destination name to copy the file or directory to. If the destination is a directory, the source will be copied into this directory. No file paths allowed. "}}, "required": ["source", "destination"]}, "response": {"type": "dict", "properties": {"result": {"type": "string", "description": "The result of the copy operation or an error message if the operation fails."}}}}
|
4 |
+
{"name": "diff", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Compare two files of any extension line by line at the current directory.", "parameters": {"type": "dict", "properties": {"file_name1": {"type": "string", "description": "The name of the first file in current directory."}, "file_name2": {"type": "string", "description": "The name of the second file in current directorry. "}}, "required": ["file_name1", "file_name2"]}, "response": {"type": "dict", "properties": {"diff_lines": {"type": "string", "description": "The differences between the two files."}}}}
|
5 |
+
{"name": "du", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Estimate the disk usage of a directory and its contents.", "parameters": {"type": "dict", "properties": {"human_readable": {"type": "boolean", "description": "If True, returns the size in human-readable format (e.g., KB, MB). ", "default": false}}, "required": []}, "response": {"type": "dict", "properties": {"disk_usage": {"type": "string", "description": "The estimated disk usage."}}}}
|
6 |
+
{"name": "echo", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Write content to a file at current directory or display it in the terminal.", "parameters": {"type": "dict", "properties": {"content": {"type": "string", "description": "The content to write or display."}, "file_name": {"type": "string", "description": "The name of the file at current directory to write the content to. Defaults to None. ", "default": "None"}}, "required": ["content"]}, "response": {"type": "dict", "properties": {"terminal_output": {"type": "string", "description": "The content if no file name is provided, or None if written to file."}}}}
|
7 |
+
{"name": "find", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Find any file or directories under specific path that contain name in its file name. This method searches for files of any extension and directories within a specified path that match the given name. If no name is provided, it returns all files and directories in the specified path and its subdirectories. Note: This method performs a recursive search through all subdirectories of the given path.", "parameters": {"type": "dict", "properties": {"path": {"type": "string", "description": "The directory path to start the search. Defaults to the current directory (\".\").", "default": "."}, "name": {"type": "string", "description": "The name of the file or directory to search for. If None, all items are returned. ", "default": "None"}}, "required": []}, "response": {"type": "dict", "properties": {"matches": {"type": "array", "description": "A list of matching file and directory paths relative to the given path.", "items": {"type": "string"}}}}}
|
8 |
+
{"name": "grep", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Search for lines in a file of any extension at current directory that contain the specified pattern.", "parameters": {"type": "dict", "properties": {"file_name": {"type": "string", "description": "The name of the file to search. No path is allowed and you can only perform on file at local directory."}, "pattern": {"type": "string", "description": "The pattern to search for. "}}, "required": ["file_name", "pattern"]}, "response": {"type": "dict", "properties": {"matching_lines": {"type": "array", "description": "Lines that match the pattern.", "items": {"type": "string"}}}}}
|
9 |
+
{"name": "ls", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: List the contents of the current directory.", "parameters": {"type": "dict", "properties": {"a": {"type": "boolean", "description": "Show hidden files and directories. Defaults to False. ", "default": false}}, "required": []}, "response": {"type": "dict", "properties": {"current_directory_content": {"type": "array", "description": "A list of the contents of the specified directory.", "items": {"type": "string"}}}}}
|
10 |
+
{"name": "mkdir", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Create a new directory in the current directory.", "parameters": {"type": "dict", "properties": {"dir_name": {"type": "string", "description": "The name of the new directory at current directory. You can only create directory at current directory."}}, "required": ["dir_name"]}, "response": {"type": "dict", "properties": {}}}
|
11 |
+
{"name": "mv", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Move a file or directory from one location to another. so", "parameters": {"type": "dict", "properties": {"source": {"type": "string", "description": "Source name of the file or directory to move. Source must be local to the current directory."}, "destination": {"type": "string", "description": "The destination name to move the file or directory to. Destination must be local to the current directory and cannot be a path. If destination is not an existing directory like when renaming something, destination is the new file name. "}}, "required": ["source", "destination"]}, "response": {"type": "dict", "properties": {"result": {"type": "string", "description": "The result of the move operation."}}}}
|
12 |
+
{"name": "pwd", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Return the current working directory path.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"current_working_directory": {"type": "string", "description": "The current working directory path."}}}}
|
13 |
+
{"name": "rm", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Remove a file or directory.", "parameters": {"type": "dict", "properties": {"file_name": {"type": "string", "description": "The name of the file or directory to remove. "}}, "required": ["file_name"]}, "response": {"type": "dict", "properties": {"result": {"type": "string", "description": "The result of the remove operation."}}}}
|
14 |
+
{"name": "rmdir", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Remove a directory at current directory.", "parameters": {"type": "dict", "properties": {"dir_name": {"type": "string", "description": "The name of the directory to remove. Directory must be local to the current directory. "}}, "required": ["dir_name"]}, "response": {"type": "dict", "properties": {"result": {"type": "string", "description": "The result of the remove operation."}}}}
|
15 |
+
{"name": "sort", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Sort the contents of a file line by line.", "parameters": {"type": "dict", "properties": {"file_name": {"type": "string", "description": "The name of the file appeared at current directory to sort. "}}, "required": ["file_name"]}, "response": {"type": "dict", "properties": {"sorted_content": {"type": "string", "description": "The sorted content of the file."}}}}
|
16 |
+
{"name": "tail", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Display the last part of a file of any extension.", "parameters": {"type": "dict", "properties": {"file_name": {"type": "string", "description": "The name of the file to display. No path is allowed and you can only perform on file at local directory."}, "lines": {"type": "integer", "description": "The number of lines to display from the end of the file. Defaults to 10. ", "default": 10}}, "required": ["file_name"]}, "response": {"type": "dict", "properties": {"last_lines": {"type": "string", "description": "The last part of the file."}}}}
|
17 |
+
{"name": "touch", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Create a new file of any extension in the current directory.", "parameters": {"type": "dict", "properties": {"file_name": {"type": "string", "description": "The name of the new file in the current directory. file_name is local to the current directory and does not allow path."}}, "required": ["file_name"]}, "response": {"type": "dict", "properties": {}}}
|
18 |
+
{"name": "wc", "description": "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc. Tool description: Count the number of lines, words, and characters in a file of any extension from current directory.", "parameters": {"type": "dict", "properties": {"file_name": {"type": "string", "description": "Name of the file of current directory to perform wc operation on."}, "mode": {"type": "string", "description": "Mode of operation ('l' for lines, 'w' for words, 'c' for characters). ", "default": "l"}}, "required": ["file_name"]}, "response": {"type": "dict", "properties": {"count": {"type": "integer", "description": "The count of the number of lines, words, or characters in the file."}, "type": {"type": "string", "description": "The type of unit we are counting. [Enum]: [\"lines\", \"words\", \"characters\"]"}}}}
|
config/math_api.json
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"name": "absolute_value", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Calculate the absolute value of a number.", "parameters": {"type": "dict", "properties": {"number": {"type": "float", "description": "The number to calculate the absolute value of. "}}, "required": ["number"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The absolute value of the number."}}}}
|
2 |
+
{"name": "add", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Add two numbers.", "parameters": {"type": "dict", "properties": {"a": {"type": "float", "description": "First number."}, "b": {"type": "float", "description": "Second number. "}}, "required": ["a", "b"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "Sum of the two numbers."}}}}
|
3 |
+
{"name": "divide", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Divide one number by another.", "parameters": {"type": "dict", "properties": {"a": {"type": "float", "description": "Numerator."}, "b": {"type": "float", "description": "Denominator. "}}, "required": ["a", "b"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "Quotient of the division."}}}}
|
4 |
+
{"name": "imperial_si_conversion", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Convert a value between imperial and SI units.", "parameters": {"type": "dict", "properties": {"value": {"type": "float", "description": "Value to be converted."}, "unit_in": {"type": "string", "description": "Unit of the input value."}, "unit_out": {"type": "string", "description": "Unit to convert the value to. "}}, "required": ["value", "unit_in", "unit_out"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "Converted value in the new unit."}}}}
|
5 |
+
{"name": "logarithm", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Compute the logarithm of a number with adjustable precision using mpmath.", "parameters": {"type": "dict", "properties": {"value": {"type": "float", "description": "The number to compute the logarithm of."}, "base": {"type": "float", "description": "The base of the logarithm."}, "precision": {"type": "integer", "description": "Desired precision for the result. "}}, "required": ["value", "base", "precision"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The logarithm of the number with respect to the given base."}}}}
|
6 |
+
{"name": "max_value", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Find the maximum value in a list of numbers.", "parameters": {"type": "dict", "properties": {"numbers": {"type": "array", "items": {"type": "float"}, "description": "List of numbers to find the maximum from. "}}, "required": ["numbers"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The maximum value in the list."}}}}
|
7 |
+
{"name": "mean", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Calculate the mean of a list of numbers.", "parameters": {"type": "dict", "properties": {"numbers": {"type": "array", "items": {"type": "float"}, "description": "List of numbers to calculate the mean of. "}}, "required": ["numbers"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "Mean of the numbers."}}}}
|
8 |
+
{"name": "min_value", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Find the minimum value in a list of numbers.", "parameters": {"type": "dict", "properties": {"numbers": {"type": "array", "items": {"type": "float"}, "description": "List of numbers to find the minimum from. "}}, "required": ["numbers"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The minimum value in the list."}}}}
|
9 |
+
{"name": "multiply", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Multiply two numbers.", "parameters": {"type": "dict", "properties": {"a": {"type": "float", "description": "First number."}, "b": {"type": "float", "description": "Second number. "}}, "required": ["a", "b"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "Product of the two numbers."}}}}
|
10 |
+
{"name": "percentage", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Calculate the percentage of a part relative to a whole.", "parameters": {"type": "dict", "properties": {"part": {"type": "float", "description": "The part value."}, "whole": {"type": "float", "description": "The whole value. "}}, "required": ["part", "whole"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The percentage of the part relative to the whole."}}}}
|
11 |
+
{"name": "power", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Raise a number to a power.", "parameters": {"type": "dict", "properties": {"base": {"type": "float", "description": "The base number."}, "exponent": {"type": "float", "description": "The exponent. "}}, "required": ["base", "exponent"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The base raised to the power of the exponent."}}}}
|
12 |
+
{"name": "round_number", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Round a number to a specified number of decimal places.", "parameters": {"type": "dict", "properties": {"number": {"type": "float", "description": "The number to round."}, "decimal_places": {"type": "integer", "description": "The number of decimal places to round to. Defaults to 0. ", "default": 0}}, "required": ["number"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The rounded number."}}}}
|
13 |
+
{"name": "si_unit_conversion", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Convert a value from one SI unit to another.", "parameters": {"type": "dict", "properties": {"value": {"type": "float", "description": "Value to be converted."}, "unit_in": {"type": "string", "description": "Unit of the input value."}, "unit_out": {"type": "string", "description": "Unit to convert the value to. "}}, "required": ["value", "unit_in", "unit_out"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "Converted value in the new unit."}}}}
|
14 |
+
{"name": "square_root", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Calculate the square root of a number with adjustable precision using the decimal module.", "parameters": {"type": "dict", "properties": {"number": {"type": "float", "description": "The number to calculate the square root of."}, "precision": {"type": "integer", "description": "Desired precision for the result. "}}, "required": ["number", "precision"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The square root of the number, or an error message."}}}}
|
15 |
+
{"name": "standard_deviation", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Calculate the standard deviation of a list of numbers.", "parameters": {"type": "dict", "properties": {"numbers": {"type": "array", "items": {"type": "float"}, "description": "List of numbers to calculate the standard deviation of. "}}, "required": ["numbers"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "Standard deviation of the numbers."}}}}
|
16 |
+
{"name": "subtract", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Subtract one number from another.", "parameters": {"type": "dict", "properties": {"a": {"type": "float", "description": "Number to subtract from."}, "b": {"type": "float", "description": "Number to subtract. "}}, "required": ["a", "b"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "Difference between the two numbers."}}}}
|
17 |
+
{"name": "sum_values", "description": "This tool belongs to the Math API, which provides various mathematical operations. Tool description: Calculate the sum of a list of numbers.", "parameters": {"type": "dict", "properties": {"numbers": {"type": "array", "items": {"type": "float"}, "description": "List of numbers to sum. "}}, "required": ["numbers"]}, "response": {"type": "dict", "properties": {"result": {"type": "float", "description": "The sum of all numbers in the list."}}}}
|
config/message_api.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"name": "add_contact", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: Add a contact to the workspace.", "parameters": {"type": "dict", "properties": {"user_name": {"type": "string", "description": "User name of contact to be added."}}, "required": ["user_name"]}, "response": {"type": "dict", "properties": {"added_status": {"type": "boolean", "description": "True if the contact was added successfully, False otherwise."}, "user_id": {"type": "string", "description": "User ID of the added contact."}, "message": {"type": "string", "description": "A message describing the result of the addition attempt."}}}}
|
2 |
+
{"name": "delete_message", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: Delete the latest message sent to a receiver.", "parameters": {"type": "dict", "properties": {"receiver_id": {"type": "string", "description": "User ID of the user to send the message to."}, "message_id": {"type": "integer", "description": "ID of the message to be deleted."}}, "required": ["receiver_id"]}, "response": {"type": "dict", "properties": {"deleted_status": {"type": "boolean", "description": "True if the message was deleted successfully, False otherwise."}, "message_id": {"type": "integer", "description": "ID of the deleted message."}, "message": {"type": "string", "description": "A message describing the result of the deletion attempt."}}}}
|
3 |
+
{"name": "get_message_stats", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: Get statistics about messages for the current user.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"stats": {"type": "dict", "description": "Dictionary containing message statistics.", "properties": {"received_count": {"type": "integer", "description": "Number of messages received by the current user."}, "total_contacts": {"type": "integer", "description": "Total number of contacts the user has interacted with."}}}}}}
|
4 |
+
{"name": "get_user_id", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: Get user ID from user name.", "parameters": {"type": "dict", "properties": {"user": {"type": "string", "description": "User name of the user. "}}, "required": ["user"]}, "response": {"type": "dict", "properties": {"user_id": {"type": "string", "description": "User ID of the user"}}}}
|
5 |
+
{"name": "list_users", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: List all users in the workspace.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"user_list": {"type": "array", "description": "List of all users in the workspace.", "items": {"type": "string"}}}}}
|
6 |
+
{"name": "message_get_login_status", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: Get the login status of the current user.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"login_status": {"type": "boolean", "description": "True if the current user is logged in, False otherwise."}}}}
|
7 |
+
{"name": "message_login", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: Log in a user with the given user ID to messeage application.", "parameters": {"type": "dict", "properties": {"user_id": {"type": "string", "description": "User ID of the user to log in. "}}, "required": ["user_id"]}, "response": {"type": "dict", "properties": {"login_status": {"type": "boolean", "description": "True if login was successful, False otherwise."}, "message": {"type": "string", "description": "A message describing the result of the login attempt."}}}}
|
8 |
+
{"name": "search_messages", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: Search for messages containing a specific keyword.", "parameters": {"type": "dict", "properties": {"keyword": {"type": "string", "description": "The keyword to search for in messages."}}, "required": ["keyword"]}, "response": {"type": "dict", "properties": {"results": {"type": "array", "description": "List of dictionaries containing matching messages.", "items": {"type": "dict", "properties": {"receiver_id": {"type": "string", "description": "User ID of the receiver of the message."}, "message": {"type": "string", "description": "The message containing the keyword."}}}}}}}
|
9 |
+
{"name": "send_message", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: Send a message to a user.", "parameters": {"type": "dict", "properties": {"receiver_id": {"type": "string", "description": "User ID of the user to send the message to."}, "message": {"type": "string", "description": "Message to be sent."}}, "required": ["receiver_id", "message"]}, "response": {"type": "dict", "properties": {"sent_status": {"type": "boolean", "description": "True if the message was sent successfully, False otherwise."}, "message_id": {"type": "integer", "description": "ID of the sent message."}, "message": {"type": "string", "description": "A message describing the result of the send attempt."}}}}
|
10 |
+
{"name": "view_messages_sent", "description": "This tool belongs to the Message API, which is used to manage user interactions in a workspace. Tool description: View all historical messages sent by the current user.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"messages": {"type": "dict", "description": "Dictionary of messages grouped by receiver An example of the messages dictionary is {\"USR001\":[\"Hello\"],\"USR002\":[\"World\"]}."}}}}
|
config/posting_api.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"name": "authenticate_twitter", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Authenticate a user with username and password.", "parameters": {"type": "dict", "properties": {"username": {"type": "string", "description": "Username of the user."}, "password": {"type": "string", "description": "Password of the user."}}, "required": ["username", "password"]}, "response": {"type": "dict", "properties": {"authentication_status": {"type": "boolean", "description": "True if authenticated, False otherwise."}}}}
|
2 |
+
{"name": "comment", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Comment on a tweet for the authenticated user.", "parameters": {"type": "dict", "properties": {"tweet_id": {"type": "integer", "description": "ID of the tweet to comment on."}, "comment_content": {"type": "string", "description": "Content of the comment."}}, "required": ["tweet_id", "comment_content"]}, "response": {"type": "dict", "properties": {"comment_status": {"type": "string", "description": "Status of the comment action."}}}}
|
3 |
+
{"name": "follow_user", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Follow a user for the authenticated user.", "parameters": {"type": "dict", "properties": {"username_to_follow": {"type": "string", "description": "Username of the user to follow."}}, "required": ["username_to_follow"]}, "response": {"type": "dict", "properties": {"follow_status": {"type": "boolean", "description": "True if followed, False if already following."}}}}
|
4 |
+
{"name": "get_tweet", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Retrieve a specific tweet.", "parameters": {"type": "dict", "properties": {"tweet_id": {"type": "integer", "description": "ID of the tweet to retrieve."}}, "required": ["tweet_id"]}, "response": {"type": "dict", "properties": {"id": {"type": "integer", "description": "ID of the retrieved tweet."}, "username": {"type": "string", "description": "Username of the tweet's author."}, "content": {"type": "string", "description": "Content of the tweet."}, "tags": {"type": "array", "description": "List of tags associated with the tweet.", "items": {"type": "string"}}, "mentions": {"type": "array", "description": "List of users mentioned in the tweet.", "items": {"type": "string"}}}}}
|
5 |
+
{"name": "get_tweet_comments", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Retrieve all comments for a specific tweet.", "parameters": {"type": "dict", "properties": {"tweet_id": {"type": "integer", "description": "ID of the tweet to retrieve comments for."}}, "required": ["tweet_id"]}, "response": {"type": "dict", "properties": {"comments": {"type": "array", "description": "List of dictionaries, each containing comment information.", "items": {"type": "dict", "properties": {"username": {"type": "string", "description": "Username of the commenter."}, "content": {"type": "string", "description": "Content of the comment."}}}}}}}
|
6 |
+
{"name": "get_user_stats", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Get statistics for a specific user.", "parameters": {"type": "dict", "properties": {"username": {"type": "string", "description": "Username of the user to get statistics for."}}, "required": ["username"]}, "response": {"type": "dict", "properties": {"tweet_count": {"type": "integer", "description": "Number of tweets posted by the user."}, "following_count": {"type": "integer", "description": "Number of users the specified user is following."}, "retweet_count": {"type": "integer", "description": "Number of retweets made by the user."}}}}
|
7 |
+
{"name": "get_user_tweets", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Retrieve all tweets from a specific user.", "parameters": {"type": "dict", "properties": {"username": {"type": "string", "description": "Username of the user whose tweets to retrieve."}}, "required": ["username"]}, "response": {"type": "dict", "properties": {"user_tweets": {"type": "array", "description": "List of dictionaries, each containing tweet information.", "items": {"type": "dict", "properties": {"id": {"type": "integer", "description": "ID of the retrieved tweet."}, "username": {"type": "string", "description": "Username of the tweet's author."}, "content": {"type": "string", "description": "Content of the tweet."}, "tags": {"type": "array", "description": "List of tags associated with the tweet.", "items": {"type": "string"}}, "mentions": {"type": "array", "description": "List of users mentioned in the tweet.", "items": {"type": "string"}}}}}}}}
|
8 |
+
{"name": "list_all_following", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: List all users that the authenticated user is following.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"following_list": {"type": "array", "description": "List of all users that the authenticated user is following.", "items": {"type": "string"}}}}}
|
9 |
+
{"name": "mention", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Mention specified users in a tweet.", "parameters": {"type": "dict", "properties": {"tweet_id": {"type": "integer", "description": "ID of the tweet where users are mentioned."}, "mentioned_usernames": {"type": "array", "items": {"type": "string"}, "description": "List of usernames to be mentioned."}}, "required": ["tweet_id", "mentioned_usernames"]}, "response": {"type": "dict", "properties": {"mention_status": {"type": "string", "description": "Status of the mention action."}}}}
|
10 |
+
{"name": "post_tweet", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Post a tweet for the authenticated user.", "parameters": {"type": "dict", "properties": {"content": {"type": "string", "description": "Content of the tweet."}, "tags": {"type": "array", "items": {"type": "string"}, "description": "List of tags for the tweet. Tag name should start with #. This is only relevant if the user wants to add tags to the tweet.", "default": []}, "mentions": {"type": "array", "items": {"type": "string"}, "description": "List of users mentioned in the tweet. Mention name should start with @. This is only relevant if the user wants to add mentions to the tweet.", "default": []}}, "required": ["content"]}, "response": {"type": "dict", "properties": {"id": {"type": "integer", "description": "ID of the posted tweet."}, "username": {"type": "string", "description": "Username of the poster."}, "content": {"type": "string", "description": "Content of the tweet."}, "tags": {"type": "array", "description": "List of tags associated with the tweet.", "items": {"type": "string"}}, "mentions": {"type": "array", "description": "List of users mentioned in the tweet.", "items": {"type": "string"}}}}}
|
11 |
+
{"name": "posting_get_login_status", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Get the login status of the current user.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"login_status": {"type": "boolean", "description": "True if the current user is logged in, False otherwise."}}}}
|
12 |
+
{"name": "retweet", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Retweet a tweet for the authenticated user.", "parameters": {"type": "dict", "properties": {"tweet_id": {"type": "integer", "description": "ID of the tweet to retweet."}}, "required": ["tweet_id"]}, "response": {"type": "dict", "properties": {"retweet_status": {"type": "string", "description": "Status of the retweet action."}}}}
|
13 |
+
{"name": "search_tweets", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Search for tweets containing a specific keyword.", "parameters": {"type": "dict", "properties": {"keyword": {"type": "string", "description": "Keyword to search for in the content of the tweets."}}, "required": ["keyword"]}, "response": {"type": "dict", "properties": {"matching_tweets": {"type": "array", "description": "List of dictionaries, each containing tweet information.", "items": {"type": "dict", "properties": {"id": {"type": "integer", "description": "ID of the retrieved tweet."}, "username": {"type": "string", "description": "Username of the tweet's author."}, "content": {"type": "string", "description": "Content of the tweet."}, "tags": {"type": "array", "description": "List of tags associated with the tweet.", "items": {"type": "string"}}, "mentions": {"type": "array", "description": "List of users mentioned in the tweet.", "items": {"type": "string"}}}}}}}}
|
14 |
+
{"name": "unfollow_user", "description": "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter. Tool description: Unfollow a user for the authenticated user.", "parameters": {"type": "dict", "properties": {"username_to_unfollow": {"type": "string", "description": "Username of the user to unfollow."}}, "required": ["username_to_unfollow"]}, "response": {"type": "dict", "properties": {"unfollow_status": {"type": "boolean", "description": "True if unfollowed, False if not following."}}}}
|
config/ticket_api.json
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"name": "close_ticket", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Close a ticket.", "parameters": {"type": "dict", "properties": {"ticket_id": {"type": "integer", "description": "ID of the ticket to be closed. "}}, "required": ["ticket_id"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Status of the close operation."}}}}
|
2 |
+
{"name": "create_ticket", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Create a ticket in the system and queue it.", "parameters": {"type": "dict", "properties": {"title": {"type": "string", "description": "Title of the ticket."}, "description": {"type": "string", "description": "Description of the ticket. Defaults to an empty string.", "default": ""}, "priority": {"type": "integer", "description": "Priority of the ticket, from 1 to 5. Defaults to 1. 5 is the highest priority. ", "default": 1}}, "required": ["title"]}, "response": {"type": "dict", "properties": {"id": {"type": "integer", "description": "Unique identifier of the ticket."}, "title": {"type": "string", "description": "Title of the ticket."}, "description": {"type": "string", "description": "Description of the ticket."}, "status": {"type": "string", "description": "Current status of the ticket."}, "priority": {"type": "integer", "description": "Priority level of the ticket."}}}}
|
3 |
+
{"name": "edit_ticket", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Modify the details of an existing ticket.", "parameters": {"type": "dict", "properties": {"ticket_id": {"type": "integer", "description": "ID of the ticket to be changed."}, "updates": {"type": "dict", "description": "Dictionary containing the fields to be updated. - title (str) : [Optional] New title for the ticket. ", "properties": {"description": {"type": "string", "description": "New description for the ticket."}, "status": {"type": "string", "description": "New status for the ticket."}, "priority": {"type": "integer", "description": "New priority for the ticket."}}}}, "required": ["ticket_id", "updates"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Status of the update operation."}}}}
|
4 |
+
{"name": "get_ticket", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Get a specific ticket by its ID.", "parameters": {"type": "dict", "properties": {"ticket_id": {"type": "integer", "description": "ID of the ticket to retrieve. "}}, "required": ["ticket_id"]}, "response": {"type": "dict", "properties": {"id": {"type": "integer", "description": "Unique identifier of the ticket."}, "title": {"type": "string", "description": "Title of the ticket."}, "description": {"type": "string", "description": "Description of the ticket."}, "status": {"type": "string", "description": "Current status of the ticket."}, "priority": {"type": "integer", "description": "Priority level of the ticket."}, "created_by": {"type": "string", "description": "Username of the ticket creator."}}}}
|
5 |
+
{"name": "get_user_tickets", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Get all tickets created by the current user, optionally filtered by status.", "parameters": {"type": "dict", "properties": {"status": {"type": "string", "description": "Status to filter tickets by. If None, return all tickets. ", "default": "None"}}, "required": []}, "response": {"type": "dict", "properties": {"id": {"type": "integer", "description": "Unique identifier of the ticket."}, "title": {"type": "string", "description": "Title of the ticket."}, "description": {"type": "string", "description": "Description of the ticket."}, "status": {"type": "string", "description": "Current status of the ticket."}, "priority": {"type": "integer", "description": "Priority level of the ticket."}, "created_by": {"type": "string", "description": "Username of the ticket"}}}}
|
6 |
+
{"name": "logout", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Log out the current user.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"success": {"type": "boolean", "description": "True if logout was successful, False otherwise."}}}}
|
7 |
+
{"name": "resolve_ticket", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Resolve a ticket with a resolution.", "parameters": {"type": "dict", "properties": {"ticket_id": {"type": "integer", "description": "ID of the ticket to be resolved."}, "resolution": {"type": "string", "description": "Resolution details for the ticket. "}}, "required": ["ticket_id", "resolution"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Status of the resolve operation."}}}}
|
8 |
+
{"name": "ticket_get_login_status", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Get the username of the currently authenticated user.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"username": {"type": "boolean", "description": "True if a user is logged in, False otherwise."}}}}
|
9 |
+
{"name": "ticket_login", "description": "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets. Tool description: Authenticate a user for ticket system.", "parameters": {"type": "dict", "properties": {"username": {"type": "string", "description": "Username of the user."}, "password": {"type": "string", "description": "Password of the user. "}}, "required": ["username", "password"]}, "response": {"type": "dict", "properties": {"success": {"type": "boolean", "description": "True if login was successful, False otherwise."}}}}
|
config/trading_bot.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"name": "add_to_watchlist", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Add a stock to the watchlist.", "parameters": {"type": "dict", "properties": {"stock": {"type": "string", "description": "the stock symbol to add to the watchlist. "}}, "required": ["stock"]}, "response": {"type": "dict", "properties": {"symbol": {"type": "string", "description": "the symbol that were successfully added to the watchlist."}}}}
|
2 |
+
{"name": "cancel_order", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Cancel an order.", "parameters": {"type": "dict", "properties": {"order_id": {"type": "integer", "description": "ID of the order to cancel. "}}, "required": ["order_id"]}, "response": {"type": "dict", "properties": {"order_id": {"type": "integer", "description": "ID of the cancelled order."}, "status": {"type": "string", "description": "New status of the order after cancellation attempt."}}}}
|
3 |
+
{"name": "filter_stocks_by_price", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Filter stocks based on a price range.", "parameters": {"type": "dict", "properties": {"stocks": {"type": "array", "items": {"type": "string"}, "description": "List of stock symbols to filter."}, "min_price": {"type": "float", "description": "Minimum stock price."}, "max_price": {"type": "float", "description": "Maximum stock price. "}}, "required": ["stocks", "min_price", "max_price"]}, "response": {"type": "dict", "properties": {"filtered_stocks": {"type": "array", "description": "Filtered list of stock symbols within the price range.", "items": {"type": "string"}}}}}
|
4 |
+
{"name": "fund_account", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Fund the account with the specified amount.", "parameters": {"type": "dict", "properties": {"amount": {"type": "float", "description": "Amount to fund the account with. "}}, "required": ["amount"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Status of the funding operation."}, "new_balance": {"type": "float", "description": "Updated account balance after funding."}}}}
|
5 |
+
{"name": "get_account_info", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get account information.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"account_id": {"type": "integer", "description": "ID of the account."}, "balance": {"type": "float", "description": "Current balance of the account."}, "binding_card": {"type": "integer", "description": "Card number associated with the account."}}}}
|
6 |
+
{"name": "get_available_stocks", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get a list of stock symbols in the given sector.", "parameters": {"type": "dict", "properties": {"sector": {"type": "string", "description": "The sector to retrieve stocks from (e.g., 'Technology'). "}}, "required": ["sector"]}, "response": {"type": "dict", "properties": {"stock_list": {"type": "array", "description": "List of stock symbols in the specified sector.", "items": {"type": "string"}}}}}
|
7 |
+
{"name": "get_current_time", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get the current time.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"current_time": {"type": "string", "description": "Current time in HH:MM AM/PM format."}}}}
|
8 |
+
{"name": "get_order_details", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get the details of an order.", "parameters": {"type": "dict", "properties": {"order_id": {"type": "integer", "description": "ID of the order. "}}, "required": ["order_id"]}, "response": {"type": "dict", "properties": {"id": {"type": "integer", "description": "ID of the order."}, "order_type": {"type": "string", "description": "Type of the order."}, "symbol": {"type": "string", "description": "Symbol of the stock in the order."}, "price": {"type": "float", "description": "Price at which the order was placed."}, "amount": {"type": "integer", "description": "Number of shares in the order."}, "status": {"type": "string", "description": "Current status of the order. [Enum]: [\"Open\", \"Pending\", \"Completed\", \"Cancelled\"]"}}}}
|
9 |
+
{"name": "get_order_history", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get the stock order ID history.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"order_history": {"type": "array", "description": "List of orders ID in the order history.", "items": {"type": "integer"}}}}}
|
10 |
+
{"name": "get_stock_info", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get the details of a stock.", "parameters": {"type": "dict", "properties": {"symbol": {"type": "string", "description": "Symbol that uniquely identifies the stock. "}}, "required": ["symbol"]}, "response": {"type": "dict", "properties": {"price": {"type": "float", "description": "Current price of the stock."}, "percent_change": {"type": "float", "description": "Percentage change in stock price."}, "volume": {"type": "float", "description": "Trading volume of the stock. MA(5) (float): 5-day Moving Average of the stock. MA(20) (float): 20-day Moving Average of the stock."}}}}
|
11 |
+
{"name": "get_symbol_by_name", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get the symbol of a stock by company name.", "parameters": {"type": "dict", "properties": {"name": {"type": "string", "description": "Name of the company. "}}, "required": ["name"]}, "response": {"type": "dict", "properties": {"symbol": {"type": "string", "description": "Symbol of the stock or \"Stock not found\" if not available."}}}}
|
12 |
+
{"name": "get_transaction_history", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get the transaction history within a specified date range.", "parameters": {"type": "dict", "properties": {"start_date": {"type": "string", "description": "Start date for the history (format: 'YYYY-MM-DD').", "default": "None"}, "end_date": {"type": "string", "description": "End date for the history (format: 'YYYY-MM-DD'). ", "default": "None"}}, "required": []}, "response": {"type": "dict", "properties": {"transaction_history": {"type": "array", "description": "List of transactions within the specified date range.", "items": {"type": "dict", "properties": {"type": {"type": "string", "description": "Type of transaction. [Enum]: [\"deposit\", \"withdrawal\"]"}, "amount": {"type": "float", "description": "Amount involved in the transaction."}, "timestamp": {"type": "string", "description": "Timestamp of the transaction, formatted as 'YYYY-MM-DD HH:MM:SS'."}}}}}}}
|
13 |
+
{"name": "get_watchlist", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get the watchlist.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"watchlist": {"type": "array", "description": "List of stock symbols in the watchlist.", "items": {"type": "string"}}}}}
|
14 |
+
{"name": "make_transaction", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Make a deposit or withdrawal based on specified amount.", "parameters": {"type": "dict", "properties": {"account_id": {"type": "integer", "description": "ID of the account."}, "xact_type": {"type": "string", "description": "Transaction type (deposit or withdrawal)."}, "amount": {"type": "float", "description": "Amount to deposit or withdraw. "}}, "required": ["account_id", "xact_type", "amount"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Status of the transaction."}, "new_balance": {"type": "float", "description": "Updated account balance after the transaction."}}}}
|
15 |
+
{"name": "notify_price_change", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Notify if there is a significant price change in the stocks.", "parameters": {"type": "dict", "properties": {"stocks": {"type": "array", "items": {"type": "string"}, "description": "List of stock symbols to check."}, "threshold": {"type": "float", "description": "Percentage change threshold to trigger a notification. "}}, "required": ["stocks", "threshold"]}, "response": {"type": "dict", "properties": {"notification": {"type": "string", "description": "Notification message about the price changes."}}}}
|
16 |
+
{"name": "place_order", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Place an order.", "parameters": {"type": "dict", "properties": {"order_type": {"type": "string", "description": "Type of the order (Buy/Sell)."}, "symbol": {"type": "string", "description": "Symbol of the stock to trade."}, "price": {"type": "float", "description": "Price at which to place the order."}, "amount": {"type": "integer", "description": "Number of shares to trade. "}}, "required": ["order_type", "symbol", "price", "amount"]}, "response": {"type": "dict", "properties": {"order_id": {"type": "integer", "description": "ID of the newly placed order."}, "order_type": {"type": "string", "description": "Type of the order (Buy/Sell)."}, "status": {"type": "string", "description": "Initial status of the order."}, "price": {"type": "float", "description": "Price at which the order was placed."}, "amount": {"type": "integer", "description": "Number of shares in the order."}}}}
|
17 |
+
{"name": "remove_stock_from_watchlist", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Remove a stock from the watchlist.", "parameters": {"type": "dict", "properties": {"symbol": {"type": "string", "description": "Symbol of the stock to remove. "}}, "required": ["symbol"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Status of the removal operation."}}}}
|
18 |
+
{"name": "trading_get_login_status", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Get the login status.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"status": {"type": "boolean", "description": "Login status."}}}}
|
19 |
+
{"name": "trading_login", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Handle user login.", "parameters": {"type": "dict", "properties": {"username": {"type": "string", "description": "Username for authentication."}, "password": {"type": "string", "description": "Password for authentication. "}}, "required": ["username", "password"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Login status message."}}}}
|
20 |
+
{"name": "trading_logout", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Handle user logout for trading system.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Logout status message."}}}}
|
21 |
+
{"name": "update_market_status", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Update the market status based on the current time.", "parameters": {"type": "dict", "properties": {"current_time_str": {"type": "string", "description": "Current time in HH:MM AM/PM format. "}}, "required": ["current_time_str"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "Status of the market. [Enum]: [\"Open\", \"Closed\"]"}}}}
|
22 |
+
{"name": "update_stock_price", "description": "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information. Tool description: Update the price of a stock.", "parameters": {"type": "dict", "properties": {"symbol": {"type": "string", "description": "Symbol of the stock to update."}, "new_price": {"type": "float", "description": "New price of the stock. "}}, "required": ["symbol", "new_price"]}, "response": {"type": "dict", "properties": {"symbol": {"type": "string", "description": "Symbol of the updated stock."}, "old_price": {"type": "float", "description": "Previous price of the stock."}, "new_price": {"type": "float", "description": "Updated price of the stock."}}}}
|
config/travel_booking.json
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"name": "authenticate_travel", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Authenticate the user with the travel API", "parameters": {"type": "dict", "properties": {"client_id": {"type": "string", "description": "The client applications client_id supplied by App Management"}, "client_secret": {"type": "string", "description": "The client applications client_secret supplied by App Management"}, "refresh_token": {"type": "string", "description": "The refresh token obtained from the initial authentication"}, "grant_type": {"type": "string", "description": "The grant type of the authentication request. Here are the options: read_write, read, write"}, "user_first_name": {"type": "string", "description": "The first name of the user"}, "user_last_name": {"type": "string", "description": "The last name of the user"}}, "required": ["client_id", "client_secret", "refresh_token", "grant_type", "user_first_name", "user_last_name"]}, "response": {"type": "dict", "properties": {"expires_in": {"type": "integer", "description": "The number of time it can use until the access token expires"}, "access_token": {"type": "string", "description": "The access token to be used in the Authorization header of future requests"}, "token_type": {"type": "string", "description": "The type of token"}, "scope": {"type": "string", "description": "The scope of the token"}}}}
|
2 |
+
{"name": "book_flight", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Book a flight given the travel information. From and To should be the airport codes in the IATA format.", "parameters": {"type": "dict", "properties": {"access_token": {"type": "string", "description": "The access token obtained from the authenticate"}, "card_id": {"type": "string", "description": "The ID of the credit card to use for the booking"}, "travel_date": {"type": "string", "description": "The date of the travel in the format YYYY-MM-DD"}, "travel_from": {"type": "string", "description": "The location the travel is from"}, "travel_to": {"type": "string", "description": "The location the travel is to"}, "travel_class": {"type": "string", "description": "The class of the travel"}, "travel_cost": {"type": "float", "description": "The cost of the travel"}}, "required": ["access_token", "card_id", "travel_date", "travel_from", "travel_to", "travel_class", "travel_cost"]}, "response": {"type": "dict", "properties": {"booking_id": {"type": "string", "description": "The ID of the booking"}, "transaction_id": {"type": "string", "description": "The ID of the transaction"}, "booking_status": {"type": "boolean", "description": "The status of the booking, True if successful, False if failed"}, "booking_history": {"type": "dict", "description": "The booking history if long context is enabled", "properties": {"booking_id": {"type": "string", "description": "The ID of the booking"}, "transaction_id": {"type": "string", "description": "The ID of the transaction"}, "travel_date": {"type": "string", "description": "The date of the travel"}, "travel_from": {"type": "string", "description": "The location the travel is from"}, "travel_to": {"type": "string", "description": "The location the travel is to"}, "travel_class": {"type": "string", "description": "The class of the travel"}, "travel_cost": {"type": "float", "description": "The cost of the travel"}}}}}}
|
3 |
+
{"name": "cancel_booking", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Cancel a booking", "parameters": {"type": "dict", "properties": {"access_token": {"type": "string", "description": "The access token obtained from the authenticate"}, "booking_id": {"type": "string", "description": "The ID of the booking"}}, "required": ["access_token", "booking_id"]}, "response": {"type": "dict", "properties": {"cancel_status": {"type": "boolean", "description": "The status of the cancellation, True if successful, False if failed"}}}}
|
4 |
+
{"name": "compute_exchange_rate", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Compute the exchange rate between two currencies", "parameters": {"type": "dict", "properties": {"base_currency": {"type": "string", "description": "The base currency. [Enum]: USD, RMB, EUR, JPY, GBP, CAD, AUD, INR, RUB, BRL, MXN"}, "target_currency": {"type": "string", "description": "The target currency. [Enum]: USD, RMB, EUR, JPY, GBP, CAD, AUD, INR, RUB, BRL, MXN"}, "value": {"type": "float", "description": "The value to convert"}}, "required": ["base_currency", "target_currency", "value"]}, "response": {"type": "dict", "properties": {"exchanged_value": {"type": "float", "description": "The value after the exchange"}}}}
|
5 |
+
{"name": "contact_customer_support", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Contact travel booking customer support, get immediate support on an issue with an online call.", "parameters": {"type": "dict", "properties": {"booking_id": {"type": "string", "description": "The ID of the booking"}, "message": {"type": "string", "description": "The message to send to customer support"}}, "required": ["booking_id", "message"]}, "response": {"type": "dict", "properties": {"customer_support_message": {"type": "string", "description": "The message from customer support"}}}}
|
6 |
+
{"name": "get_all_credit_cards", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Get all registered credit cards", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"credit_card_list": {"type": "dict", "description": "A dictionary containing all registered credit cards", "properties": {"card_number": {"type": "string", "description": "The number of the credit card"}, "expiration_date": {"type": "string", "description": "The expiration date of the credit card in the format YYYY-MM-DD"}, "cardholder_name": {"type": "string", "description": "The name of the cardholder"}, "card_verification_value": {"type": "integer", "description": "The verification value of the credit card"}, "balance": {"type": "float", "description": "The balance of the credit card"}}}}}}
|
7 |
+
{"name": "get_budget_fiscal_year", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Get the budget fiscal year", "parameters": {"type": "dict", "properties": {"lastModifiedAfter": {"type": "string", "description": "Use this field if you only want Fiscal Years that were changed after the supplied date. The supplied date will be interpreted in the UTC time zone. If lastModifiedAfter is not supplied, the service will return all Fiscal Years, regardless of modified date. Example: 2016-03-29T16:12:20. Return in the format of YYYY-MM-DDTHH:MM:SS.", "default": "None"}, "includeRemoved": {"type": "string", "description": "If true, the service will return all Fiscal Years, including those that were previously removed. If not supplied, this field defaults to false.", "default": "None"}}, "required": []}, "response": {"type": "dict", "properties": {"budget_fiscal_year": {"type": "string", "description": "The budget fiscal year"}}}}
|
8 |
+
{"name": "get_credit_card_balance", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Get the balance of a credit card", "parameters": {"type": "dict", "properties": {"access_token": {"type": "string", "description": "The access token obtained from the authenticate"}, "card_id": {"type": "string", "description": "The ID of the credit card"}}, "required": ["access_token", "card_id"]}, "response": {"type": "dict", "properties": {"card_balance": {"type": "float", "description": "The balance of the credit card"}}}}
|
9 |
+
{"name": "get_flight_cost", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Get the list of cost of a flight in USD based on location, date, and class", "parameters": {"type": "dict", "properties": {"travel_from": {"type": "string", "description": "The 3 letter code of the departing airport"}, "travel_to": {"type": "string", "description": "The 3 letter code of the arriving airport"}, "travel_date": {"type": "string", "description": "The date of the travel in the format 'YYYY-MM-DD'"}, "travel_class": {"type": "string", "description": "The class of the travel. Options are: economy, business, first."}}, "required": ["travel_from", "travel_to", "travel_date", "travel_class"]}, "response": {"type": "dict", "properties": {"travel_cost_list": {"type": "array", "description": "The list of cost of the travel", "items": {"type": "float"}}}}}
|
10 |
+
{"name": "get_nearest_airport_by_city", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Get the nearest airport to the given location", "parameters": {"type": "dict", "properties": {"location": {"type": "string", "description": "The name of the location. [Enum]: Rivermist, Stonebrook, Maplecrest, Silverpine, Shadowridge, London, Paris, Sunset Valley, Oakendale, Willowbend, Crescent Hollow, Autumnville, Pinehaven, Greenfield, San Francisco, Los Angeles, New York, Chicago, Boston, Beijing, Hong Kong, Rome, Tokyo"}}, "required": ["location"]}, "response": {"type": "dict", "properties": {"nearest_airport": {"type": "string", "description": "The nearest airport to the given location"}}}}
|
11 |
+
{"name": "list_all_airports", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: List all available airports", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"airports": {"type": "array", "description": "A list of all available airports", "items": {"type": "string"}}}}}
|
12 |
+
{"name": "purchase_insurance", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Purchase insurance", "parameters": {"type": "dict", "properties": {"access_token": {"type": "string", "description": "The access token obtained from the authenticate"}, "insurance_type": {"type": "string", "description": "The type of insurance to purchase"}, "insurance_cost": {"type": "float", "description": "The cost of the insurance"}, "booking_id": {"type": "string", "description": "The ID of the booking"}, "card_id": {"type": "string", "description": "The ID of the credit card to use for the"}}, "required": ["access_token", "insurance_type", "booking_id", "insurance_cost", "card_id"]}, "response": {"type": "dict", "properties": {"insurance_id": {"type": "string", "description": "The ID of the insurance"}, "insurance_status": {"type": "boolean", "description": "The status of the insurance purchase, True if successful, False if failed"}}}}
|
13 |
+
{"name": "register_credit_card", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Register a credit card", "parameters": {"type": "dict", "properties": {"access_token": {"type": "string", "description": "The access token obtained from the authenticate method"}, "card_number": {"type": "string", "description": "The credit card number"}, "expiration_date": {"type": "string", "description": "The expiration date of the credit card in the format MM/YYYY"}, "cardholder_name": {"type": "string", "description": "The name of the cardholder"}, "card_verification_number": {"type": "integer", "description": "The card verification number"}}, "required": ["access_token", "card_number", "expiration_date", "cardholder_name", "card_verification_number"]}, "response": {"type": "dict", "properties": {"card_id": {"type": "string", "description": "The ID of the registered credit card"}}}}
|
14 |
+
{"name": "retrieve_invoice", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Retrieve the invoice for a booking", "parameters": {"type": "dict", "properties": {"access_token": {"type": "string", "description": "The access token obtained from the authenticate"}, "booking_id": {"type": "string", "description": "The ID of the booking", "default": "None"}, "insurance_id": {"type": "string", "description": "The ID of the insurance", "default": "None"}}, "required": ["access_token"]}, "response": {"type": "dict", "properties": {"invoice": {"type": "dict", "description": "The invoice for the booking", "properties": {"booking_id": {"type": "string", "description": "The ID of the booking"}, "travel_date": {"type": "string", "description": "The date of the travel"}, "travel_from": {"type": "string", "description": "The location the travel is from"}, "travel_to": {"type": "string", "description": "The location the travel is to"}, "travel_class": {"type": "string", "description": "The class of the travel"}, "travel_cost": {"type": "float", "description": "The cost of the travel"}, "transaction_id": {"type": "string", "description": "The ID of the transaction"}}}}}}
|
15 |
+
{"name": "set_budget_limit", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Set the budget limit for the user", "parameters": {"type": "dict", "properties": {"access_token": {"type": "string", "description": "The access token obtained from the authentication process or initial configuration."}, "budget_limit": {"type": "float", "description": "The budget limit to set in USD"}}, "required": ["access_token", "budget_limit"]}, "response": {"type": "dict", "properties": {"budget_limit": {"type": "float", "description": "The budget limit set in USD"}}}}
|
16 |
+
{"name": "travel_get_login_status", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Get the status of the login", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"status": {"type": "boolean", "description": "The status of the login"}}}}
|
17 |
+
{"name": "verify_traveler_information", "description": "This tool belongs to the travel system, which allows users to book flights, manage credit cards, and view budget information. Tool description: Verify the traveler information", "parameters": {"type": "dict", "properties": {"first_name": {"type": "string", "description": "The first name of the traveler"}, "last_name": {"type": "string", "description": "The last name of the traveler"}, "date_of_birth": {"type": "string", "description": "The date of birth of the traveler in the format YYYY-MM-DD"}, "passport_number": {"type": "string", "description": "The passport number of the traveler"}}, "required": ["first_name", "last_name", "date_of_birth", "passport_number"]}, "response": {"type": "dict", "properties": {"verification_status": {"type": "boolean", "description": "The status of the verification, True if successful, False if failed"}, "verification_failure": {"type": "string", "description": "The reason for the verification failure"}}}}
|
config/vehicle_control.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"name": "activateParkingBrake", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Activates the parking brake of the vehicle.", "parameters": {"type": "dict", "properties": {"mode": {"type": "string", "description": "The mode to set. [Enum]: [\"engage\", \"release\"]"}}, "required": ["mode"]}, "response": {"type": "dict", "properties": {"parkingBrakeStatus": {"type": "string", "description": "The status of the brake. [Enum]: [\"engaged\", \"released\"]"}, "_parkingBrakeForce": {"type": "float", "description": "The force applied to the brake in Newtons."}, "_slopeAngle": {"type": "float", "description": "The slope angle in degrees."}}}}
|
2 |
+
{"name": "adjustClimateControl", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Adjusts the climate control of the vehicle.", "parameters": {"type": "dict", "properties": {"temperature": {"type": "float", "description": "The temperature to set in degree. Default to be celsius."}, "unit": {"type": "string", "description": "The unit of temperature. [Enum]: [\"celsius\", \"fahrenheit\"]", "default": "celsius"}, "fanSpeed": {"type": "integer", "description": "The fan speed to set from 0 to 100. Default is 50.", "default": 50}, "mode": {"type": "string", "description": "The climate mode to set. [Enum]: [\"auto\", \"cool\", \"heat\", \"defrost\"]", "default": "auto"}}, "required": ["temperature"]}, "response": {"type": "dict", "properties": {"currentTemperature": {"type": "float", "description": "The current temperature set in degree Celsius."}, "climateMode": {"type": "string", "description": "The current climate mode set."}, "humidityLevel": {"type": "float", "description": "The humidity level in percentage."}}}}
|
3 |
+
{"name": "check_tire_pressure", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Checks the tire pressure of the vehicle.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"tirePressure": {"type": "dict", "description": "The tire pressure of the vehicle.", "properties": {"frontLeftTirePressure": {"type": "float", "description": "The pressure of the front left tire in psi."}, "frontRightTirePressure": {"type": "float", "description": "The pressure of the front right tire in psi."}, "rearLeftTirePressure": {"type": "float", "description": "The pressure of the rear left tire in psi."}, "rearRightTirePressure": {"type": "float", "description": "The pressure of the rear right tire in psi."}, "healthy_tire_pressure": {"type": "boolean", "description": "True if the tire pressure is healthy, False otherwise."}, "car_info": {"type": "dict", "description": "The metadata of the car."}}}}}}
|
4 |
+
{"name": "displayCarStatus", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Displays the status of the vehicle based on the provided display option.", "parameters": {"type": "dict", "properties": {"option": {"type": "string", "description": "The option to display. [Enum]: [\"fuel\", \"battery\", \"doors\", \"climate\", \"headlights\", \"parkingBrake\", \"brakePadle\", \"engine\"]"}}, "required": ["option"]}, "response": {"type": "dict", "properties": {"status": {"type": "dict", "description": "The status of the vehicle based on the option.", "properties": {"fuelLevel": {"type": "float", "description": "[Optional] The fuel level of the vehicle in gallons."}, "batteryVoltage": {"type": "float", "description": "[Optional] The battery voltage of the vehicle in volts."}, "doorStatus": {"type": "dict", "description": "[Optional] The status of the doors.", "properties": {"driver": {"type": "string", "description": "The status of the driver door. [Enum]: [\"locked\", \"unlocked\"]"}, "passenger": {"type": "string", "description": "The status of the passenger door. [Enum]: [\"locked\", \"unlocked\"]"}, "rear_left": {"type": "string", "description": "The status of the rear left door. [Enum]: [\"locked\", \"unlocked\"]"}, "rear_right": {"type": "string", "description": "The status of the rear right door. [Enum]: [\"locked\", \"unlocked\"]"}}}, "currentACTemperature": {"type": "float", "description": "[Optional] The current temperature set in degree Celsius."}, "fanSpeed": {"type": "integer", "description": "[Optional] The fan speed set from 0 to 100."}, "climateMode": {"type": "string", "description": "[Optional] The climate mode set. [Enum]: [\"auto\", \"cool\", \"heat\", \"defrost\"]"}, "humidityLevel": {"type": "float", "description": "[Optional] The humidity level in percentage."}, "headlightStatus": {"type": "string", "description": "[Optional] The status of the headlights. [Enum]: [\"on\", \"off\"]"}, "parkingBrakeStatus": {"type": "string", "description": "[Optional] The status of the brake. [Enum]: [\"engaged\", \"released\"]"}, "parkingBrakeForce": {"type": "float", "description": "[Optional] The force applied to the brake in Newtons."}, "slopeAngle": {"type": "float", "description": "[Optional] The slope angle in degrees."}, "brakePedalStatus": {"type": "string", "description": "[Optional] The status of the brake pedal. [Enum]: [\"pressed\", \"released\"]"}, "brakePedalForce": {"type": "float", "description": "[Optional] The force applied to the brake pedal in Newtons."}, "engineState": {"type": "string", "description": "[Optional] The state of the engine. [Enum]: [\"running\", \"stopped\"]"}, "metadata": {"type": "string", "description": "[Optional] The metadata of the car."}}}}}}
|
5 |
+
{"name": "display_log", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Displays the log messages.", "parameters": {"type": "dict", "properties": {"messages": {"type": "array", "items": {"type": "string"}, "description": "The list of messages to display."}}, "required": ["messages"]}, "response": {"type": "dict", "properties": {"log": {"type": "array", "description": "The list of messages displayed.", "items": {"type": "string"}}}}}
|
6 |
+
{"name": "estimate_distance", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Estimates the distance between two cities.", "parameters": {"type": "dict", "properties": {"cityA": {"type": "string", "description": "The zipcode of the first city."}, "cityB": {"type": "string", "description": "The zipcode of the second city."}}, "required": ["cityA", "cityB"]}, "response": {"type": "dict", "properties": {"distance": {"type": "float", "description": "The distance between the two cities in km."}, "intermediaryCities": {"type": "array", "description": "[Optional] The list of intermediary cities between the two cities.", "items": {"type": "string"}}}}}
|
7 |
+
{"name": "estimate_drive_feasibility_by_mileage", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Estimates the milage of the vehicle given the distance needed to drive.", "parameters": {"type": "dict", "properties": {"distance": {"type": "float", "description": "The distance to travel in miles."}}, "required": ["distance"]}, "response": {"type": "dict", "properties": {"canDrive": {"type": "boolean", "description": "True if the vehicle can drive the distance, False otherwise."}}}}
|
8 |
+
{"name": "fillFuelTank", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Fills the fuel tank of the vehicle. The fuel tank can hold up to 50 gallons.", "parameters": {"type": "dict", "properties": {"fuelAmount": {"type": "float", "description": "The amount of fuel to fill in gallons; this is the additional fuel to add to the tank."}}, "required": ["fuelAmount"]}, "response": {"type": "dict", "properties": {"fuelLevel": {"type": "float", "description": "The fuel level of the vehicle in gallons."}}}}
|
9 |
+
{"name": "find_nearest_tire_shop", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Finds the nearest tire shop.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"shopLocation": {"type": "string", "description": "The location of the nearest tire shop."}}}}
|
10 |
+
{"name": "gallon_to_liter", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Converts the gallon to liter.", "parameters": {"type": "dict", "properties": {"gallon": {"type": "float", "description": "The amount of gallon to convert."}}, "required": ["gallon"]}, "response": {"type": "dict", "properties": {"liter": {"type": "float", "description": "The amount of liter converted."}}}}
|
11 |
+
{"name": "get_current_speed", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Gets the current speed of the vehicle.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"currentSpeed": {"type": "float", "description": "The current speed of the vehicle in km/h."}}}}
|
12 |
+
{"name": "get_outside_temperature_from_google", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Gets the outside temperature.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"outsideTemperature": {"type": "float", "description": "The outside temperature in degree Celsius."}}}}
|
13 |
+
{"name": "get_outside_temperature_from_weather_com", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Gets the outside temperature.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"outsideTemperature": {"type": "float", "description": "The outside temperature in degree Celsius."}}}}
|
14 |
+
{"name": "get_zipcode_based_on_city", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Gets the zipcode based on the city.", "parameters": {"type": "dict", "properties": {"city": {"type": "string", "description": "The name of the city."}}, "required": ["city"]}, "response": {"type": "dict", "properties": {"zipcode": {"type": "string", "description": "The zipcode of the city."}}}}
|
15 |
+
{"name": "liter_to_gallon", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Converts the liter to gallon.", "parameters": {"type": "dict", "properties": {"liter": {"type": "float", "description": "The amount of liter to convert."}}, "required": ["liter"]}, "response": {"type": "dict", "properties": {"gallon": {"type": "float", "description": "The amount of gallon converted."}}}}
|
16 |
+
{"name": "lockDoors", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Locks the doors of the vehicle.", "parameters": {"type": "dict", "properties": {"unlock": {"type": "boolean", "description": "True if the doors are to be unlocked, False otherwise."}, "door": {"type": "array", "items": {"type": "string"}, "description": "The list of doors to lock or unlock. [Enum]: [\"driver\", \"passenger\", \"rear_left\", \"rear_right\"]"}}, "required": ["unlock", "door"]}, "response": {"type": "dict", "properties": {"lockStatus": {"type": "string", "description": "The status of the lock. [Enum]: [\"locked\", \"unlocked\"]"}, "remainingUnlockedDoors": {"type": "integer", "description": "The number of remaining unlocked doors."}}}}
|
17 |
+
{"name": "pressBrakePedal", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Presses the brake pedal based on pedal position. The brake pedal will be kept pressed until released.", "parameters": {"type": "dict", "properties": {"pedalPosition": {"type": "float", "description": "Position of the brake pedal, between 0 (not pressed) and 1 (fully pressed)."}}, "required": ["pedalPosition"]}, "response": {"type": "dict", "properties": {"brakePedalStatus": {"type": "string", "description": "The status of the brake pedal. [Enum]: [\"pressed\", \"released\"]"}, "brakePedalForce": {"type": "float", "description": "The force applied to the brake pedal in Newtons."}}}}
|
18 |
+
{"name": "releaseBrakePedal", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Releases the brake pedal of the vehicle.", "parameters": {"type": "dict", "properties": {}, "required": []}, "response": {"type": "dict", "properties": {"brakePedalStatus": {"type": "string", "description": "The status of the brake pedal. [Enum]: [\"pressed\", \"released\"]"}, "brakePedalForce": {"type": "float", "description": "The force applied to the brake pedal in Newtons."}}}}
|
19 |
+
{"name": "setCruiseControl", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Sets the cruise control of the vehicle.", "parameters": {"type": "dict", "properties": {"speed": {"type": "float", "description": "The speed to set in m/h. The speed should be between 0 and 120 and a multiple of 5."}, "activate": {"type": "boolean", "description": "True to activate the cruise control, False to deactivate."}, "distanceToNextVehicle": {"type": "float", "description": "The distance to the next vehicle in meters."}}, "required": ["speed", "activate", "distanceToNextVehicle"]}, "response": {"type": "dict", "properties": {"cruiseStatus": {"type": "string", "description": "The status of the cruise control. [Enum]: [\"active\", \"inactive\"]"}, "currentSpeed": {"type": "float", "description": "The current speed of the vehicle in km/h."}, "distanceToNextVehicle": {"type": "float", "description": "The distance to the next vehicle in meters."}}}}
|
20 |
+
{"name": "setHeadlights", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Sets the headlights of the vehicle.", "parameters": {"type": "dict", "properties": {"mode": {"type": "string", "description": "The mode of the headlights. [Enum]: [\"on\", \"off\", \"auto\"]"}}, "required": ["mode"]}, "response": {"type": "dict", "properties": {"headlightStatus": {"type": "string", "description": "The status of the headlights. [Enum]: [\"on\", \"off\"]"}}}}
|
21 |
+
{"name": "set_navigation", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Navigates to the destination.", "parameters": {"type": "dict", "properties": {"destination": {"type": "string", "description": "The destination to navigate in the format of street, city, state."}}, "required": ["destination"]}, "response": {"type": "dict", "properties": {"status": {"type": "string", "description": "The status of the navigation."}}}}
|
22 |
+
{"name": "startEngine", "description": "This tool belongs to the vehicle control system, which allows users to control various aspects of the car such as engine, doors, climate control, lights, and more. Tool description: Starts the engine of the vehicle.", "parameters": {"type": "dict", "properties": {"ignitionMode": {"type": "string", "description": "The ignition mode of the vehicle. [Enum]: [\"START\", \"STOP\"]"}}, "required": ["ignitionMode"]}, "response": {"type": "dict", "properties": {"engineState": {"type": "string", "description": "The state of the engine. [Enum]: [\"running\", \"stopped\"]"}, "fuelLevel": {"type": "float", "description": "The fuel level of the vehicle in gallons."}, "batteryVoltage": {"type": "float", "description": "The battery voltage of the vehicle in volts."}}}}
|
constant.py
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MAXIMUM_STEP_LIMIT = 20
|
2 |
+
|
3 |
+
DEFAULT_SYSTEM_PROMPT_WITHOUT_FUNC_DOC = """You are an expert in composing functions. You are given a question and a set of possible functions. Based on the question, you will need to make one or more function/tool calls to achieve the purpose.
|
4 |
+
If none of the function can be used, point it out. If the given question lacks the parameters required by the function, also point it out.
|
5 |
+
You should only return the function calls in your response.
|
6 |
+
|
7 |
+
If you decide to invoke any of the function(s), you MUST put it in the format of [func_name1(params_name1=params_value1, params_name2=params_value2...), func_name2(params)]
|
8 |
+
You SHOULD NOT include any other text in the response.
|
9 |
+
|
10 |
+
At each turn, your should try your best to complete the tasks requested by the user within the current turn. Continue to output functions to call until you have fulfilled the user's request to the best of your ability. Once you have no more functions to call, the system will consider the current turn complete and proceed to the next turn or task.
|
11 |
+
"""
|
12 |
+
|
13 |
+
DEFAULT_SYSTEM_PROMPT = (
|
14 |
+
DEFAULT_SYSTEM_PROMPT_WITHOUT_FUNC_DOC
|
15 |
+
+ """
|
16 |
+
Here is a list of functions in JSON format that you can invoke.\n{functions}\n
|
17 |
+
"""
|
18 |
+
)
|
19 |
+
|
20 |
+
DEFAULT_USER_PROMPT_FOR_ADDITIONAL_FUNCTION_FC = "I have updated some more functions you can choose from. What about now?"
|
21 |
+
|
22 |
+
DEFAULT_USER_PROMPT_FOR_ADDITIONAL_FUNCTION_PROMPTING = "{functions}\n" + DEFAULT_USER_PROMPT_FOR_ADDITIONAL_FUNCTION_FC
|
23 |
+
|
24 |
+
GORILLA_TO_OPENAPI = {
|
25 |
+
"integer": "integer",
|
26 |
+
"number": "number",
|
27 |
+
"float": "number",
|
28 |
+
"string": "string",
|
29 |
+
"boolean": "boolean",
|
30 |
+
"bool": "boolean",
|
31 |
+
"array": "array",
|
32 |
+
"list": "array",
|
33 |
+
"dict": "object",
|
34 |
+
"object": "object",
|
35 |
+
"tuple": "array",
|
36 |
+
"any": "string",
|
37 |
+
"byte": "integer",
|
38 |
+
"short": "integer",
|
39 |
+
"long": "integer",
|
40 |
+
"double": "number",
|
41 |
+
"char": "string",
|
42 |
+
"ArrayList": "array",
|
43 |
+
"Array": "array",
|
44 |
+
"HashMap": "object",
|
45 |
+
"Hashtable": "object",
|
46 |
+
"Queue": "array",
|
47 |
+
"Stack": "array",
|
48 |
+
"Any": "string",
|
49 |
+
"String": "string",
|
50 |
+
"Bigint": "integer",
|
51 |
+
}
|
52 |
+
|
53 |
+
GORILLA_TO_PYTHON = {
|
54 |
+
"integer": "int",
|
55 |
+
"number": "float",
|
56 |
+
"float": "float",
|
57 |
+
"string": "str",
|
58 |
+
"boolean": "bool",
|
59 |
+
"bool": "bool",
|
60 |
+
"array": "list",
|
61 |
+
"list": "list",
|
62 |
+
"dict": "dict",
|
63 |
+
"object": "dict",
|
64 |
+
"tuple": "tuple",
|
65 |
+
"any": "str",
|
66 |
+
"byte": "int",
|
67 |
+
"short": "int",
|
68 |
+
"long": "int",
|
69 |
+
"double": "float",
|
70 |
+
"char": "str",
|
71 |
+
"ArrayList": "list",
|
72 |
+
"Array": "list",
|
73 |
+
"HashMap": "dict",
|
74 |
+
"Hashtable": "dict",
|
75 |
+
"Queue": "list",
|
76 |
+
"Stack": "list",
|
77 |
+
"Any": "str",
|
78 |
+
"String": "str",
|
79 |
+
"Bigint": "int",
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
JAVA_TYPE_CONVERSION = {
|
84 |
+
"byte": int,
|
85 |
+
"short": int,
|
86 |
+
"integer": int,
|
87 |
+
"float": float,
|
88 |
+
"double": float,
|
89 |
+
"long": int,
|
90 |
+
"boolean": bool,
|
91 |
+
"char": str,
|
92 |
+
"Array": list,
|
93 |
+
"ArrayList": list,
|
94 |
+
"Set": set,
|
95 |
+
"HashMap": dict,
|
96 |
+
"Hashtable": dict,
|
97 |
+
"Queue": list, # this can be `queue.Queue` as well, for simplicity we check with list
|
98 |
+
"Stack": list,
|
99 |
+
"String": str,
|
100 |
+
"any": str,
|
101 |
+
}
|
102 |
+
|
103 |
+
JS_TYPE_CONVERSION = {
|
104 |
+
"String": str,
|
105 |
+
"integer": int,
|
106 |
+
"float": float,
|
107 |
+
"Bigint": int,
|
108 |
+
"Boolean": bool,
|
109 |
+
"dict": dict,
|
110 |
+
"array": list,
|
111 |
+
"any": str,
|
112 |
+
}
|
113 |
+
|
114 |
+
UNDERSCORE_TO_DOT = [
|
115 |
+
"gpt-4o-2024-08-06-FC",
|
116 |
+
"gpt-4o-2024-05-13-FC",
|
117 |
+
"gpt-4o-mini-2024-07-18-FC",
|
118 |
+
"gpt-4-turbo-2024-04-09-FC",
|
119 |
+
"gpt-4-1106-preview-FC",
|
120 |
+
"gpt-4-0125-preview-FC",
|
121 |
+
"gpt-4-0613-FC",
|
122 |
+
"gpt-3.5-turbo-0125-FC",
|
123 |
+
"claude-3-opus-20240229-FC",
|
124 |
+
"claude-3-sonnet-20240229-FC",
|
125 |
+
"claude-3-5-sonnet-20240620-FC",
|
126 |
+
"claude-3-5-sonnet-20241022-FC",
|
127 |
+
"claude-3-haiku-20240307-FC",
|
128 |
+
"claude-3-5-haiku-20241022-FC",
|
129 |
+
"open-mistral-nemo-2407-FC",
|
130 |
+
"open-mixtral-8x22b-FC",
|
131 |
+
"mistral-large-2407-FC",
|
132 |
+
"mistral-large-2407-FC",
|
133 |
+
"mistral-small-2402-FC",
|
134 |
+
"mistral-small-2402-FC",
|
135 |
+
"gemini-1.5-pro-002-FC",
|
136 |
+
"gemini-1.5-pro-001-FC",
|
137 |
+
"gemini-1.5-flash-002-FC",
|
138 |
+
"gemini-1.5-flash-001-FC",
|
139 |
+
"gemini-1.0-pro-002-FC",
|
140 |
+
"meetkai/functionary-small-v3.1-FC",
|
141 |
+
"meetkai/functionary-small-v3.2-FC",
|
142 |
+
"meetkai/functionary-medium-v3.1-FC",
|
143 |
+
"NousResearch/Hermes-2-Pro-Llama-3-8B",
|
144 |
+
"NousResearch/Hermes-2-Pro-Llama-3-70B",
|
145 |
+
"NousResearch/Hermes-2-Pro-Mistral-7B",
|
146 |
+
"NousResearch/Hermes-2-Theta-Llama-3-8B",
|
147 |
+
"NousResearch/Hermes-2-Theta-Llama-3-70B",
|
148 |
+
"command-r-plus-FC",
|
149 |
+
"command-r-plus-FC-optimized",
|
150 |
+
"THUDM/glm-4-9b-chat",
|
151 |
+
"ibm-granite/granite-20b-functioncalling",
|
152 |
+
"yi-large-fc",
|
153 |
+
"openbmb/MiniCPM3-4B-FC",
|
154 |
+
]
|
db.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pymongo import MongoClient
|
2 |
+
from pymongo.server_api import ServerApi
|
3 |
+
import os
|
4 |
+
|
5 |
+
uri = os.getenv('DATABASE_URL').strip()
|
6 |
+
cluster = MongoClient(uri, server_api=ServerApi('1'))
|
7 |
+
try:
|
8 |
+
cluster.admin.command('ping')
|
9 |
+
print("Pinged your deployment. You successfully connected to MongoDB!")
|
10 |
+
except Exception as e:
|
11 |
+
print(e)
|
12 |
+
db = cluster["test"]
|
13 |
+
collection = db["test"]
|
eval_runner_helper.py
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import re
|
4 |
+
import statistics
|
5 |
+
from pathlib import Path
|
6 |
+
from typing import Union
|
7 |
+
|
8 |
+
import numpy as np
|
9 |
+
from constant import *
|
10 |
+
|
11 |
+
from tqdm import tqdm
|
12 |
+
|
13 |
+
|
14 |
+
def is_multi_turn(test_category):
|
15 |
+
return "multi_turn" in test_category
|
16 |
+
|
17 |
+
def contain_multi_turn_irrelevance(test_category):
|
18 |
+
return "miss_func" in test_category or "miss_param" in test_category
|
19 |
+
|
20 |
+
def is_executable(test_category):
|
21 |
+
return "exec" in test_category or "rest" in test_category
|
22 |
+
|
23 |
+
|
24 |
+
def is_rest(test_category):
|
25 |
+
return "rest" in test_category
|
26 |
+
|
27 |
+
|
28 |
+
def is_relevance_or_irrelevance(test_category):
|
29 |
+
return "relevance" in test_category or "irrelevance" in test_category
|
30 |
+
|
31 |
+
|
32 |
+
def is_chatable(test_category):
|
33 |
+
return "chatable" in test_category
|
34 |
+
|
35 |
+
|
36 |
+
def is_java(test_category):
|
37 |
+
return "java" in test_category
|
38 |
+
|
39 |
+
|
40 |
+
def is_js(test_category):
|
41 |
+
return "javascript" in test_category
|
42 |
+
|
43 |
+
|
44 |
+
def is_sql(test_category):
|
45 |
+
return "sql" in test_category
|
46 |
+
|
47 |
+
|
48 |
+
def load_file(file_path):
|
49 |
+
result = []
|
50 |
+
with open(file_path) as f:
|
51 |
+
file = f.readlines()
|
52 |
+
for line in file:
|
53 |
+
result.append(json.loads(line))
|
54 |
+
return result
|
55 |
+
|
56 |
+
|
57 |
+
def get_handler(model_name):
|
58 |
+
return handler_map[model_name](model_name, temperature=0) #Temperature doesn't matter for evaluation
|
59 |
+
|
60 |
+
|
61 |
+
def write_list_of_dicts_to_file(filename, data, subdir=None):
|
62 |
+
if subdir:
|
63 |
+
# Ensure the subdirectory exists
|
64 |
+
os.makedirs(subdir, exist_ok=True)
|
65 |
+
|
66 |
+
# Construct the full path to the file
|
67 |
+
filename = os.path.join(subdir, filename)
|
68 |
+
|
69 |
+
# Write the list of dictionaries to the file in JSON format
|
70 |
+
with open(filename, "w") as f:
|
71 |
+
for i, entry in enumerate(data):
|
72 |
+
# Go through each key-value pair in the dictionary to make sure the values are JSON serializable
|
73 |
+
for key, value in entry.items():
|
74 |
+
try:
|
75 |
+
json.dumps(value)
|
76 |
+
except:
|
77 |
+
# If the value is not JSON serializable, wrap it in a string
|
78 |
+
entry[key] = str(value)
|
79 |
+
|
80 |
+
json_str = json.dumps(entry)
|
81 |
+
f.write(json_str)
|
82 |
+
if i < len(data) - 1:
|
83 |
+
f.write("\n")
|
84 |
+
|
85 |
+
|
86 |
+
def is_function_calling_format_output(decoded_output):
|
87 |
+
# Ensure the output is a list of dictionaries
|
88 |
+
if type(decoded_output) == list:
|
89 |
+
for item in decoded_output:
|
90 |
+
if type(item) != dict:
|
91 |
+
return False
|
92 |
+
return True
|
93 |
+
return False
|
94 |
+
|
95 |
+
|
96 |
+
def is_executable_format_output(decoded_output):
|
97 |
+
# Ensure the output is a list of strings (one or more strings)
|
98 |
+
if type(decoded_output) == list:
|
99 |
+
if len(decoded_output) == 0:
|
100 |
+
return False
|
101 |
+
for item in decoded_output:
|
102 |
+
if type(item) != str:
|
103 |
+
return False
|
104 |
+
return True
|
105 |
+
return False
|
106 |
+
|
107 |
+
|
108 |
+
def is_rest_format_output(decoded_output):
|
109 |
+
# Ensure the output is a list of one string
|
110 |
+
if type(decoded_output) == list:
|
111 |
+
if len(decoded_output) == 1 and type(decoded_output[0]) == str:
|
112 |
+
return True
|
113 |
+
return False
|
114 |
+
|
115 |
+
|
116 |
+
def is_empty_output(decoded_output):
|
117 |
+
# This function is a patch to the ast decoder for relevance detection
|
118 |
+
# Sometimes the ast decoder will parse successfully, but the input doens't really have a function call
|
119 |
+
# [], [{}], and anything that is not in function calling format is considered empty (and thus should be marked as correct)
|
120 |
+
if not is_function_calling_format_output(decoded_output):
|
121 |
+
return True
|
122 |
+
if len(decoded_output) == 0:
|
123 |
+
return True
|
124 |
+
if len(decoded_output) == 1 and len(decoded_output[0]) == 0:
|
125 |
+
return True
|
126 |
+
return False
|
127 |
+
|
flagged/log.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
name,intensity,output,flag,username,timestamp
|
2 |
+
This is Sharon,0,"Hello, This is Sharon",,,2024-10-04 15:56:52.011215
|
info_table.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import json
|
3 |
+
|
4 |
+
def open_json(filename):
|
5 |
+
with open(filename, 'r') as file:
|
6 |
+
data = []
|
7 |
+
for line in file:
|
8 |
+
try:
|
9 |
+
data.append(json.loads(line))
|
10 |
+
except json.JSONDecodeError as e:
|
11 |
+
print(f"Error parsing line: {line}")
|
12 |
+
print(f"Error message: {e}")
|
13 |
+
return data
|
14 |
+
|
15 |
+
def format_questions(question):
|
16 |
+
questions = """<div style="text-align: left; width: 500px;">\n"""
|
17 |
+
for i, q in enumerate(question):
|
18 |
+
questions += f"<p style='margin: 10px 0;'><b>Turn {i + 1} Question:</b> <br>\n {q[0]['content']}<br>\n"
|
19 |
+
return questions
|
20 |
+
|
21 |
+
def format_solutions(solution):
|
22 |
+
solutions = """<div style="text-align: left;">"""
|
23 |
+
for i, s in enumerate(solution):
|
24 |
+
solutions += f"<b>Turn {i+1} Response</b> \n\n ```python\n"
|
25 |
+
for c in s:
|
26 |
+
solutions += c + "\n"
|
27 |
+
solutions += "\n```\n\n"
|
28 |
+
return solutions
|
29 |
+
|
30 |
+
def process(df, questions, solutions):
|
31 |
+
df['involved_classes'] = [questions[int(df['id'][i].split("_")[-1])]['involved_classes'] for i in df.index]
|
32 |
+
df['question'] = [questions[int(df['id'][i].split("_")[-1])]['question'] for i in df.index]
|
33 |
+
df['ground_truth'] = [solutions[int(df['id'][i].split("_")[-1])]['ground_truth'] for i in df.index]
|
34 |
+
df['question'] = df['question'].apply(format_questions)
|
35 |
+
df['ground_truth'] = df['ground_truth'].apply(format_solutions)
|
36 |
+
return df
|
37 |
+
|
38 |
+
api_info = pd.read_csv("api_info.csv")
|
39 |
+
questions = open_json('BFCL_v3_multi_turn_base.json')
|
40 |
+
solutions = open_json('BFCL_v3_multi_turn_base_sol.json')
|
41 |
+
api_samples = pd.read_csv('samples_qa.csv')
|
42 |
+
api_samples = process(api_samples, questions, solutions)
|
model_style.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from enum import Enum
|
2 |
+
|
3 |
+
|
4 |
+
class ModelStyle(Enum):
|
5 |
+
Gorilla = "gorilla"
|
6 |
+
OpenAI = "gpt"
|
7 |
+
Anthropic = "claude"
|
8 |
+
Mistral = "mistral"
|
9 |
+
Google = "google"
|
10 |
+
FIREWORK_AI = "firework_ai"
|
11 |
+
NEXUS = "nexus"
|
12 |
+
OSSMODEL = "ossmodel"
|
13 |
+
COHERE = "cohere"
|
14 |
+
WRITER = "writer"
|
multi_turn_eval/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/__init__.cpython-311.pyc
ADDED
Binary file (236 Bytes). View file
|
|
multi_turn_eval/func_source_code/__pycache__/__init__.cpython-312.pyc
ADDED
Binary file (224 Bytes). View file
|
|
multi_turn_eval/func_source_code/__pycache__/gorilla_file_system.cpython-311.pyc
ADDED
Binary file (40.7 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/gorilla_file_system.cpython-312.pyc
ADDED
Binary file (39.4 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/long_context.cpython-311.pyc
ADDED
Binary file (196 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/long_context.cpython-312.pyc
ADDED
Binary file (186 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/math_api.cpython-311.pyc
ADDED
Binary file (15.6 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/math_api.cpython-312.pyc
ADDED
Binary file (14.3 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/message_api.cpython-311.pyc
ADDED
Binary file (15.2 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/message_api.cpython-312.pyc
ADDED
Binary file (15 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/posting_api.cpython-311.pyc
ADDED
Binary file (16.2 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/posting_api.cpython-312.pyc
ADDED
Binary file (13.2 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/ticket_api.cpython-311.pyc
ADDED
Binary file (12.1 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/ticket_api.cpython-312.pyc
ADDED
Binary file (10.2 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/trading_bot.cpython-311.pyc
ADDED
Binary file (29.4 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/trading_bot.cpython-312.pyc
ADDED
Binary file (23.8 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/travel_booking.cpython-311.pyc
ADDED
Binary file (35.3 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/travel_booking.cpython-312.pyc
ADDED
Binary file (31.8 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/vehicle_control.cpython-311.pyc
ADDED
Binary file (30.2 kB). View file
|
|
multi_turn_eval/func_source_code/__pycache__/vehicle_control.cpython-312.pyc
ADDED
Binary file (22.1 kB). View file
|
|
multi_turn_eval/func_source_code/gorilla_file_system.py
ADDED
@@ -0,0 +1,811 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datetime
|
2 |
+
import subprocess
|
3 |
+
from copy import deepcopy
|
4 |
+
from typing import Dict, List, Optional, Union
|
5 |
+
|
6 |
+
from .long_context import FILE_CONTENT_EXTENSION, FILES_TAIL_USED, POPULATE_FILE_EXTENSION
|
7 |
+
|
8 |
+
|
9 |
+
class File:
|
10 |
+
|
11 |
+
def __init__(self, name: str, content: str = "") -> None:
|
12 |
+
"""
|
13 |
+
Initialize a file with a name and optional content.
|
14 |
+
|
15 |
+
Args:
|
16 |
+
name (str): The name of the file.
|
17 |
+
content (str, optional): The initial content of the file. Defaults to an empty string.
|
18 |
+
"""
|
19 |
+
self.name: str = name
|
20 |
+
self.content: str = content
|
21 |
+
self._last_modified: datetime.datetime = datetime.datetime.now()
|
22 |
+
|
23 |
+
def _write(self, new_content: str) -> None:
|
24 |
+
"""
|
25 |
+
Write new content to the file and update the last modified time.
|
26 |
+
|
27 |
+
Args:
|
28 |
+
new_content (str): The new content to write to the file.
|
29 |
+
"""
|
30 |
+
self.content = new_content
|
31 |
+
self._last_modified = datetime.datetime.now()
|
32 |
+
|
33 |
+
def _read(self) -> str:
|
34 |
+
"""
|
35 |
+
Read the content of the file.
|
36 |
+
|
37 |
+
Returns:
|
38 |
+
content (str): The current content of the file.
|
39 |
+
"""
|
40 |
+
return self.content
|
41 |
+
|
42 |
+
def _append(self, additional_content: str) -> None:
|
43 |
+
"""
|
44 |
+
Append content to the existing file content.
|
45 |
+
|
46 |
+
Args:
|
47 |
+
additional_content (str): The content to append to the file.
|
48 |
+
"""
|
49 |
+
self.content += additional_content
|
50 |
+
self._last_modified = datetime.datetime.now()
|
51 |
+
|
52 |
+
def __repr__(self):
|
53 |
+
return f"<<File: {self.name}, Content: {self.content}>>"
|
54 |
+
|
55 |
+
def __eq__(self, other: object) -> bool:
|
56 |
+
if not isinstance(other, File):
|
57 |
+
return False
|
58 |
+
return self.name == other.name and self.content == other.content
|
59 |
+
|
60 |
+
|
61 |
+
class Directory:
|
62 |
+
|
63 |
+
def __init__(self, name: str, parent: Optional["Directory"] = None) -> None:
|
64 |
+
"""
|
65 |
+
Initialize a directory with a name.
|
66 |
+
|
67 |
+
Args:
|
68 |
+
name (str): The name of the directory.
|
69 |
+
"""
|
70 |
+
self.name: str = name
|
71 |
+
self.parent: Optional["Directory"] = parent
|
72 |
+
self.contents: Dict[str, Union["File", "Directory"]] = {}
|
73 |
+
|
74 |
+
def _add_file(self, file_name: str, content: str = "") -> None:
|
75 |
+
"""
|
76 |
+
Add a new file to the directory.
|
77 |
+
|
78 |
+
Args:
|
79 |
+
file_name (str): The name of the file.
|
80 |
+
content (str, optional): The content of the new file. Defaults to an empty string.
|
81 |
+
"""
|
82 |
+
if file_name in self.contents:
|
83 |
+
raise ValueError(
|
84 |
+
f"File '{file_name}' already exists in directory '{self.name}'."
|
85 |
+
)
|
86 |
+
new_file = File(file_name, content)
|
87 |
+
self.contents[file_name] = new_file
|
88 |
+
|
89 |
+
def _add_directory(self, dir_name: str) -> None:
|
90 |
+
"""
|
91 |
+
Add a new subdirectory to the directory.
|
92 |
+
|
93 |
+
Args:
|
94 |
+
dir_name (str): The name of the subdirectory.
|
95 |
+
"""
|
96 |
+
if dir_name in self.contents:
|
97 |
+
raise ValueError(
|
98 |
+
f"Directory '{dir_name}' already exists in directory '{self.name}'."
|
99 |
+
)
|
100 |
+
new_dir = Directory(dir_name, self)
|
101 |
+
self.contents[dir_name] = new_dir
|
102 |
+
|
103 |
+
def _get_item(self, item_name: str) -> Union["File", "Directory", None]:
|
104 |
+
"""
|
105 |
+
Get an item (file or subdirectory) from the directory.
|
106 |
+
|
107 |
+
Args:
|
108 |
+
item_name (str): The name of the item to retrieve.
|
109 |
+
|
110 |
+
Returns:
|
111 |
+
item (any): The retrieved item or None if it does not exist.
|
112 |
+
"""
|
113 |
+
return self.contents.get(item_name)
|
114 |
+
|
115 |
+
def _list_contents(self) -> List[str]:
|
116 |
+
"""
|
117 |
+
List the names of all contents in the directory.
|
118 |
+
|
119 |
+
Returns:
|
120 |
+
contents (List[str]): A list of names of the files and subdirectories in the directory.
|
121 |
+
"""
|
122 |
+
return list(self.contents.keys())
|
123 |
+
|
124 |
+
def __repr__(self):
|
125 |
+
return f"<Directory: {self.name}, Parent: {self.parent.name if self.parent else None}, Contents: {self.contents}>"
|
126 |
+
|
127 |
+
def __eq__(self, other: object) -> bool:
|
128 |
+
if not isinstance(other, Directory):
|
129 |
+
return False
|
130 |
+
return self.name == other.name and self.contents == other.contents
|
131 |
+
|
132 |
+
|
133 |
+
DEFAULT_STATE = {"root": Directory("/", None)}
|
134 |
+
|
135 |
+
|
136 |
+
class GorillaFileSystem:
|
137 |
+
|
138 |
+
def __init__(self) -> None:
|
139 |
+
"""
|
140 |
+
Initialize the Gorilla file system with a root directory
|
141 |
+
"""
|
142 |
+
self.root: Directory
|
143 |
+
self._current_dir: Directory
|
144 |
+
self._api_description = "This tool belongs to the Gorilla file system. It is a simple file system that allows users to perform basic file operations such as navigating directories, creating files and directories, reading and writing to files, etc."
|
145 |
+
|
146 |
+
def __eq__(self, other: object) -> bool:
|
147 |
+
if not isinstance(other, GorillaFileSystem):
|
148 |
+
return False
|
149 |
+
return self.root == other.root
|
150 |
+
|
151 |
+
def _load_scenario(self, scenario: dict, long_context: bool = False) -> None:
|
152 |
+
"""
|
153 |
+
Load a scenario into the file system.
|
154 |
+
|
155 |
+
Args:
|
156 |
+
scenario (dict): The scenario to load.
|
157 |
+
|
158 |
+
The scenario always starts with a root directory. Each directory can contain files or subdirectories.
|
159 |
+
The key is the name of the file or directory, and the value is a dictionary with the following keys
|
160 |
+
An example scenario:
|
161 |
+
Here John is the root directory and it contains a home directory with a user directory inside it.
|
162 |
+
The user directory contains a file named file1.txt and a directory named directory1.
|
163 |
+
Root is not a part of the scenario and it's just easy for parsing. During generation, you should have at most 2 layers.
|
164 |
+
{
|
165 |
+
"root": {
|
166 |
+
"john": {
|
167 |
+
"type": "directory",
|
168 |
+
"contents": {
|
169 |
+
"home": {
|
170 |
+
"type": "directory",
|
171 |
+
"contents": {
|
172 |
+
"user": {
|
173 |
+
"type": "directory",
|
174 |
+
"contents": {
|
175 |
+
"file1.txt": {
|
176 |
+
"type": "file",
|
177 |
+
"content": "Hello, world!"
|
178 |
+
},
|
179 |
+
"directory1": {
|
180 |
+
"type": "directory",
|
181 |
+
"contents": {}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
"""
|
191 |
+
DEFAULT_STATE_COPY = deepcopy(DEFAULT_STATE)
|
192 |
+
self.long_context = long_context
|
193 |
+
self.root = DEFAULT_STATE_COPY["root"]
|
194 |
+
if "root" in scenario:
|
195 |
+
root_dir = Directory(list(scenario["root"].keys())[0], None)
|
196 |
+
self.root = self._load_directory(
|
197 |
+
scenario["root"][list(scenario["root"].keys())[0]]["contents"], root_dir
|
198 |
+
)
|
199 |
+
self._current_dir = self.root
|
200 |
+
|
201 |
+
def _load_directory(
|
202 |
+
self, current: dict, parent: Optional[Directory] = None
|
203 |
+
) -> Directory:
|
204 |
+
"""
|
205 |
+
Load a directory and its contents from a dictionary.
|
206 |
+
|
207 |
+
Args:
|
208 |
+
data (dict): The dictionary representing the directory.
|
209 |
+
parent (Directory, optional): The parent directory. Defaults to None.
|
210 |
+
|
211 |
+
Returns:
|
212 |
+
Directory: The loaded directory.
|
213 |
+
"""
|
214 |
+
is_bottommost = True
|
215 |
+
for dir_name, dir_data in current.items():
|
216 |
+
|
217 |
+
if dir_data["type"] == "directory":
|
218 |
+
is_bottommost = False
|
219 |
+
new_dir = Directory(dir_name, parent)
|
220 |
+
new_dir = self._load_directory(dir_data["contents"], new_dir)
|
221 |
+
parent.contents[dir_name] = new_dir
|
222 |
+
|
223 |
+
elif dir_data["type"] == "file":
|
224 |
+
content = dir_data["content"]
|
225 |
+
if self.long_context and dir_name not in FILES_TAIL_USED:
|
226 |
+
content += FILE_CONTENT_EXTENSION
|
227 |
+
new_file = File(dir_name, content)
|
228 |
+
parent.contents[dir_name] = new_file
|
229 |
+
|
230 |
+
if is_bottommost and self.long_context:
|
231 |
+
self._populate_directory(parent)
|
232 |
+
|
233 |
+
return parent
|
234 |
+
|
235 |
+
def _populate_directory(
|
236 |
+
self, directory: Directory
|
237 |
+
) -> None: # Used only for long context
|
238 |
+
"""
|
239 |
+
Populate an innermost directory with multiple empty files.
|
240 |
+
|
241 |
+
Args:
|
242 |
+
directory (Directory): The innermost directory to populate.
|
243 |
+
"""
|
244 |
+
for i in range(len(POPULATE_FILE_EXTENSION)):
|
245 |
+
name = POPULATE_FILE_EXTENSION[i]
|
246 |
+
file_name = f"{name}"
|
247 |
+
directory._add_file(file_name)
|
248 |
+
|
249 |
+
def pwd(self):
|
250 |
+
"""
|
251 |
+
Return the current working directory path.
|
252 |
+
Args:
|
253 |
+
None
|
254 |
+
Returns:
|
255 |
+
current_working_directory (str): The current working directory path.
|
256 |
+
|
257 |
+
"""
|
258 |
+
path = []
|
259 |
+
dir = self._current_dir
|
260 |
+
while dir is not None and dir.name != self.root:
|
261 |
+
path.append(dir.name)
|
262 |
+
dir = dir.parent
|
263 |
+
return {"current_working_directory": "/" + "/".join(reversed(path))}
|
264 |
+
|
265 |
+
def ls(self, a: bool = False) -> Dict[str, List[str]]:
|
266 |
+
"""
|
267 |
+
List the contents of the current directory.
|
268 |
+
|
269 |
+
Args:
|
270 |
+
a (bool): [Optional] Show hidden files and directories. Defaults to False.
|
271 |
+
|
272 |
+
Returns:
|
273 |
+
current_directory_content (List[str]): A list of the contents of the specified directory.
|
274 |
+
"""
|
275 |
+
contents = self._current_dir._list_contents()
|
276 |
+
if not a:
|
277 |
+
contents = [item for item in contents if not item.startswith(".")]
|
278 |
+
return {"current_directory_content": contents}
|
279 |
+
|
280 |
+
def cd(self, folder: str) -> Union[None, Dict[str, str]]:
|
281 |
+
"""
|
282 |
+
Change the current working directory to the specified folder.
|
283 |
+
|
284 |
+
Args:
|
285 |
+
folder (str): The folder of the directory to change to. You can only change one folder at a time.
|
286 |
+
|
287 |
+
Returns:
|
288 |
+
current_working_directory (str): The new current working directory path.
|
289 |
+
"""
|
290 |
+
# Handle navigating to the parent directory with "cd .."
|
291 |
+
if folder == "..":
|
292 |
+
if self._current_dir.parent:
|
293 |
+
self._current_dir = self._current_dir.parent
|
294 |
+
elif self.root == self._current_dir:
|
295 |
+
return {"error": "Cuurent directory is already the root. Cannot go back."}
|
296 |
+
else:
|
297 |
+
return {"error": "cd: ..: No such directory"}
|
298 |
+
return {}
|
299 |
+
|
300 |
+
# Handle absolute or relative paths
|
301 |
+
target_dir = self._navigate_to_directory(folder)
|
302 |
+
if isinstance(target_dir, dict): # Error condition check
|
303 |
+
return {
|
304 |
+
"error": f"cd: {folder}: No such directory. You cannot use path to change directory."
|
305 |
+
}
|
306 |
+
self._current_dir = target_dir
|
307 |
+
return {"current_working_directory": target_dir.name}
|
308 |
+
|
309 |
+
def _validate_file_or_directory_name(self, dir_name: str) -> bool:
|
310 |
+
if any(c in dir_name for c in '|/\\?%*:"><'):
|
311 |
+
return False
|
312 |
+
return True
|
313 |
+
|
314 |
+
def mkdir(self, dir_name: str) -> Union[None, Dict[str, str]]:
|
315 |
+
"""
|
316 |
+
Create a new directory in the current directory.
|
317 |
+
|
318 |
+
Args:
|
319 |
+
dir_name (str): The name of the new directory at current directory. You can only create directory at current directory.
|
320 |
+
"""
|
321 |
+
if not self._validate_file_or_directory_name(dir_name):
|
322 |
+
return {
|
323 |
+
"error": f"mkdir: cannot create directory '{dir_name}': Invalid character"
|
324 |
+
}
|
325 |
+
if dir_name in self._current_dir.contents:
|
326 |
+
return {"error": f"mkdir: cannot create directory '{dir_name}': File exists"}
|
327 |
+
|
328 |
+
self._current_dir._add_directory(dir_name)
|
329 |
+
return None
|
330 |
+
|
331 |
+
def touch(self, file_name: str) -> Union[None, Dict[str, str]]:
|
332 |
+
"""
|
333 |
+
Create a new file of any extension in the current directory.
|
334 |
+
|
335 |
+
Args:
|
336 |
+
file_name (str): The name of the new file in the current directory. file_name is local to the current directory and does not allow path.
|
337 |
+
"""
|
338 |
+
if not self._validate_file_or_directory_name(file_name):
|
339 |
+
return {"error": f"touch: cannot touch '{file_name}': Invalid character"}
|
340 |
+
|
341 |
+
if file_name in self._current_dir.contents:
|
342 |
+
return {"error": f"touch: cannot touch '{file_name}': File exists"}
|
343 |
+
|
344 |
+
self._current_dir._add_file(file_name)
|
345 |
+
return None
|
346 |
+
|
347 |
+
def echo(
|
348 |
+
self, content: str, file_name: Optional[str] = None
|
349 |
+
) -> Union[Dict[str, str], None]:
|
350 |
+
"""
|
351 |
+
Write content to a file at current directory or display it in the terminal.
|
352 |
+
|
353 |
+
Args:
|
354 |
+
content (str): The content to write or display.
|
355 |
+
file_name (str): [Optional] The name of the file at current directory to write the content to. Defaults to None.
|
356 |
+
|
357 |
+
Returns:
|
358 |
+
terminal_output (str): The content if no file name is provided, or None if written to file.
|
359 |
+
"""
|
360 |
+
if file_name is None:
|
361 |
+
return {"terminal_output": content}
|
362 |
+
if not self._validate_file_or_directory_name(file_name):
|
363 |
+
return {"error": f"echo: cannot touch '{file_name}': Invalid character"}
|
364 |
+
|
365 |
+
if file_name:
|
366 |
+
if file_name in self._current_dir.contents:
|
367 |
+
self._current_dir._get_item(file_name)._write(content)
|
368 |
+
else:
|
369 |
+
self._current_dir._add_file(file_name, content)
|
370 |
+
else:
|
371 |
+
return {"terminal_output": content}
|
372 |
+
|
373 |
+
def cat(self, file_name: str) -> Dict[str, str]:
|
374 |
+
"""
|
375 |
+
Display the contents of a file of any extension from currrent directory.
|
376 |
+
|
377 |
+
Args:
|
378 |
+
file_name (str): The name of the file from current directory to display. No path is allowed.
|
379 |
+
|
380 |
+
Returns:
|
381 |
+
file_content (str): The content of the file.
|
382 |
+
"""
|
383 |
+
if not self._validate_file_or_directory_name(file_name):
|
384 |
+
return {"error": f"cat: '{file_name}': Invalid character"}
|
385 |
+
|
386 |
+
if file_name in self._current_dir.contents:
|
387 |
+
item = self._current_dir._get_item(file_name)
|
388 |
+
if isinstance(item, File):
|
389 |
+
return {"file_content": item._read()}
|
390 |
+
else:
|
391 |
+
return {"error": f"cat: {file_name}: Is a directory"}
|
392 |
+
else:
|
393 |
+
return {"error": f"cat: {file_name}: No such file or directory"}
|
394 |
+
|
395 |
+
def find(self, path: str = ".", name: Optional[str] = None) -> Dict[str, List[str]]:
|
396 |
+
"""
|
397 |
+
Find any file or directories under specific path that contain name in its file name.
|
398 |
+
|
399 |
+
This method searches for files of any extension and directories within a specified path that match
|
400 |
+
the given name. If no name is provided, it returns all files and directories
|
401 |
+
in the specified path and its subdirectories.
|
402 |
+
Note: This method performs a recursive search through all subdirectories of the given path.
|
403 |
+
|
404 |
+
Args:
|
405 |
+
path (str): The directory path to start the search. Defaults to the current directory (".").
|
406 |
+
name (str): [Optional] The name of the file or directory to search for. If None, all items are returned.
|
407 |
+
|
408 |
+
Returns:
|
409 |
+
matches (List[str]): A list of matching file and directory paths relative to the given path.
|
410 |
+
|
411 |
+
"""
|
412 |
+
matches = []
|
413 |
+
target_dir = self._current_dir
|
414 |
+
|
415 |
+
def recursive_search(directory: Directory, base_path: str) -> None:
|
416 |
+
for item_name, item in directory.contents.items():
|
417 |
+
item_path = f"{base_path}/{item_name}"
|
418 |
+
if name is None or name in item_name:
|
419 |
+
matches.append(item_path)
|
420 |
+
if isinstance(item, Directory):
|
421 |
+
recursive_search(item, item_path)
|
422 |
+
|
423 |
+
recursive_search(target_dir, path.rstrip("/"))
|
424 |
+
return {"matches": matches}
|
425 |
+
|
426 |
+
def wc(self, file_name: str, mode: str = "l") -> Dict[str, Union[int, str]]:
|
427 |
+
"""
|
428 |
+
Count the number of lines, words, and characters in a file of any extension from current directory.
|
429 |
+
|
430 |
+
Args:
|
431 |
+
file_name (str): Name of the file of current directory to perform wc operation on.
|
432 |
+
mode (str): Mode of operation ('l' for lines, 'w' for words, 'c' for characters).
|
433 |
+
|
434 |
+
Returns:
|
435 |
+
count (int): The count of the number of lines, words, or characters in the file.
|
436 |
+
type (str): The type of unit we are counting. [Enum]: ["lines", "words", "characters"]
|
437 |
+
"""
|
438 |
+
if mode not in ["l", "w", "c"]:
|
439 |
+
return {"error": f"wc: invalid mode '{mode}'"}
|
440 |
+
|
441 |
+
if file_name in self._current_dir.contents:
|
442 |
+
file = self._current_dir._get_item(file_name)
|
443 |
+
if isinstance(file, File):
|
444 |
+
content = file._read()
|
445 |
+
|
446 |
+
if mode == "l":
|
447 |
+
line_count = len(content.splitlines())
|
448 |
+
return {"count": line_count, "type": "lines"}
|
449 |
+
|
450 |
+
elif mode == "w":
|
451 |
+
word_count = len(content.split())
|
452 |
+
return {"count": word_count, "type": "words"}
|
453 |
+
|
454 |
+
elif mode == "c":
|
455 |
+
char_count = len(content)
|
456 |
+
return {"count": char_count, "type": "characters"}
|
457 |
+
|
458 |
+
return {"error": f"wc: {file_name}: No such file or directory"}
|
459 |
+
|
460 |
+
def sort(self, file_name: str) -> Dict[str, str]:
|
461 |
+
"""
|
462 |
+
Sort the contents of a file line by line.
|
463 |
+
|
464 |
+
Args:
|
465 |
+
file_name (str): The name of the file appeared at current directory to sort.
|
466 |
+
|
467 |
+
Returns:
|
468 |
+
sorted_content (str): The sorted content of the file.
|
469 |
+
"""
|
470 |
+
if file_name in self._current_dir.contents:
|
471 |
+
file = self._current_dir._get_item(file_name)
|
472 |
+
if isinstance(file, File):
|
473 |
+
content = file._read()
|
474 |
+
|
475 |
+
sorted_content = "\n".join(sorted(content.splitlines()))
|
476 |
+
|
477 |
+
return {"sorted_content": sorted_content}
|
478 |
+
|
479 |
+
return {"error": f"sort: {file_name}: No such file or directory"}
|
480 |
+
|
481 |
+
def grep(self, file_name: str, pattern: str) -> Dict[str, List[str]]:
|
482 |
+
"""
|
483 |
+
Search for lines in a file of any extension at current directory that contain the specified pattern.
|
484 |
+
|
485 |
+
Args:
|
486 |
+
file_name (str): The name of the file to search. No path is allowed and you can only perform on file at local directory.
|
487 |
+
pattern (str): The pattern to search for.
|
488 |
+
|
489 |
+
Returns:
|
490 |
+
matching_lines (List[str]): Lines that match the pattern.
|
491 |
+
"""
|
492 |
+
if file_name in self._current_dir.contents:
|
493 |
+
file = self._current_dir._get_item(file_name)
|
494 |
+
if isinstance(file, File):
|
495 |
+
content = file._read()
|
496 |
+
|
497 |
+
matching_lines = [line for line in content.splitlines() if pattern in line]
|
498 |
+
|
499 |
+
return {"matching_lines": matching_lines}
|
500 |
+
|
501 |
+
return {"error": f"grep: {file_name}: No such file or directory"}
|
502 |
+
|
503 |
+
def du(self, human_readable: bool = False) -> Dict[str, str]:
|
504 |
+
"""
|
505 |
+
Estimate the disk usage of a directory and its contents.
|
506 |
+
|
507 |
+
Args:
|
508 |
+
human_readable (bool): If True, returns the size in human-readable format (e.g., KB, MB).
|
509 |
+
|
510 |
+
Returns:
|
511 |
+
disk_usage (str): The estimated disk usage.
|
512 |
+
"""
|
513 |
+
|
514 |
+
def get_size(item: Union[File, Directory]) -> int:
|
515 |
+
if isinstance(item, File):
|
516 |
+
return len(item._read().encode("utf-8"))
|
517 |
+
elif isinstance(item, Directory):
|
518 |
+
return sum(get_size(child) for child in item.contents.values())
|
519 |
+
return 0
|
520 |
+
|
521 |
+
target_dir = self._navigate_to_directory(None)
|
522 |
+
if isinstance(target_dir, dict): # Error condition check
|
523 |
+
return target_dir
|
524 |
+
|
525 |
+
total_size = get_size(target_dir)
|
526 |
+
|
527 |
+
if human_readable:
|
528 |
+
for unit in ["B", "KB", "MB", "GB", "TB"]:
|
529 |
+
if total_size < 1024:
|
530 |
+
size_str = f"{total_size:.2f} {unit}"
|
531 |
+
break
|
532 |
+
total_size /= 1024
|
533 |
+
else:
|
534 |
+
size_str = f"{total_size:.2f} PB"
|
535 |
+
else:
|
536 |
+
size_str = f"{total_size} bytes"
|
537 |
+
|
538 |
+
return {"disk_usage": size_str}
|
539 |
+
|
540 |
+
def tail(self, file_name: str, lines: int = 10) -> Dict[str, str]:
|
541 |
+
"""
|
542 |
+
Display the last part of a file of any extension.
|
543 |
+
|
544 |
+
Args:
|
545 |
+
file_name (str): The name of the file to display. No path is allowed and you can only perform on file at local directory.
|
546 |
+
lines (int): The number of lines to display from the end of the file. Defaults to 10.
|
547 |
+
|
548 |
+
Returns:
|
549 |
+
last_lines (str): The last part of the file.
|
550 |
+
"""
|
551 |
+
if file_name in self._current_dir.contents:
|
552 |
+
file = self._current_dir._get_item(file_name)
|
553 |
+
if isinstance(file, File):
|
554 |
+
content = file._read().splitlines()
|
555 |
+
|
556 |
+
if lines > len(content):
|
557 |
+
lines = len(content)
|
558 |
+
|
559 |
+
last_lines = content[-lines:]
|
560 |
+
return {"last_lines": "\n".join(last_lines)}
|
561 |
+
|
562 |
+
return {"error": f"tail: {file_name}: No such file or directory"}
|
563 |
+
|
564 |
+
def diff(self, file_name1: str, file_name2: str) -> Dict[str, str]:
|
565 |
+
"""
|
566 |
+
Compare two files of any extension line by line at the current directory.
|
567 |
+
|
568 |
+
Args:
|
569 |
+
file_name1 (str): The name of the first file in current directory.
|
570 |
+
file_name2 (str): The name of the second file in current directorry.
|
571 |
+
|
572 |
+
Returns:
|
573 |
+
diff_lines (str): The differences between the two files.
|
574 |
+
"""
|
575 |
+
if (
|
576 |
+
file_name1 in self._current_dir.contents
|
577 |
+
and file_name2 in self._current_dir.contents
|
578 |
+
):
|
579 |
+
file1 = self._current_dir._get_item(file_name1)
|
580 |
+
file2 = self._current_dir._get_item(file_name2)
|
581 |
+
|
582 |
+
if isinstance(file1, File) and isinstance(file2, File):
|
583 |
+
content1 = file1._read().splitlines()
|
584 |
+
content2 = file2._read().splitlines()
|
585 |
+
|
586 |
+
diff_lines = [
|
587 |
+
f"- {line1}\n+ {line2}"
|
588 |
+
for line1, line2 in zip(content1, content2)
|
589 |
+
if line1 != line2
|
590 |
+
]
|
591 |
+
|
592 |
+
return {"diff_lines": "\n".join(diff_lines)}
|
593 |
+
|
594 |
+
return {"error": f"diff: {file_name1} or {file_name2}: No such file or directory"}
|
595 |
+
|
596 |
+
def mv(self, source: str, destination: str) -> Dict[str, str]:
|
597 |
+
"""
|
598 |
+
Move a file or directory from one location to another. so
|
599 |
+
|
600 |
+
Args:
|
601 |
+
source (str): Source name of the file or directory to move. Source must be local to the current directory.
|
602 |
+
destination (str): The destination name to move the file or directory to. Destination must be local to the current directory and cannot be a path. If destination is not an existing directory like when renaming something, destination is the new file name.
|
603 |
+
|
604 |
+
Returns:
|
605 |
+
result (str): The result of the move operation.
|
606 |
+
"""
|
607 |
+
if source not in self._current_dir.contents:
|
608 |
+
return {"error": f"mv: cannot move '{source}': No such file or directory"}
|
609 |
+
|
610 |
+
item = self._current_dir._get_item(source)
|
611 |
+
|
612 |
+
if not isinstance(item, (File, Directory)):
|
613 |
+
return {"error": f"mv: cannot move '{source}': Not a file or directory"}
|
614 |
+
|
615 |
+
if "/" in destination:
|
616 |
+
return {
|
617 |
+
"error": f"mv: no path allowed in destination. Only file name and folder name is supported for this operation."
|
618 |
+
}
|
619 |
+
|
620 |
+
# Check if the destination is an existing directory
|
621 |
+
if destination in self._current_dir.contents:
|
622 |
+
dest_item = self._current_dir._get_item(destination)
|
623 |
+
if isinstance(dest_item, Directory):
|
624 |
+
# Move source into the destination directory
|
625 |
+
new_destination = f"{source}"
|
626 |
+
if new_destination in dest_item.contents:
|
627 |
+
return {
|
628 |
+
"error": f"mv: cannot move '{source}' to '{destination}/{source}': File exists"
|
629 |
+
}
|
630 |
+
else:
|
631 |
+
self._current_dir.contents.pop(source)
|
632 |
+
if isinstance(item, File):
|
633 |
+
dest_item._add_file(source, item.content)
|
634 |
+
else:
|
635 |
+
dest_item._add_directory(source)
|
636 |
+
dest_item.contents[source].contents = item.contents
|
637 |
+
return {"result": f"'{source}' moved to '{destination}/{source}'"}
|
638 |
+
else:
|
639 |
+
return {
|
640 |
+
"error": f"mv: cannot move '{source}' to '{destination}': Not a directory"
|
641 |
+
}
|
642 |
+
else:
|
643 |
+
# Destination is not an existing directory, move/rename the item
|
644 |
+
self._current_dir.contents.pop(source)
|
645 |
+
if isinstance(item, File):
|
646 |
+
self._current_dir._add_file(destination, item.content)
|
647 |
+
else:
|
648 |
+
self._current_dir._add_directory(destination)
|
649 |
+
self._current_dir.contents[destination].contents = item.contents
|
650 |
+
return {"result": f"'{source}' moved to '{destination}'"}
|
651 |
+
|
652 |
+
def rm(self, file_name: str) -> Dict[str, str]:
|
653 |
+
"""
|
654 |
+
Remove a file or directory.
|
655 |
+
|
656 |
+
Args:
|
657 |
+
file_name (str): The name of the file or directory to remove.
|
658 |
+
|
659 |
+
Returns:
|
660 |
+
result (str): The result of the remove operation.
|
661 |
+
"""
|
662 |
+
if file_name in self._current_dir.contents:
|
663 |
+
item = self._current_dir._get_item(file_name)
|
664 |
+
if isinstance(item, File) or isinstance(item, Directory):
|
665 |
+
self._current_dir.contents.pop(file_name)
|
666 |
+
return {"result": f"'{file_name}' removed"}
|
667 |
+
else:
|
668 |
+
return {
|
669 |
+
"error": f"rm: cannot remove '{file_name}': Not a file or directory"
|
670 |
+
}
|
671 |
+
else:
|
672 |
+
return {"error": f"rm: cannot remove '{file_name}': No such file or directory"}
|
673 |
+
|
674 |
+
def rmdir(self, dir_name: str) -> Dict[str, str]:
|
675 |
+
"""
|
676 |
+
Remove a directory at current directory.
|
677 |
+
|
678 |
+
Args:
|
679 |
+
dir_name (str): The name of the directory to remove. Directory must be local to the current directory.
|
680 |
+
|
681 |
+
Returns:
|
682 |
+
result (str): The result of the remove operation.
|
683 |
+
"""
|
684 |
+
if dir_name in self._current_dir.contents:
|
685 |
+
item = self._current_dir._get_item(dir_name)
|
686 |
+
if isinstance(item, Directory):
|
687 |
+
if item.contents: # Check if directory is not empty
|
688 |
+
return {
|
689 |
+
"error": f"rmdir: failed to remove '{dir_name}': Directory not empty"
|
690 |
+
}
|
691 |
+
else:
|
692 |
+
self._current_dir.contents.pop(dir_name)
|
693 |
+
return {"result": f"'{dir_name}' removed"}
|
694 |
+
else:
|
695 |
+
return {"error": f"rmdir: cannot remove '{dir_name}': Not a directory"}
|
696 |
+
else:
|
697 |
+
return {
|
698 |
+
"error": f"rmdir: cannot remove '{dir_name}': No such file or directory"
|
699 |
+
}
|
700 |
+
|
701 |
+
def cp(self, source: str, destination: str) -> Dict[str, str]:
|
702 |
+
"""
|
703 |
+
Copy a file or directory from one location to another.
|
704 |
+
|
705 |
+
If the destination is a directory, the source file or directory will be copied
|
706 |
+
into the destination directory.
|
707 |
+
|
708 |
+
Both source and destination must be local to the current directory.
|
709 |
+
|
710 |
+
Args:
|
711 |
+
source (str): The name of the file or directory to copy.
|
712 |
+
destination (str): The destination name to copy the file or directory to.
|
713 |
+
If the destination is a directory, the source will be copied
|
714 |
+
into this directory. No file paths allowed.
|
715 |
+
|
716 |
+
Returns:
|
717 |
+
result (str): The result of the copy operation or an error message if the operation fails.
|
718 |
+
"""
|
719 |
+
if source not in self._current_dir.contents:
|
720 |
+
return {"error": f"cp: cannot copy '{source}': No such file or directory"}
|
721 |
+
|
722 |
+
item = self._current_dir._get_item(source)
|
723 |
+
|
724 |
+
if not isinstance(item, (File, Directory)):
|
725 |
+
return {"error": f"cp: cannot copy '{source}': Not a file or directory"}
|
726 |
+
|
727 |
+
if "/" in destination:
|
728 |
+
return {
|
729 |
+
"error": f"cp: don't allow path in destination. Only file name and folder name is supported for this operation."
|
730 |
+
}
|
731 |
+
# Check if the destination is an existing directory
|
732 |
+
if destination in self._current_dir.contents:
|
733 |
+
dest_item = self._current_dir._get_item(destination)
|
734 |
+
if isinstance(dest_item, Directory):
|
735 |
+
# Copy source into the destination directory
|
736 |
+
new_destination = f"{destination}/{source}"
|
737 |
+
if new_destination in dest_item.contents:
|
738 |
+
return {
|
739 |
+
"error": f"cp: cannot copy '{source}' to '{destination}/{source}': File exists"
|
740 |
+
}
|
741 |
+
else:
|
742 |
+
if isinstance(item, File):
|
743 |
+
dest_item._add_file(source, item.content)
|
744 |
+
else:
|
745 |
+
dest_item._add_directory(source)
|
746 |
+
dest_item.contents[source].contents = item.contents.copy()
|
747 |
+
return {"result": f"'{source}' copied to '{destination}/{source}'"}
|
748 |
+
else:
|
749 |
+
return {
|
750 |
+
"error": f"cp: cannot copy '{source}' to '{destination}': Not a directory"
|
751 |
+
}
|
752 |
+
else:
|
753 |
+
# Destination is not an existing directory, perform the copy
|
754 |
+
if isinstance(item, File):
|
755 |
+
self._current_dir._add_file(destination, item.content)
|
756 |
+
else:
|
757 |
+
self._current_dir._add_directory(destination)
|
758 |
+
self._current_dir.contents[destination].contents = item.contents.copy()
|
759 |
+
return {"result": f"'{source}' copied to '{destination}'"}
|
760 |
+
|
761 |
+
def _navigate_to_directory(
|
762 |
+
self, path: Optional[str]
|
763 |
+
) -> Union[Directory, Dict[str, str]]:
|
764 |
+
"""
|
765 |
+
Navigate to a specified directory path from the current directory.
|
766 |
+
|
767 |
+
Args:
|
768 |
+
path (str): [Optional] The path to navigate to. Defaults to None (current directory).
|
769 |
+
|
770 |
+
Returns:
|
771 |
+
target_directory (Directory or dict): The target directory object or error message.
|
772 |
+
"""
|
773 |
+
if path is None or path == ".":
|
774 |
+
return self._current_dir
|
775 |
+
elif path == "/":
|
776 |
+
return self.root
|
777 |
+
|
778 |
+
dirs = path.strip("/").split("/")
|
779 |
+
temp_dir = self._current_dir if not path.startswith("/") else self.root
|
780 |
+
|
781 |
+
for dir_name in dirs:
|
782 |
+
next_dir = temp_dir._get_item(dir_name)
|
783 |
+
if isinstance(next_dir, Directory):
|
784 |
+
temp_dir = next_dir
|
785 |
+
else:
|
786 |
+
return {"error": f"cd: '{path}': No such file or directory"}
|
787 |
+
|
788 |
+
return temp_dir
|
789 |
+
|
790 |
+
def _parse_positions(self, positions: str) -> List[int]:
|
791 |
+
"""
|
792 |
+
Helper function to parse position strings, e.g., '1,3,5', '1-5', '-3', or '3-'.
|
793 |
+
|
794 |
+
Args:
|
795 |
+
positions (str): The position string to parse.
|
796 |
+
|
797 |
+
Returns:
|
798 |
+
list (List[int]): A list of integers representing the positions.
|
799 |
+
"""
|
800 |
+
result = []
|
801 |
+
if "," in positions:
|
802 |
+
for part in positions.split(","):
|
803 |
+
result.extend(self._parse_positions(part))
|
804 |
+
elif "-" in positions:
|
805 |
+
start, end = positions.split("-")
|
806 |
+
start = int(start) if start else 1
|
807 |
+
end = int(end) if end else float("inf")
|
808 |
+
result.extend(range(start, end + 1))
|
809 |
+
else:
|
810 |
+
result.append(int(positions))
|
811 |
+
return result
|
multi_turn_eval/func_source_code/long_context.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|
multi_turn_eval/func_source_code/math_api.py
ADDED
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import math
|
2 |
+
from decimal import Decimal, InvalidOperation, getcontext
|
3 |
+
from typing import Dict, List, Optional, Union
|
4 |
+
|
5 |
+
import mpmath
|
6 |
+
|
7 |
+
|
8 |
+
class MathAPI:
|
9 |
+
def __init__(self):
|
10 |
+
self._api_description = "This tool belongs to the Math API, which provides various mathematical operations."
|
11 |
+
|
12 |
+
def logarithm(
|
13 |
+
self, value: float, base: float, precision: int
|
14 |
+
) -> Dict[str, float]:
|
15 |
+
"""
|
16 |
+
Compute the logarithm of a number with adjustable precision using mpmath.
|
17 |
+
|
18 |
+
Args:
|
19 |
+
value (float): The number to compute the logarithm of.
|
20 |
+
base (float): The base of the logarithm.
|
21 |
+
precision (int): Desired precision for the result.
|
22 |
+
|
23 |
+
Returns:
|
24 |
+
result (float): The logarithm of the number with respect to the given base.
|
25 |
+
"""
|
26 |
+
try:
|
27 |
+
# Set precision for mpmath
|
28 |
+
mpmath.mp.dps = precision
|
29 |
+
|
30 |
+
# Use mpmath for high-precision logarithmic calculations
|
31 |
+
result = mpmath.log(value) / mpmath.log(base)
|
32 |
+
|
33 |
+
return {"result": result}
|
34 |
+
except Exception as e:
|
35 |
+
return {"error": str(e)}
|
36 |
+
|
37 |
+
def mean(self, numbers: List[float]) -> Dict[str, float]:
|
38 |
+
"""
|
39 |
+
Calculate the mean of a list of numbers.
|
40 |
+
|
41 |
+
Args:
|
42 |
+
numbers (List[float]): List of numbers to calculate the mean of.
|
43 |
+
|
44 |
+
Returns:
|
45 |
+
result (float): Mean of the numbers.
|
46 |
+
"""
|
47 |
+
if not numbers:
|
48 |
+
return {"error": "Cannot calculate mean of an empty list"}
|
49 |
+
try:
|
50 |
+
return {"result": sum(numbers) / len(numbers)}
|
51 |
+
except TypeError:
|
52 |
+
return {"error": "All elements in the list must be numbers"}
|
53 |
+
|
54 |
+
def standard_deviation(self, numbers: List[float]) -> Dict[str, float]:
|
55 |
+
"""
|
56 |
+
Calculate the standard deviation of a list of numbers.
|
57 |
+
|
58 |
+
Args:
|
59 |
+
numbers (List[float]): List of numbers to calculate the standard deviation of.
|
60 |
+
|
61 |
+
Returns:
|
62 |
+
result (float): Standard deviation of the numbers.
|
63 |
+
"""
|
64 |
+
if not numbers:
|
65 |
+
return {"error": "Cannot calculate standard deviation of an empty list"}
|
66 |
+
try:
|
67 |
+
mean = sum(numbers) / len(numbers)
|
68 |
+
variance = sum((x - mean) ** 2 for x in numbers) / len(numbers)
|
69 |
+
return {"result": math.sqrt(variance)}
|
70 |
+
except TypeError:
|
71 |
+
return {"error": "All elements in the list must be numbers"}
|
72 |
+
|
73 |
+
def si_unit_conversion(
|
74 |
+
self, value: float, unit_in: str, unit_out: str
|
75 |
+
) -> Dict[str, float]:
|
76 |
+
"""
|
77 |
+
Convert a value from one SI unit to another.
|
78 |
+
|
79 |
+
Args:
|
80 |
+
value (float): Value to be converted.
|
81 |
+
unit_in (str): Unit of the input value.
|
82 |
+
unit_out (str): Unit to convert the value to.
|
83 |
+
|
84 |
+
Returns:
|
85 |
+
result (float): Converted value in the new unit.
|
86 |
+
"""
|
87 |
+
to_meters = {"km": 1000, "m": 1, "cm": 0.01, "mm": 0.001, "um": 1e-6, "nm": 1e-9}
|
88 |
+
from_meters = {unit: 1 / factor for unit, factor in to_meters.items()}
|
89 |
+
|
90 |
+
if not isinstance(value, (int, float)):
|
91 |
+
return {"error": "Value must be a number"}
|
92 |
+
|
93 |
+
if unit_in not in to_meters or unit_out not in from_meters:
|
94 |
+
return {
|
95 |
+
"error": f"Conversion from '{unit_in}' to '{unit_out}' is not supported"
|
96 |
+
}
|
97 |
+
|
98 |
+
try:
|
99 |
+
value_in_meters = value * to_meters[unit_in]
|
100 |
+
result = value_in_meters * from_meters[unit_out]
|
101 |
+
return {"result": result}
|
102 |
+
except OverflowError:
|
103 |
+
return {"error": "Conversion resulted in a value too large to represent"}
|
104 |
+
|
105 |
+
def imperial_si_conversion(
|
106 |
+
self, value: float, unit_in: str, unit_out: str
|
107 |
+
) -> Dict[str, float]:
|
108 |
+
"""
|
109 |
+
Convert a value between imperial and SI units.
|
110 |
+
|
111 |
+
Args:
|
112 |
+
value (float): Value to be converted.
|
113 |
+
unit_in (str): Unit of the input value.
|
114 |
+
unit_out (str): Unit to convert the value to.
|
115 |
+
|
116 |
+
Returns:
|
117 |
+
result (float): Converted value in the new unit.
|
118 |
+
"""
|
119 |
+
conversion = {
|
120 |
+
"cm_to_in": 0.393701,
|
121 |
+
"in_to_cm": 2.54,
|
122 |
+
"m_to_ft": 3.28084,
|
123 |
+
"ft_to_m": 0.3048,
|
124 |
+
"m_to_yd": 1.09361,
|
125 |
+
"yd_to_m": 0.9144,
|
126 |
+
"km_to_miles": 0.621371,
|
127 |
+
"miles_to_km": 1.60934,
|
128 |
+
"kg_to_lb": 2.20462,
|
129 |
+
"lb_to_kg": 0.453592,
|
130 |
+
"celsius_to_fahrenheit": 1.8,
|
131 |
+
"fahrenheit_to_celsius": 5 / 9,
|
132 |
+
}
|
133 |
+
|
134 |
+
if not isinstance(value, (int, float)):
|
135 |
+
return {"error": "Value must be a number"}
|
136 |
+
|
137 |
+
if unit_in == unit_out:
|
138 |
+
return {"result": value}
|
139 |
+
|
140 |
+
conversion_key = f"{unit_in}_to_{unit_out}"
|
141 |
+
if conversion_key not in conversion:
|
142 |
+
return {
|
143 |
+
"error": f"Conversion from '{unit_in}' to '{unit_out}' is not supported"
|
144 |
+
}
|
145 |
+
|
146 |
+
try:
|
147 |
+
if unit_in == "celsius" and unit_out == "fahrenheit":
|
148 |
+
result = (value * conversion[conversion_key]) + 32
|
149 |
+
elif unit_in == "fahrenheit" and unit_out == "celsius":
|
150 |
+
result = (value - 32) * conversion[conversion_key]
|
151 |
+
else:
|
152 |
+
result = value * conversion[conversion_key]
|
153 |
+
|
154 |
+
return {"result": result}
|
155 |
+
except OverflowError:
|
156 |
+
return {"error": "Conversion resulted in a value too large to represent"}
|
157 |
+
|
158 |
+
def add(self, a: float, b: float) -> Dict[str, float]:
|
159 |
+
"""
|
160 |
+
Add two numbers.
|
161 |
+
|
162 |
+
Args:
|
163 |
+
a (float): First number.
|
164 |
+
b (float): Second number.
|
165 |
+
|
166 |
+
Returns:
|
167 |
+
result (float): Sum of the two numbers.
|
168 |
+
"""
|
169 |
+
try:
|
170 |
+
return {"result": a + b}
|
171 |
+
except TypeError:
|
172 |
+
return {"error": "Both inputs must be numbers"}
|
173 |
+
|
174 |
+
def subtract(self, a: float, b: float) -> Dict[str, float]:
|
175 |
+
"""
|
176 |
+
Subtract one number from another.
|
177 |
+
|
178 |
+
Args:
|
179 |
+
a (float): Number to subtract from.
|
180 |
+
b (float): Number to subtract.
|
181 |
+
|
182 |
+
Returns:
|
183 |
+
result (float): Difference between the two numbers.
|
184 |
+
"""
|
185 |
+
try:
|
186 |
+
return {"result": a - b}
|
187 |
+
except TypeError:
|
188 |
+
return {"error": "Both inputs must be numbers"}
|
189 |
+
|
190 |
+
def multiply(self, a: float, b: float) -> Dict[str, float]:
|
191 |
+
"""
|
192 |
+
Multiply two numbers.
|
193 |
+
|
194 |
+
Args:
|
195 |
+
a (float): First number.
|
196 |
+
b (float): Second number.
|
197 |
+
|
198 |
+
Returns:
|
199 |
+
result (float): Product of the two numbers.
|
200 |
+
"""
|
201 |
+
if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
|
202 |
+
return {"error": "Both inputs must be numbers"}
|
203 |
+
|
204 |
+
try:
|
205 |
+
return {"result": a * b}
|
206 |
+
except TypeError:
|
207 |
+
return {"error": "Both inputs must be numbers"}
|
208 |
+
|
209 |
+
def divide(self, a: float, b: float) -> Dict[str, float]:
|
210 |
+
"""
|
211 |
+
Divide one number by another.
|
212 |
+
|
213 |
+
Args:
|
214 |
+
a (float): Numerator.
|
215 |
+
b (float): Denominator.
|
216 |
+
|
217 |
+
Returns:
|
218 |
+
result (float): Quotient of the division.
|
219 |
+
"""
|
220 |
+
try:
|
221 |
+
if b == 0:
|
222 |
+
return {"error": "Cannot divide by zero"}
|
223 |
+
return {"result": a / b}
|
224 |
+
except TypeError:
|
225 |
+
return {"error": "Both inputs must be numbers"}
|
226 |
+
|
227 |
+
def power(self, base: float, exponent: float) -> Dict[str, float]:
|
228 |
+
"""
|
229 |
+
Raise a number to a power.
|
230 |
+
|
231 |
+
Args:
|
232 |
+
base (float): The base number.
|
233 |
+
exponent (float): The exponent.
|
234 |
+
|
235 |
+
Returns:
|
236 |
+
result (float): The base raised to the power of the exponent.
|
237 |
+
"""
|
238 |
+
try:
|
239 |
+
return {"result": base**exponent}
|
240 |
+
except TypeError:
|
241 |
+
return {"error": "Both inputs must be numbers"}
|
242 |
+
|
243 |
+
def square_root(self, number: float, precision: int) -> Dict[str, float]:
|
244 |
+
"""
|
245 |
+
Calculate the square root of a number with adjustable precision using the decimal module.
|
246 |
+
|
247 |
+
Args:
|
248 |
+
number (float): The number to calculate the square root of.
|
249 |
+
precision (int): Desired precision for the result.
|
250 |
+
|
251 |
+
Returns:
|
252 |
+
result (float): The square root of the number, or an error message.
|
253 |
+
"""
|
254 |
+
try:
|
255 |
+
if number < 0:
|
256 |
+
return {"error": "Cannot calculate square root of a negative number"}
|
257 |
+
|
258 |
+
# Set the precision for the decimal context
|
259 |
+
getcontext().prec = precision
|
260 |
+
|
261 |
+
# Use Decimal for high-precision square root calculation
|
262 |
+
decimal_number = Decimal(number)
|
263 |
+
|
264 |
+
result = decimal_number.sqrt()
|
265 |
+
return {"result": result}
|
266 |
+
except (TypeError, InvalidOperation):
|
267 |
+
return {
|
268 |
+
"error": "Input must be a number or computation resulted in an invalid operation"
|
269 |
+
}
|
270 |
+
|
271 |
+
def absolute_value(self, number: float) -> Dict[str, float]:
|
272 |
+
"""
|
273 |
+
Calculate the absolute value of a number.
|
274 |
+
|
275 |
+
Args:
|
276 |
+
number (float): The number to calculate the absolute value of.
|
277 |
+
|
278 |
+
Returns:
|
279 |
+
result (float): The absolute value of the number.
|
280 |
+
"""
|
281 |
+
try:
|
282 |
+
return {"result": abs(number)}
|
283 |
+
except TypeError:
|
284 |
+
return {"error": "Input must be a number"}
|
285 |
+
|
286 |
+
def round_number(
|
287 |
+
self, number: float, decimal_places: int = 0
|
288 |
+
) -> Dict[str, float]:
|
289 |
+
"""
|
290 |
+
Round a number to a specified number of decimal places.
|
291 |
+
|
292 |
+
Args:
|
293 |
+
number (float): The number to round.
|
294 |
+
decimal_places (int): [Optional] The number of decimal places to round to. Defaults to 0.
|
295 |
+
|
296 |
+
Returns:
|
297 |
+
result (float): The rounded number.
|
298 |
+
"""
|
299 |
+
try:
|
300 |
+
return {"result": round(number, decimal_places)}
|
301 |
+
except TypeError:
|
302 |
+
return {
|
303 |
+
"error": "First input must be a number, second input must be an integer"
|
304 |
+
}
|
305 |
+
|
306 |
+
def percentage(self, part: float, whole: float) -> Dict[str, float]:
|
307 |
+
"""
|
308 |
+
Calculate the percentage of a part relative to a whole.
|
309 |
+
|
310 |
+
Args:
|
311 |
+
part (float): The part value.
|
312 |
+
whole (float): The whole value.
|
313 |
+
|
314 |
+
Returns:
|
315 |
+
result (float): The percentage of the part relative to the whole.
|
316 |
+
"""
|
317 |
+
try:
|
318 |
+
if whole == 0:
|
319 |
+
return {"error": "Whole value cannot be zero"}
|
320 |
+
return {"result": (part / whole) * 100}
|
321 |
+
except TypeError:
|
322 |
+
return {"error": "Both inputs must be numbers"}
|
323 |
+
|
324 |
+
def min_value(self, numbers: List[float]) -> Dict[str, float]:
|
325 |
+
"""
|
326 |
+
Find the minimum value in a list of numbers.
|
327 |
+
|
328 |
+
Args:
|
329 |
+
numbers (List[float]): List of numbers to find the minimum from.
|
330 |
+
|
331 |
+
Returns:
|
332 |
+
result (float): The minimum value in the list.
|
333 |
+
"""
|
334 |
+
if not numbers:
|
335 |
+
return {"error": "Cannot find minimum of an empty list"}
|
336 |
+
try:
|
337 |
+
return {"result": min(numbers)}
|
338 |
+
except TypeError:
|
339 |
+
return {"error": "All elements in the list must be numbers"}
|
340 |
+
|
341 |
+
def max_value(self, numbers: List[float]) -> Dict[str, float]:
|
342 |
+
"""
|
343 |
+
Find the maximum value in a list of numbers.
|
344 |
+
|
345 |
+
Args:
|
346 |
+
numbers (List[float]): List of numbers to find the maximum from.
|
347 |
+
|
348 |
+
Returns:
|
349 |
+
result (float): The maximum value in the list.
|
350 |
+
"""
|
351 |
+
if not numbers:
|
352 |
+
return {"error": "Cannot find maximum of an empty list"}
|
353 |
+
try:
|
354 |
+
return {"result": max(numbers)}
|
355 |
+
except TypeError:
|
356 |
+
return {"error": "All elements in the list must be numbers"}
|
357 |
+
|
358 |
+
def sum_values(self, numbers: List[float]) -> Dict[str, float]:
|
359 |
+
"""
|
360 |
+
Calculate the sum of a list of numbers.
|
361 |
+
|
362 |
+
Args:
|
363 |
+
numbers (List[float]): List of numbers to sum.
|
364 |
+
|
365 |
+
Returns:
|
366 |
+
result (float): The sum of all numbers in the list.
|
367 |
+
"""
|
368 |
+
if not numbers:
|
369 |
+
return {"error": "Cannot calculate sum of an empty list"}
|
370 |
+
try:
|
371 |
+
return {"result": sum(numbers)}
|
372 |
+
except TypeError:
|
373 |
+
return {"error": "All elements in the list must be numbers"}
|
multi_turn_eval/func_source_code/message_api.py
ADDED
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
from copy import deepcopy
|
3 |
+
from typing import Dict, List, Optional, Union
|
4 |
+
|
5 |
+
DEFAULT_STATE = {
|
6 |
+
"generated_ids": set(),
|
7 |
+
"user_count": 4,
|
8 |
+
"user_map": {
|
9 |
+
"Alice": "USR001",
|
10 |
+
"Bob": "USR002",
|
11 |
+
"Catherine": "USR003",
|
12 |
+
"Daniel": "USR004",
|
13 |
+
},
|
14 |
+
"inbox": [
|
15 |
+
{
|
16 |
+
"USR002": "My name is Alice. I want to connect.",
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"USR003": "Could you upload the file?",
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"USR004": "Could you upload the file?",
|
23 |
+
},
|
24 |
+
],
|
25 |
+
"message_count": 3,
|
26 |
+
"current_user": None,
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
class MessageAPI:
|
31 |
+
"""
|
32 |
+
A class representing a Message API for managing user interactions in a workspace.
|
33 |
+
|
34 |
+
This class provides methods for user management, messaging, and message retrieval
|
35 |
+
within a specific workspace. It maintains user information, sent messages, and
|
36 |
+
received messages for each user.
|
37 |
+
|
38 |
+
Attributes:
|
39 |
+
user_map (Dict[str, str]): A mapping of user names to user IDs.
|
40 |
+
inbox (Dict[int, Dict[str, Union[str, int]]]): A dictionary storing all messages.
|
41 |
+
message_count (int): The total count of messages in the workspace.
|
42 |
+
current_user (Optional[str]): The ID of the currently logged-in user.
|
43 |
+
|
44 |
+
Methods:
|
45 |
+
generate_id(): Generate a unique ID for a message.
|
46 |
+
list_users(): List all users in the workspace.
|
47 |
+
get_user_id(user: str): Get the user ID for a given username.
|
48 |
+
login(user_id: str): Log in a user.
|
49 |
+
send_message(receiver_id: str, message: str): Send a message to another user.
|
50 |
+
view_messages_sent(): View messages sent by the current user.
|
51 |
+
delete_message(receiver_id: str, message_index: int): Delete a sent message.
|
52 |
+
add_contact(name: str, user_id: str): Add a new contact to the workspace.
|
53 |
+
search_messages(keyword: str): Search for messages containing a keyword.
|
54 |
+
get_message_stats(): Get messaging statistics for the current user.
|
55 |
+
"""
|
56 |
+
|
57 |
+
def __init__(self):
|
58 |
+
"""
|
59 |
+
Initialize the MessageAPI with a workspace ID.
|
60 |
+
"""
|
61 |
+
self.generated_ids: set
|
62 |
+
self.user_count: int
|
63 |
+
self.user_map: Dict[str, str]
|
64 |
+
self.inbox: List[Dict[str, str]]
|
65 |
+
self.message_count: int
|
66 |
+
self.current_user: Optional[str]
|
67 |
+
self._api_description = "This tool belongs to the Message API, which is used to manage user interactions in a workspace."
|
68 |
+
|
69 |
+
def _load_scenario(self, scenario: dict, long_context=False) -> None:
|
70 |
+
"""
|
71 |
+
Load a scenario into the MessageAPI.
|
72 |
+
|
73 |
+
Args:
|
74 |
+
scenario (Dict): A dictionary containing message data.
|
75 |
+
"""
|
76 |
+
DEFAULT_STATE_COPY = deepcopy(DEFAULT_STATE)
|
77 |
+
self._random = random.Random((scenario.get("random_seed", 200191)))
|
78 |
+
self.generated_ids = scenario.get(
|
79 |
+
"generated_ids", DEFAULT_STATE_COPY["generated_ids"]
|
80 |
+
)
|
81 |
+
self.user_count = scenario.get("user_count", DEFAULT_STATE_COPY["user_count"])
|
82 |
+
self.user_map = scenario.get("user_map", DEFAULT_STATE_COPY["user_map"])
|
83 |
+
self.inbox = scenario.get("inbox", DEFAULT_STATE_COPY["inbox"])
|
84 |
+
self.message_count = scenario.get(
|
85 |
+
"message_count", DEFAULT_STATE_COPY["message_count"]
|
86 |
+
)
|
87 |
+
self.current_user = scenario.get("current_user", DEFAULT_STATE_COPY["current_user"])
|
88 |
+
|
89 |
+
def __eq__(self, value: object) -> bool:
|
90 |
+
if not isinstance(value, MessageAPI):
|
91 |
+
return False
|
92 |
+
|
93 |
+
for attr_name in vars(self):
|
94 |
+
if attr_name.startswith("_"):
|
95 |
+
continue
|
96 |
+
model_attr = getattr(self, attr_name)
|
97 |
+
ground_truth_attr = getattr(value, attr_name)
|
98 |
+
|
99 |
+
if model_attr != ground_truth_attr:
|
100 |
+
return False
|
101 |
+
|
102 |
+
return True
|
103 |
+
|
104 |
+
def _generate_id(self):
|
105 |
+
"""
|
106 |
+
Generate a unique ID for a message.
|
107 |
+
|
108 |
+
Returns:
|
109 |
+
new_id (int): A unique ID for a message.
|
110 |
+
"""
|
111 |
+
new_id = self._random.randint(
|
112 |
+
10000, 99999
|
113 |
+
) # first 5 mapped by initial configuration.
|
114 |
+
while new_id in self.generated_ids:
|
115 |
+
new_id = self._random.randint(10000, 99999)
|
116 |
+
self.generated_ids.add(new_id)
|
117 |
+
return {"new_id": new_id}
|
118 |
+
|
119 |
+
def list_users(self) -> Dict[str, List[str]]:
|
120 |
+
"""
|
121 |
+
List all users in the workspace.
|
122 |
+
|
123 |
+
Returns:
|
124 |
+
user_list (List[str]): List of all users in the workspace.
|
125 |
+
"""
|
126 |
+
return {"user_list": list(self.user_map.keys())}
|
127 |
+
|
128 |
+
def get_user_id(self, user: str) -> Dict[str, Optional[str]]:
|
129 |
+
"""
|
130 |
+
Get user ID from user name.
|
131 |
+
|
132 |
+
Args:
|
133 |
+
user (str): User name of the user.
|
134 |
+
|
135 |
+
Returns:
|
136 |
+
user_id (str): User ID of the user
|
137 |
+
"""
|
138 |
+
if user not in self.user_map:
|
139 |
+
return {"error": f"User '{user}' not found in the workspace."}
|
140 |
+
return {"user_id": self.user_map.get(user)}
|
141 |
+
|
142 |
+
def message_login(self, user_id: str) -> Dict[str, Union[str, bool]]:
|
143 |
+
"""
|
144 |
+
Log in a user with the given user ID to messeage application.
|
145 |
+
|
146 |
+
Args:
|
147 |
+
user_id (str): User ID of the user to log in.
|
148 |
+
|
149 |
+
Returns:
|
150 |
+
login_status (bool): True if login was successful, False otherwise.
|
151 |
+
message (str): A message describing the result of the login attempt.
|
152 |
+
"""
|
153 |
+
if user_id not in [id for id in self.user_map.values()]:
|
154 |
+
return {"login_status": False, "message": f"User ID '{user_id}' not found."}
|
155 |
+
self.current_user = user_id
|
156 |
+
return {
|
157 |
+
"login_status": True,
|
158 |
+
"message": f"User '{user_id}' logged in successfully.",
|
159 |
+
}
|
160 |
+
|
161 |
+
def message_get_login_status(self) -> Dict[str, bool]:
|
162 |
+
"""
|
163 |
+
Get the login status of the current user.
|
164 |
+
|
165 |
+
Returns:
|
166 |
+
login_status (bool): True if the current user is logged in, False otherwise.
|
167 |
+
"""
|
168 |
+
return {"login_status": bool(self.current_user)}
|
169 |
+
|
170 |
+
def send_message(self, receiver_id: str, message: str) -> Dict[str, Union[str, bool]]:
|
171 |
+
"""
|
172 |
+
Send a message to a user.
|
173 |
+
Args:
|
174 |
+
receiver_id (str): User ID of the user to send the message to.
|
175 |
+
message (str): Message to be sent.
|
176 |
+
Returns:
|
177 |
+
sent_status (bool): True if the message was sent successfully, False otherwise.
|
178 |
+
message_id (int): ID of the sent message.
|
179 |
+
message (str): A message describing the result of the send attempt.
|
180 |
+
"""
|
181 |
+
# Check if there is a current user logged in
|
182 |
+
if not self.current_user:
|
183 |
+
return {"error": "No user is currently logged in."}
|
184 |
+
# Validate receiver existence
|
185 |
+
if receiver_id not in self.user_map.values():
|
186 |
+
return {"error": f"Receiver ID '{receiver_id}' not found."}
|
187 |
+
# Generate a unique message ID
|
188 |
+
message_id = self._generate_id()
|
189 |
+
# Store the message in the inbox
|
190 |
+
self.inbox.append({receiver_id: message})
|
191 |
+
self.message_count += 1
|
192 |
+
return {
|
193 |
+
"sent_status": True,
|
194 |
+
"message_id": message_id,
|
195 |
+
"message": f"Message sent to '{receiver_id}' successfully.",
|
196 |
+
}
|
197 |
+
|
198 |
+
def delete_message(self, receiver_id: str) -> Dict[str, Union[bool, str]]:
|
199 |
+
"""
|
200 |
+
Delete the latest message sent to a receiver.
|
201 |
+
Args:
|
202 |
+
receiver_id (str): User ID of the user to send the message to.
|
203 |
+
message_id (int): ID of the message to be deleted.
|
204 |
+
Returns:
|
205 |
+
deleted_status (bool): True if the message was deleted successfully, False otherwise.
|
206 |
+
message_id (int): ID of the deleted message.
|
207 |
+
message (str): A message describing the result of the deletion attempt.
|
208 |
+
"""
|
209 |
+
if not self.current_user:
|
210 |
+
return {"error": "No user is currently logged in."}
|
211 |
+
|
212 |
+
# Loop through the inbox in reverse order to find the first message sent to the receiver
|
213 |
+
for message in self.inbox[::-1]:
|
214 |
+
receiver, _ = list(message.items())[0]
|
215 |
+
if receiver == receiver_id:
|
216 |
+
self.inbox.remove(message)
|
217 |
+
return {
|
218 |
+
"deleted_status": True,
|
219 |
+
"message_id": receiver,
|
220 |
+
"message": f"Receiver {receiver_id}'s first message deleted successfully.",
|
221 |
+
}
|
222 |
+
return {"error": f"Receiver ID {receiver_id} not found."}
|
223 |
+
|
224 |
+
def view_messages_sent(self) -> Dict[str, Union[Dict[str, List[str]], str]]:
|
225 |
+
"""
|
226 |
+
View all historical messages sent by the current user.
|
227 |
+
|
228 |
+
Returns:
|
229 |
+
messages (Dict): Dictionary of messages grouped by receiver An example of the messages dictionary is {"USR001":["Hello"],"USR002":["World"]}.
|
230 |
+
|
231 |
+
"""
|
232 |
+
if not self.current_user:
|
233 |
+
return {"error": "No user is currently logged in."}
|
234 |
+
# Dictionary to collect messages grouped by receiver
|
235 |
+
sent_messages = {}
|
236 |
+
# Loop through the inbox and collect messages sent by the current user
|
237 |
+
for message in self.inbox:
|
238 |
+
receiver, message_content = list(message.items())[0]
|
239 |
+
if receiver not in sent_messages:
|
240 |
+
sent_messages[receiver] = [message_content]
|
241 |
+
else:
|
242 |
+
sent_messages[receiver].append(message_content)
|
243 |
+
return {"messages": sent_messages}
|
244 |
+
|
245 |
+
def add_contact(self, user_name: str) -> Dict[str, Union[bool, str]]:
|
246 |
+
"""
|
247 |
+
Add a contact to the workspace.
|
248 |
+
Args:
|
249 |
+
user_name (str): User name of contact to be added.
|
250 |
+
Returns:
|
251 |
+
added_status (bool): True if the contact was added successfully, False otherwise.
|
252 |
+
user_id (str): User ID of the added contact.
|
253 |
+
message (str): A message describing the result of the addition attempt.
|
254 |
+
"""
|
255 |
+
if user_name in self.user_map:
|
256 |
+
return {"error": f"User name '{user_name}' already exists."}
|
257 |
+
self.user_count += 1
|
258 |
+
user_id = f"USR{str(self.user_count).zfill(3)}"
|
259 |
+
if user_id in self.user_map.values():
|
260 |
+
return {"error": f"User ID '{user_id}' already exists."}
|
261 |
+
self.user_map[user_name] = user_id
|
262 |
+
return {
|
263 |
+
"added_status": True,
|
264 |
+
"user_id": user_id,
|
265 |
+
"message": f"Contact '{user_name}' added successfully.",
|
266 |
+
}
|
267 |
+
|
268 |
+
def search_messages(
|
269 |
+
self, keyword: str
|
270 |
+
) -> Dict[str, Union[List[Dict[str, Union[str, List[str]]]], str]]:
|
271 |
+
"""
|
272 |
+
Search for messages containing a specific keyword.
|
273 |
+
Args:
|
274 |
+
keyword (str): The keyword to search for in messages.
|
275 |
+
Returns:
|
276 |
+
results (List[Dict]): List of dictionaries containing matching messages.
|
277 |
+
- receiver_id (str): User ID of the receiver of the message.
|
278 |
+
- message (str): The message containing the keyword.
|
279 |
+
"""
|
280 |
+
if not self.current_user:
|
281 |
+
return {"error": "No user is currently logged in."}
|
282 |
+
keyword_lower = keyword.lower()
|
283 |
+
results = []
|
284 |
+
# Iterate through the inbox to search for the keyword in messages
|
285 |
+
# for message_id, message_data in self.inbox.items():
|
286 |
+
for message_data in self.inbox:
|
287 |
+
receiver_id, message_content = list(message_data.items())[0]
|
288 |
+
if keyword_lower in message_content.lower():
|
289 |
+
results.append(
|
290 |
+
{
|
291 |
+
"receiver_id": receiver_id,
|
292 |
+
"message": message_content,
|
293 |
+
}
|
294 |
+
)
|
295 |
+
return {"results": results}
|
296 |
+
|
297 |
+
def get_message_stats(self) -> Dict[str, Union[Dict[str, int], str]]:
|
298 |
+
"""
|
299 |
+
Get statistics about messages for the current user.
|
300 |
+
Returns:
|
301 |
+
stats (Dict): Dictionary containing message statistics.
|
302 |
+
- received_count (int): Number of messages received by the current user.
|
303 |
+
- total_contacts (int): Total number of contacts the user has interacted with.
|
304 |
+
"""
|
305 |
+
if not self.current_user:
|
306 |
+
return {"error": "No user is currently logged in."}
|
307 |
+
sent_count = 0
|
308 |
+
received_count = 0
|
309 |
+
contacts = set()
|
310 |
+
# Loop through the inbox to calculate stats
|
311 |
+
for message_data in self.inbox:
|
312 |
+
receiver_id, message_content = list(message_data.items())[0]
|
313 |
+
received_count += 1
|
314 |
+
contacts.add(receiver_id)
|
315 |
+
total_contacts = len(contacts)
|
316 |
+
return {
|
317 |
+
"stats": {
|
318 |
+
"received_count": received_count,
|
319 |
+
"total_contacts": total_contacts,
|
320 |
+
}
|
321 |
+
}
|
multi_turn_eval/func_source_code/posting_api.py
ADDED
@@ -0,0 +1,313 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from copy import deepcopy
|
2 |
+
from typing import Dict, List, Optional, Union
|
3 |
+
|
4 |
+
DEFAULT_STATE = {
|
5 |
+
"username": "john",
|
6 |
+
"password": "john123",
|
7 |
+
"authenticated": False,
|
8 |
+
"tweets": {},
|
9 |
+
"comments": {},
|
10 |
+
"retweets": {},
|
11 |
+
"following_list": ["alice", "bob"],
|
12 |
+
"tweet_counter": 0,
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
class TwitterAPI:
|
17 |
+
def __init__(self):
|
18 |
+
self.username: str
|
19 |
+
self.password: str
|
20 |
+
self.authenticated: bool
|
21 |
+
self.tweets: Dict[int, Dict[str, Union[int, str, List[str]]]]
|
22 |
+
self.comments: Dict[int, List[Dict[str, str]]]
|
23 |
+
self.retweets: Dict[str, List[int]]
|
24 |
+
self.following_list: List[str]
|
25 |
+
# tweet_counter is used to assign unique IDs to tweets, it might not be the same as the length of the tweets list for different scenarios
|
26 |
+
self.tweet_counter: int
|
27 |
+
self._api_description = "This tool belongs to the TwitterAPI, which provides core functionality for posting tweets, retweeting, commenting, and following users on Twitter."
|
28 |
+
|
29 |
+
def _load_scenario(self, scenario: dict, long_context=False) -> None:
|
30 |
+
"""
|
31 |
+
Load a scenario into the TwitterAPI instance.
|
32 |
+
Args:
|
33 |
+
scenario (dict): A dictionary containing Twitter data.
|
34 |
+
"""
|
35 |
+
DEFAULT_STATE_COPY = deepcopy(DEFAULT_STATE)
|
36 |
+
self.username = scenario.get("username", DEFAULT_STATE_COPY["username"])
|
37 |
+
self.password = scenario.get("password", DEFAULT_STATE_COPY["password"])
|
38 |
+
self.authenticated = scenario.get(
|
39 |
+
"authenticated", DEFAULT_STATE_COPY["authenticated"]
|
40 |
+
)
|
41 |
+
self.tweets = scenario.get("tweets", DEFAULT_STATE_COPY["tweets"])
|
42 |
+
self.tweets = {int(k): v for k, v in self.tweets.items()} # Convert tweet keys from string to int from loaded scenario
|
43 |
+
self.comments = scenario.get("comments", DEFAULT_STATE_COPY["comments"])
|
44 |
+
self.retweets = scenario.get("retweets", DEFAULT_STATE_COPY["retweets"])
|
45 |
+
self.following_list = scenario.get(
|
46 |
+
"following_list", DEFAULT_STATE_COPY["following_list"]
|
47 |
+
)
|
48 |
+
self.tweet_counter = scenario.get(
|
49 |
+
"tweet_counter", DEFAULT_STATE_COPY["tweet_counter"]
|
50 |
+
)
|
51 |
+
|
52 |
+
def authenticate_twitter(self, username: str, password: str) -> Dict[str, bool]:
|
53 |
+
"""
|
54 |
+
Authenticate a user with username and password.
|
55 |
+
|
56 |
+
Args:
|
57 |
+
username (str): Username of the user.
|
58 |
+
password (str): Password of the user.
|
59 |
+
Returns:
|
60 |
+
authentication_status (bool): True if authenticated, False otherwise.
|
61 |
+
"""
|
62 |
+
if username == self.username and password == self.password:
|
63 |
+
self.authenticated = True
|
64 |
+
return {"authentication_status": True}
|
65 |
+
return {"authentication_status": False}
|
66 |
+
|
67 |
+
def posting_get_login_status(self) -> Dict[str, Union[bool, str]]:
|
68 |
+
"""
|
69 |
+
Get the login status of the current user.
|
70 |
+
|
71 |
+
Returns:
|
72 |
+
login_status (bool): True if the current user is logged in, False otherwise.
|
73 |
+
"""
|
74 |
+
return {"login_status": bool(self.authenticated)}
|
75 |
+
|
76 |
+
def post_tweet(
|
77 |
+
self, content: str, tags: List[str] = [], mentions: List[str] = []
|
78 |
+
) -> Dict[str, Union[int, str, List[str]]]:
|
79 |
+
"""
|
80 |
+
Post a tweet for the authenticated user.
|
81 |
+
|
82 |
+
Args:
|
83 |
+
content (str): Content of the tweet.
|
84 |
+
tags (List[str]): [Optional] List of tags for the tweet. Tag name should start with #. This is only relevant if the user wants to add tags to the tweet.
|
85 |
+
mentions (List[str]): [Optional] List of users mentioned in the tweet. Mention name should start with @. This is only relevant if the user wants to add mentions to the tweet.
|
86 |
+
Returns:
|
87 |
+
id (int): ID of the posted tweet.
|
88 |
+
username (str): Username of the poster.
|
89 |
+
content (str): Content of the tweet.
|
90 |
+
tags (List[str]): List of tags associated with the tweet.
|
91 |
+
mentions (List[str]): List of users mentioned in the tweet.
|
92 |
+
"""
|
93 |
+
if not self.authenticated:
|
94 |
+
return {"error": "User not authenticated. Please authenticate before posting."}
|
95 |
+
|
96 |
+
tweet = {
|
97 |
+
"id": self.tweet_counter,
|
98 |
+
"username": self.username,
|
99 |
+
"content": content,
|
100 |
+
"tags": tags,
|
101 |
+
"mentions": mentions,
|
102 |
+
}
|
103 |
+
self.tweets[self.tweet_counter] = tweet
|
104 |
+
self.tweet_counter += 1
|
105 |
+
return tweet
|
106 |
+
|
107 |
+
def retweet(self, tweet_id: int) -> Dict[str, str]:
|
108 |
+
"""
|
109 |
+
Retweet a tweet for the authenticated user.
|
110 |
+
|
111 |
+
Args:
|
112 |
+
tweet_id (int): ID of the tweet to retweet.
|
113 |
+
Returns:
|
114 |
+
retweet_status (str): Status of the retweet action.
|
115 |
+
"""
|
116 |
+
if not self.authenticated:
|
117 |
+
return {"error": "User not authenticated. Please authenticate before retweeting."}
|
118 |
+
|
119 |
+
if tweet_id not in self.tweets:
|
120 |
+
return {"error": f"Tweet with ID {tweet_id} not found."}
|
121 |
+
|
122 |
+
if self.username not in self.retweets:
|
123 |
+
self.retweets[self.username] = []
|
124 |
+
|
125 |
+
if tweet_id in self.retweets[self.username]:
|
126 |
+
return {"retweet_status": "Already retweeted"}
|
127 |
+
|
128 |
+
self.retweets[self.username].append(tweet_id)
|
129 |
+
return {"retweet_status": "Successfully retweeted"}
|
130 |
+
|
131 |
+
def comment(self, tweet_id: int, comment_content: str) -> Dict[str, str]:
|
132 |
+
"""
|
133 |
+
Comment on a tweet for the authenticated user.
|
134 |
+
|
135 |
+
Args:
|
136 |
+
tweet_id (int): ID of the tweet to comment on.
|
137 |
+
comment_content (str): Content of the comment.
|
138 |
+
Returns:
|
139 |
+
comment_status (str): Status of the comment action.
|
140 |
+
"""
|
141 |
+
if not self.authenticated:
|
142 |
+
raise {"error": "User not authenticated. Please authenticate before commenting."}
|
143 |
+
|
144 |
+
|
145 |
+
if tweet_id not in self.tweets:
|
146 |
+
return {"error": f"Tweet with ID {tweet_id} not found."}
|
147 |
+
|
148 |
+
if tweet_id not in self.comments:
|
149 |
+
self.comments[tweet_id] = []
|
150 |
+
|
151 |
+
self.comments[tweet_id].append(
|
152 |
+
{"username": self.username, "content": comment_content}
|
153 |
+
)
|
154 |
+
return {"comment_status": "Comment added successfully"}
|
155 |
+
|
156 |
+
def mention(self, tweet_id: int, mentioned_usernames: List[str]) -> Dict[str, str]:
|
157 |
+
"""
|
158 |
+
Mention specified users in a tweet.
|
159 |
+
|
160 |
+
Args:
|
161 |
+
tweet_id (int): ID of the tweet where users are mentioned.
|
162 |
+
mentioned_usernames (List[str]): List of usernames to be mentioned.
|
163 |
+
Returns:
|
164 |
+
mention_status (str): Status of the mention action.
|
165 |
+
"""
|
166 |
+
if tweet_id not in self.tweets:
|
167 |
+
return {"error": f"Tweet with ID {tweet_id} not found."}
|
168 |
+
|
169 |
+
tweet = self.tweets[tweet_id]
|
170 |
+
tweet["mentions"].extend(mentioned_usernames)
|
171 |
+
|
172 |
+
return {"mention_status": "Users mentioned successfully"}
|
173 |
+
|
174 |
+
def follow_user(self, username_to_follow: str) -> Dict[str, bool]:
|
175 |
+
"""
|
176 |
+
Follow a user for the authenticated user.
|
177 |
+
|
178 |
+
Args:
|
179 |
+
username_to_follow (str): Username of the user to follow.
|
180 |
+
Returns:
|
181 |
+
follow_status (bool): True if followed, False if already following.
|
182 |
+
"""
|
183 |
+
if not self.authenticated:
|
184 |
+
return {"error": "User not authenticated. Please authenticate before following."}
|
185 |
+
|
186 |
+
if username_to_follow in self.following_list:
|
187 |
+
return {"follow_status": False}
|
188 |
+
|
189 |
+
self.following_list.append(username_to_follow)
|
190 |
+
return {"follow_status": True}
|
191 |
+
|
192 |
+
def list_all_following(self) -> List[str]:
|
193 |
+
"""
|
194 |
+
List all users that the authenticated user is following.
|
195 |
+
|
196 |
+
Returns:
|
197 |
+
following_list (List[str]): List of all users that the authenticated user is following.
|
198 |
+
"""
|
199 |
+
if not self.authenticated:
|
200 |
+
return {"error": "User not authenticated. Please authenticate before listing following."}
|
201 |
+
|
202 |
+
return self.following_list
|
203 |
+
|
204 |
+
def unfollow_user(self, username_to_unfollow: str) -> Dict[str, bool]:
|
205 |
+
"""
|
206 |
+
Unfollow a user for the authenticated user.
|
207 |
+
|
208 |
+
Args:
|
209 |
+
username_to_unfollow (str): Username of the user to unfollow.
|
210 |
+
Returns:
|
211 |
+
unfollow_status (bool): True if unfollowed, False if not following.
|
212 |
+
"""
|
213 |
+
if not self.authenticated:
|
214 |
+
return {"error": "User not authenticated. Please authenticate before unfollowing."}
|
215 |
+
|
216 |
+
if username_to_unfollow not in self.following_list:
|
217 |
+
return {"unfollow_status": False}
|
218 |
+
|
219 |
+
self.following_list.remove(username_to_unfollow)
|
220 |
+
return {"unfollow_status": True}
|
221 |
+
|
222 |
+
def get_tweet(self, tweet_id: int) -> Dict[str, Union[int, str, List[str]]]:
|
223 |
+
"""
|
224 |
+
Retrieve a specific tweet.
|
225 |
+
|
226 |
+
Args:
|
227 |
+
tweet_id (int): ID of the tweet to retrieve.
|
228 |
+
Returns:
|
229 |
+
id (int): ID of the retrieved tweet.
|
230 |
+
username (str): Username of the tweet's author.
|
231 |
+
content (str): Content of the tweet.
|
232 |
+
tags (List[str]): List of tags associated with the tweet.
|
233 |
+
mentions (List[str]): List of users mentioned in the tweet.
|
234 |
+
"""
|
235 |
+
if tweet_id not in self.tweets:
|
236 |
+
return {"error": f"Tweet with ID {tweet_id} not found."}
|
237 |
+
|
238 |
+
return self.tweets[tweet_id]
|
239 |
+
|
240 |
+
def get_user_tweets(self, username: str) -> List[Dict[str, Union[int, str, List[str]]]]:
|
241 |
+
"""
|
242 |
+
Retrieve all tweets from a specific user.
|
243 |
+
|
244 |
+
Args:
|
245 |
+
username (str): Username of the user whose tweets to retrieve.
|
246 |
+
Returns:
|
247 |
+
user_tweets (List[Dict]): List of dictionaries, each containing tweet information.
|
248 |
+
- id (int): ID of the retrieved tweet.
|
249 |
+
- username (str): Username of the tweet's author.
|
250 |
+
- content (str): Content of the tweet.
|
251 |
+
- tags (List[str]): List of tags associated with the tweet.
|
252 |
+
- mentions (List[str]): List of users mentioned in the tweet.
|
253 |
+
"""
|
254 |
+
return [tweet for tweet in self.tweets.values() if tweet["username"] == username]
|
255 |
+
|
256 |
+
def search_tweets(self, keyword: str) -> List[Dict[str, Union[int, str, List[str]]]]:
|
257 |
+
"""
|
258 |
+
Search for tweets containing a specific keyword.
|
259 |
+
|
260 |
+
Args:
|
261 |
+
keyword (str): Keyword to search for in the content of the tweets.
|
262 |
+
Returns:
|
263 |
+
matching_tweets (List[Dict]): List of dictionaries, each containing tweet information.
|
264 |
+
- id (int): ID of the retrieved tweet.
|
265 |
+
- username (str): Username of the tweet's author.
|
266 |
+
- content (str): Content of the tweet.
|
267 |
+
- tags (List[str]): List of tags associated with the tweet.
|
268 |
+
- mentions (List[str]): List of users mentioned in the tweet.
|
269 |
+
"""
|
270 |
+
return [
|
271 |
+
tweet
|
272 |
+
for tweet in self.tweets.values()
|
273 |
+
if keyword.lower() in tweet["content"].lower()
|
274 |
+
or keyword.lower() in [tag.lower() for tag in tweet["tags"]]
|
275 |
+
]
|
276 |
+
|
277 |
+
def get_tweet_comments(self, tweet_id: int) -> List[Dict[str, str]]:
|
278 |
+
"""
|
279 |
+
Retrieve all comments for a specific tweet.
|
280 |
+
|
281 |
+
Args:
|
282 |
+
tweet_id (int): ID of the tweet to retrieve comments for.
|
283 |
+
Returns:
|
284 |
+
comments (List[Dict]): List of dictionaries, each containing comment information.
|
285 |
+
- username (str): Username of the commenter.
|
286 |
+
- content (str): Content of the comment.
|
287 |
+
"""
|
288 |
+
if tweet_id not in self.tweets:
|
289 |
+
return {"error": f"Tweet with ID {tweet_id} not found."}
|
290 |
+
return self.comments.get(tweet_id, [])
|
291 |
+
|
292 |
+
def get_user_stats(self, username: str) -> Dict[str, int]:
|
293 |
+
"""
|
294 |
+
Get statistics for a specific user.
|
295 |
+
|
296 |
+
Args:
|
297 |
+
username (str): Username of the user to get statistics for.
|
298 |
+
Returns:
|
299 |
+
tweet_count (int): Number of tweets posted by the user.
|
300 |
+
following_count (int): Number of users the specified user is following.
|
301 |
+
retweet_count (int): Number of retweets made by the user.
|
302 |
+
"""
|
303 |
+
tweet_count = len(
|
304 |
+
[tweet for tweet in self.tweets.values() if tweet["username"] == username]
|
305 |
+
)
|
306 |
+
following_count = len(self.following_list) if username == self.username else 0
|
307 |
+
retweet_count = len(self.retweets.get(username, []))
|
308 |
+
|
309 |
+
return {
|
310 |
+
"tweet_count": tweet_count,
|
311 |
+
"following_count": following_count,
|
312 |
+
"retweet_count": retweet_count,
|
313 |
+
}
|
multi_turn_eval/func_source_code/ticket_api.py
ADDED
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from copy import deepcopy
|
2 |
+
from typing import Dict, List, Optional, Union
|
3 |
+
|
4 |
+
DEFAULT_STATE = {
|
5 |
+
"ticket_queue": [],
|
6 |
+
"ticket_counter": 1,
|
7 |
+
"current_user": None,
|
8 |
+
}
|
9 |
+
|
10 |
+
|
11 |
+
class TicketAPI:
|
12 |
+
"""
|
13 |
+
A class representing the Ticket API for managing support tickets.
|
14 |
+
|
15 |
+
This class provides methods for creating, retrieving, and managing
|
16 |
+
support tickets within a ticketing system. It maintains a queue of
|
17 |
+
tickets and handles ticket-related operations such as creation,
|
18 |
+
status updates, and retrieval.
|
19 |
+
|
20 |
+
Attributes:
|
21 |
+
ticket_queue (List[Dict[str, Union[int, str]]]): A list of ticket dictionaries.
|
22 |
+
ticket_counter (int): A counter for generating unique ticket IDs.
|
23 |
+
current_user (Optional[str]): The currently authenticated user.
|
24 |
+
"""
|
25 |
+
|
26 |
+
def __init__(self):
|
27 |
+
"""
|
28 |
+
Initialize the TicketAPI instance.
|
29 |
+
"""
|
30 |
+
self.ticket_queue: List[Dict[str, Union[int, str]]]
|
31 |
+
self.ticket_counter: int
|
32 |
+
self.current_user: Optional[str]
|
33 |
+
self._api_description = "This tool belongs to the ticketing system that is part of a company, which allows users to create, view, and manage support business tickets."
|
34 |
+
|
35 |
+
def _load_scenario(self, scenario: dict, long_context=False) -> None:
|
36 |
+
"""
|
37 |
+
Load a scenario into the ticket queue.
|
38 |
+
|
39 |
+
Args:
|
40 |
+
scenario (Dict): A dictionary containing ticket data.
|
41 |
+
"""
|
42 |
+
DEFAULT_STATE_COPY = deepcopy(DEFAULT_STATE)
|
43 |
+
self.ticket_queue = scenario.get("ticket_queue", DEFAULT_STATE_COPY["ticket_queue"])
|
44 |
+
self.ticket_counter = scenario.get(
|
45 |
+
"ticket_counter", DEFAULT_STATE_COPY["ticket_counter"]
|
46 |
+
)
|
47 |
+
self.current_user = scenario.get("current_user", DEFAULT_STATE_COPY["current_user"])
|
48 |
+
|
49 |
+
def create_ticket(
|
50 |
+
self, title: str, description: str = "", priority: int = 1
|
51 |
+
) -> Dict[str, Union[int, str]]:
|
52 |
+
"""
|
53 |
+
Create a ticket in the system and queue it.
|
54 |
+
|
55 |
+
Args:
|
56 |
+
title (str): Title of the ticket.
|
57 |
+
description (str): Description of the ticket. Defaults to an empty string.
|
58 |
+
priority (int): Priority of the ticket, from 1 to 5. Defaults to 1. 5 is the highest priority.
|
59 |
+
|
60 |
+
Returns:
|
61 |
+
id (int): Unique identifier of the ticket.
|
62 |
+
title (str): Title of the ticket.
|
63 |
+
description (str): Description of the ticket.
|
64 |
+
status (str): Current status of the ticket.
|
65 |
+
priority (int): Priority level of the ticket.
|
66 |
+
"""
|
67 |
+
if not self.current_user:
|
68 |
+
return {"error": "User not authenticated. Please log in to create a ticket."}
|
69 |
+
if priority < 1 or priority > 5:
|
70 |
+
return {"error": "Invalid priority. Priority must be between 1 and 5."}
|
71 |
+
ticket = {
|
72 |
+
"id": self.ticket_counter,
|
73 |
+
"title": title,
|
74 |
+
"description": description,
|
75 |
+
"status": "Open",
|
76 |
+
"priority": priority,
|
77 |
+
"created_by": self.current_user,
|
78 |
+
}
|
79 |
+
self.ticket_queue.append(ticket)
|
80 |
+
self.ticket_counter += 1
|
81 |
+
return ticket
|
82 |
+
|
83 |
+
def get_ticket(self, ticket_id: int) -> Dict[str, Union[int, str]]:
|
84 |
+
"""
|
85 |
+
Get a specific ticket by its ID.
|
86 |
+
|
87 |
+
Args:
|
88 |
+
ticket_id (int): ID of the ticket to retrieve.
|
89 |
+
|
90 |
+
Returns:
|
91 |
+
id (int): Unique identifier of the ticket.
|
92 |
+
title (str): Title of the ticket.
|
93 |
+
description (str): Description of the ticket.
|
94 |
+
status (str): Current status of the ticket.
|
95 |
+
priority (int): Priority level of the ticket.
|
96 |
+
created_by (str): Username of the ticket creator.
|
97 |
+
"""
|
98 |
+
ticket = self._find_ticket(ticket_id)
|
99 |
+
if not ticket:
|
100 |
+
return {"error": f"Ticket with ID {ticket_id} not found."}
|
101 |
+
return ticket
|
102 |
+
|
103 |
+
def close_ticket(self, ticket_id: int) -> Dict[str, str]:
|
104 |
+
"""
|
105 |
+
Close a ticket.
|
106 |
+
|
107 |
+
Args:
|
108 |
+
ticket_id (int): ID of the ticket to be closed.
|
109 |
+
|
110 |
+
Returns:
|
111 |
+
status (str): Status of the close operation.
|
112 |
+
"""
|
113 |
+
ticket = self._find_ticket(ticket_id)
|
114 |
+
if not ticket:
|
115 |
+
return {"error": f"Ticket with ID {ticket_id} not found."}
|
116 |
+
if ticket["status"] == "Closed":
|
117 |
+
return {"error": f"Ticket with ID {ticket_id} is already closed."}
|
118 |
+
ticket["status"] = "Closed"
|
119 |
+
return {"status": f"Ticket {ticket_id} has been closed successfully."}
|
120 |
+
|
121 |
+
def resolve_ticket(self, ticket_id: int, resolution: str) -> Dict[str, str]:
|
122 |
+
"""
|
123 |
+
Resolve a ticket with a resolution.
|
124 |
+
|
125 |
+
Args:
|
126 |
+
ticket_id (int): ID of the ticket to be resolved.
|
127 |
+
resolution (str): Resolution details for the ticket.
|
128 |
+
|
129 |
+
Returns:
|
130 |
+
status (str): Status of the resolve operation.
|
131 |
+
"""
|
132 |
+
ticket = self._find_ticket(ticket_id)
|
133 |
+
if not ticket:
|
134 |
+
return {"error": f"Ticket with ID {ticket_id} not found."}
|
135 |
+
if ticket["status"] == "Resolved":
|
136 |
+
return {"error": f"Ticket with ID {ticket_id} is already resolved."}
|
137 |
+
ticket["status"] = "Resolved"
|
138 |
+
ticket["resolution"] = resolution
|
139 |
+
return {"status": f"Ticket {ticket_id} has been resolved successfully."}
|
140 |
+
|
141 |
+
def edit_ticket(
|
142 |
+
self, ticket_id: int, updates: Dict[str, Optional[Union[str, int]]]
|
143 |
+
) -> Dict[str, str]:
|
144 |
+
"""
|
145 |
+
Modify the details of an existing ticket.
|
146 |
+
|
147 |
+
Args:
|
148 |
+
ticket_id (int): ID of the ticket to be changed.
|
149 |
+
updates (Dict): Dictionary containing the fields to be updated.
|
150 |
+
- title (str) : [Optional] New title for the ticket.
|
151 |
+
- description (str): [Optional] New description for the ticket.
|
152 |
+
- status (str): [Optional] New status for the ticket.
|
153 |
+
- priority (int): [Optional] New priority for the ticket.
|
154 |
+
|
155 |
+
Returns:
|
156 |
+
status (str): Status of the update operation.
|
157 |
+
"""
|
158 |
+
ticket = self._find_ticket(ticket_id)
|
159 |
+
if not ticket:
|
160 |
+
return {"error": f"Ticket with ID {ticket_id} not found."}
|
161 |
+
|
162 |
+
valid_fields = {"title", "description", "status", "priority"}
|
163 |
+
invalid_fields = set(updates.keys()) - valid_fields
|
164 |
+
if invalid_fields:
|
165 |
+
return {"error": f"Invalid fields for update: {', '.join(invalid_fields)}"}
|
166 |
+
|
167 |
+
for key, value in updates.items():
|
168 |
+
if value is not None:
|
169 |
+
ticket[key] = value
|
170 |
+
|
171 |
+
return {"status": f"Ticket {ticket_id} has been updated successfully."}
|
172 |
+
|
173 |
+
def _find_ticket(self, ticket_id: int) -> Optional[Dict[str, Union[int, str]]]:
|
174 |
+
"""
|
175 |
+
Find a ticket by its ID.
|
176 |
+
|
177 |
+
Args:
|
178 |
+
ticket_id (int): ID of the ticket to find.
|
179 |
+
|
180 |
+
Returns:
|
181 |
+
id (int): Unique identifier of the ticket.
|
182 |
+
title (str): Title of the ticket.
|
183 |
+
description (str): Description of the ticket.
|
184 |
+
status (str): Current status of the ticket.
|
185 |
+
priority (int): Priority level of the ticket.
|
186 |
+
created_by (str): Username of the ticket creator.
|
187 |
+
"""
|
188 |
+
for ticket in self.ticket_queue:
|
189 |
+
if ticket["id"] == ticket_id:
|
190 |
+
return ticket
|
191 |
+
return None
|
192 |
+
|
193 |
+
def ticket_login(self, username: str, password: str) -> Dict[str, bool]:
|
194 |
+
"""
|
195 |
+
Authenticate a user for ticket system.
|
196 |
+
|
197 |
+
Args:
|
198 |
+
username (str): Username of the user.
|
199 |
+
password (str): Password of the user.
|
200 |
+
|
201 |
+
Returns:
|
202 |
+
success (bool): True if login was successful, False otherwise.
|
203 |
+
"""
|
204 |
+
# In a real system, you would validate the credentials against a database
|
205 |
+
if username and password: # Simplified authentication
|
206 |
+
self.current_user = username
|
207 |
+
return {"success": True}
|
208 |
+
return {"success": False}
|
209 |
+
|
210 |
+
def ticket_get_login_status(self) -> Dict[str, bool]:
|
211 |
+
"""
|
212 |
+
Get the username of the currently authenticated user.
|
213 |
+
|
214 |
+
Returns:
|
215 |
+
username (bool): True if a user is logged in, False otherwise.
|
216 |
+
|
217 |
+
"""
|
218 |
+
return {"username": bool(self.current_user)}
|
219 |
+
|
220 |
+
def logout(self) -> Dict[str, bool]:
|
221 |
+
"""
|
222 |
+
Log out the current user.
|
223 |
+
|
224 |
+
Returns:
|
225 |
+
success (bool): True if logout was successful, False otherwise.
|
226 |
+
"""
|
227 |
+
if self.current_user:
|
228 |
+
self.current_user = None
|
229 |
+
return {"success": True}
|
230 |
+
return {"success": False}
|
231 |
+
|
232 |
+
def get_user_tickets(
|
233 |
+
self, status: Optional[str] = None
|
234 |
+
) -> List[Dict[str, Union[int, str]]]:
|
235 |
+
"""
|
236 |
+
Get all tickets created by the current user, optionally filtered by status.
|
237 |
+
|
238 |
+
Args:
|
239 |
+
status (str): [Optional] Status to filter tickets by. If None, return all tickets.
|
240 |
+
|
241 |
+
Returns:
|
242 |
+
id (int): Unique identifier of the ticket.
|
243 |
+
title (str): Title of the ticket.
|
244 |
+
description (str): Description of the ticket.
|
245 |
+
status (str): Current status of the ticket.
|
246 |
+
priority (int): Priority level of the ticket.
|
247 |
+
created_by (str): Username of the ticket
|
248 |
+
"""
|
249 |
+
if not self.current_user:
|
250 |
+
return [{"error": "User not authenticated. Please log in to view tickets."}]
|
251 |
+
|
252 |
+
user_tickets = [
|
253 |
+
ticket
|
254 |
+
for ticket in self.ticket_queue
|
255 |
+
if ticket["created_by"] == self.current_user
|
256 |
+
]
|
257 |
+
|
258 |
+
if status:
|
259 |
+
user_tickets = [
|
260 |
+
ticket
|
261 |
+
for ticket in user_tickets
|
262 |
+
if ticket["status"].lower() == status.lower()
|
263 |
+
]
|
264 |
+
|
265 |
+
return user_tickets
|
multi_turn_eval/func_source_code/trading_bot.py
ADDED
@@ -0,0 +1,734 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
from copy import deepcopy
|
3 |
+
from datetime import datetime, time, timedelta
|
4 |
+
from typing import Dict, List, Optional, Union
|
5 |
+
|
6 |
+
from .long_context import (
|
7 |
+
AUTOMOBILE_EXTENSION,
|
8 |
+
MA_5_EXTENSION,
|
9 |
+
MA_20_EXTENSION,
|
10 |
+
ORDER_DETAIL_EXTENSION,
|
11 |
+
TECHNOLOGY_EXTENSION,
|
12 |
+
TRANSACTION_HISTORY_EXTENSION,
|
13 |
+
WATCH_LIST_EXTENSION,
|
14 |
+
)
|
15 |
+
|
16 |
+
CURRENT_TIME = datetime(2024, 9, 1, 10, 30)
|
17 |
+
|
18 |
+
DEFAULT_STATE = {
|
19 |
+
"orders": {
|
20 |
+
12345: {
|
21 |
+
"id": 12345,
|
22 |
+
"order_type": "Buy",
|
23 |
+
"symbol": "AAPL",
|
24 |
+
"price": 210.65,
|
25 |
+
"amount": 10,
|
26 |
+
"status": "Completed",
|
27 |
+
},
|
28 |
+
12446: {
|
29 |
+
"id": 12446,
|
30 |
+
"order_type": "Sell",
|
31 |
+
"symbol": "GOOG",
|
32 |
+
"price": 2840.56,
|
33 |
+
"amount": 5,
|
34 |
+
"status": "Pending",
|
35 |
+
},
|
36 |
+
},
|
37 |
+
"account_info": {
|
38 |
+
"account_id": 12345,
|
39 |
+
"balance": 10000.0,
|
40 |
+
"binding_card": 1974202140965533,
|
41 |
+
},
|
42 |
+
"authenticated": False,
|
43 |
+
"market_status": "Closed",
|
44 |
+
"order_counter": 12446,
|
45 |
+
"stocks": {
|
46 |
+
"AAPL": {
|
47 |
+
"price": 227.16,
|
48 |
+
"percent_change": 0.17,
|
49 |
+
"volume": 2.552,
|
50 |
+
"MA(5)": 227.11,
|
51 |
+
"MA(20)": 227.09,
|
52 |
+
},
|
53 |
+
"GOOG": {
|
54 |
+
"price": 2840.34,
|
55 |
+
"percent_change": 0.24,
|
56 |
+
"volume": 1.123,
|
57 |
+
"MA(5)": 2835.67,
|
58 |
+
"MA(20)": 2842.15,
|
59 |
+
},
|
60 |
+
"TSLA": {
|
61 |
+
"price": 667.92,
|
62 |
+
"percent_change": -0.12,
|
63 |
+
"volume": 1.654,
|
64 |
+
"MA(5)": 671.15,
|
65 |
+
"MA(20)": 668.20,
|
66 |
+
},
|
67 |
+
"MSFT": {
|
68 |
+
"price": 310.23,
|
69 |
+
"percent_change": 0.09,
|
70 |
+
"volume": 3.234,
|
71 |
+
"MA(5)": 309.88,
|
72 |
+
"MA(20)": 310.11,
|
73 |
+
},
|
74 |
+
"NVDA": {
|
75 |
+
"price": 220.34,
|
76 |
+
"percent_change": 0.34,
|
77 |
+
"volume": 1.234,
|
78 |
+
"MA(5)": 220.45,
|
79 |
+
"MA(20)": 220.67,
|
80 |
+
},
|
81 |
+
"ALPH": {
|
82 |
+
"price": 1320.45,
|
83 |
+
"percent_change": -0.08,
|
84 |
+
"volume": 1.567,
|
85 |
+
"MA(5)": 1321.12,
|
86 |
+
"MA(20)": 1325.78,
|
87 |
+
},
|
88 |
+
"OMEG": {
|
89 |
+
"price": 457.23,
|
90 |
+
"percent_change": 0.12,
|
91 |
+
"volume": 2.345,
|
92 |
+
"MA(5)": 456.78,
|
93 |
+
"MA(20)": 458.12,
|
94 |
+
},
|
95 |
+
"QUAS": {
|
96 |
+
"price": 725.89,
|
97 |
+
"percent_change": -0.03,
|
98 |
+
"volume": 1.789,
|
99 |
+
"MA(5)": 726.45,
|
100 |
+
"MA(20)": 728.00,
|
101 |
+
},
|
102 |
+
"NEPT": {
|
103 |
+
"price": 88.34,
|
104 |
+
"percent_change": 0.19,
|
105 |
+
"volume": 0.654,
|
106 |
+
"MA(5)": 88.21,
|
107 |
+
"MA(20)": 88.67,
|
108 |
+
},
|
109 |
+
"SYNX": {
|
110 |
+
"price": 345.67,
|
111 |
+
"percent_change": 0.11,
|
112 |
+
"volume": 2.112,
|
113 |
+
"MA(5)": 345.34,
|
114 |
+
"MA(20)": 346.12,
|
115 |
+
},
|
116 |
+
"ZETA": {
|
117 |
+
"price": 22.09,
|
118 |
+
"percent_change": -0.05,
|
119 |
+
"volume": 0.789,
|
120 |
+
"MA(5)": 22.12,
|
121 |
+
"MA(20)": 22.34,
|
122 |
+
},
|
123 |
+
},
|
124 |
+
"watch_list": ["NVDA"],
|
125 |
+
"transaction_history": [],
|
126 |
+
"random_seed": 1053520,
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
class TradingBot:
|
131 |
+
"""
|
132 |
+
A class representing a trading bot for executing stock trades and managing a trading account.
|
133 |
+
|
134 |
+
Attributes:
|
135 |
+
orders (Dict[int, Dict[str, Union[str, float, int]]]): A dictionary of orders for purchasing and selling of stock, keyed by order ID.
|
136 |
+
account_info (Dict[str, Union[int, float]]): Information about the trading account.
|
137 |
+
authenticated (bool): Whether the user is currently authenticated.
|
138 |
+
market_status (str): The current status of the market ('Open' or 'Closed').
|
139 |
+
order_counter (int): A counter for generating unique order IDs.
|
140 |
+
stocks (Dict[str, Dict[str, Union[float, int]]]): Information about various stocks.
|
141 |
+
watch_list (List[str]): A list of stock symbols being watched.
|
142 |
+
transaction_history (List[Dict[str, Union[str, float, int]]]): A history of trading account related transactions.
|
143 |
+
"""
|
144 |
+
|
145 |
+
def __init__(self):
|
146 |
+
"""
|
147 |
+
Initialize the TradingBot instance.
|
148 |
+
"""
|
149 |
+
self.orders: Dict[int, Dict[str, Union[str, float, int]]]
|
150 |
+
self.account_info: Dict[str, Union[int, float]]
|
151 |
+
self.authenticated: bool
|
152 |
+
self.market_status: str
|
153 |
+
self.order_counter: int
|
154 |
+
self.stocks: Dict[str, Dict[str, Union[float, int]]]
|
155 |
+
self.watch_list: List[str]
|
156 |
+
self.transaction_history: List[Dict[str, Union[str, float, int]]]
|
157 |
+
self._api_description = "This tool belongs to the trading system, which allows users to trade stocks, manage their account, and view stock information."
|
158 |
+
|
159 |
+
def _load_scenario(self, scenario: dict, long_context=False) -> None:
|
160 |
+
"""
|
161 |
+
Load a scenario into the TradingBot.
|
162 |
+
|
163 |
+
Args:
|
164 |
+
scenario (dict): A scenario dictionary containing data to load.
|
165 |
+
"""
|
166 |
+
DEFAULT_STATE_COPY = deepcopy(DEFAULT_STATE)
|
167 |
+
self.orders = scenario.get("orders", DEFAULT_STATE_COPY["orders"])
|
168 |
+
# Convert all string keys that can be interpreted as integers to integer keys
|
169 |
+
self.orders = {
|
170 |
+
int(k) if isinstance(k, str) and k.isdigit() else k: v
|
171 |
+
for k, v in self.orders.items()
|
172 |
+
}
|
173 |
+
self.account_info = scenario.get("account_info", DEFAULT_STATE_COPY["account_info"])
|
174 |
+
self.authenticated = scenario.get(
|
175 |
+
"authenticated", DEFAULT_STATE_COPY["authenticated"]
|
176 |
+
)
|
177 |
+
self.market_status = scenario.get(
|
178 |
+
"market_status", DEFAULT_STATE_COPY["market_status"]
|
179 |
+
)
|
180 |
+
self.order_counter = scenario.get(
|
181 |
+
"order_counter", DEFAULT_STATE_COPY["order_counter"]
|
182 |
+
) # Start counter from the next order ID
|
183 |
+
self.stocks = scenario.get("stocks", DEFAULT_STATE_COPY["stocks"])
|
184 |
+
self.watch_list = scenario.get("watch_list", DEFAULT_STATE_COPY["watch_list"])
|
185 |
+
self.transaction_history = scenario.get(
|
186 |
+
"transaction_history", DEFAULT_STATE_COPY["transaction_history"]
|
187 |
+
)
|
188 |
+
self.long_context = long_context
|
189 |
+
self._random = random.Random(
|
190 |
+
(scenario.get("random_seed", DEFAULT_STATE_COPY["random_seed"]))
|
191 |
+
)
|
192 |
+
|
193 |
+
def _generate_transaction_timestamp(self) -> str:
|
194 |
+
"""
|
195 |
+
Generate a timestamp for a transaction.
|
196 |
+
|
197 |
+
Returns:
|
198 |
+
timestamp (str): A formatted timestamp string.
|
199 |
+
"""
|
200 |
+
# Define the start and end dates for the range
|
201 |
+
start_date = CURRENT_TIME
|
202 |
+
end_date = CURRENT_TIME + timedelta(days=1)
|
203 |
+
|
204 |
+
start_timestamp = int(start_date.timestamp())
|
205 |
+
end_timestamp = int(end_date.timestamp())
|
206 |
+
|
207 |
+
# Generate a random timestamp within the range
|
208 |
+
random_timestamp = self._random.randint(start_timestamp, end_timestamp)
|
209 |
+
|
210 |
+
# Convert the random timestamp to a datetime object
|
211 |
+
random_date = datetime.fromtimestamp(random_timestamp)
|
212 |
+
|
213 |
+
return random_date.strftime("%Y-%m-%d %H:%M:%S")
|
214 |
+
|
215 |
+
def get_current_time(self) -> Dict[str, str]:
|
216 |
+
"""
|
217 |
+
Get the current time.
|
218 |
+
|
219 |
+
Returns:
|
220 |
+
current_time (str): Current time in HH:MM AM/PM format.
|
221 |
+
"""
|
222 |
+
return {"current_time": CURRENT_TIME.strftime("%I:%M %p")}
|
223 |
+
|
224 |
+
def update_market_status(self, current_time_str: str) -> Dict[str, str]:
|
225 |
+
"""
|
226 |
+
Update the market status based on the current time.
|
227 |
+
|
228 |
+
Args:
|
229 |
+
current_time_str (str): Current time in HH:MM AM/PM format.
|
230 |
+
|
231 |
+
Returns:
|
232 |
+
status (str): Status of the market. [Enum]: ["Open", "Closed"]
|
233 |
+
"""
|
234 |
+
market_open_time = time(9, 30) # Market opens at 9:30 AM
|
235 |
+
market_close_time = time(16, 0) # Market closes at 4:00 PM
|
236 |
+
|
237 |
+
current_time = datetime.strptime(current_time_str, "%I:%M %p").time()
|
238 |
+
|
239 |
+
if market_open_time <= current_time <= market_close_time:
|
240 |
+
self.market_status = "Open"
|
241 |
+
return {"status": "Open"}
|
242 |
+
else:
|
243 |
+
self.market_status = "Closed"
|
244 |
+
return {"status": "Closed"}
|
245 |
+
|
246 |
+
def get_symbol_by_name(self, name: str) -> Dict[str, str]:
|
247 |
+
"""
|
248 |
+
Get the symbol of a stock by company name.
|
249 |
+
|
250 |
+
Args:
|
251 |
+
name (str): Name of the company.
|
252 |
+
|
253 |
+
Returns:
|
254 |
+
symbol (str): Symbol of the stock or "Stock not found" if not available.
|
255 |
+
"""
|
256 |
+
symbol_map = {
|
257 |
+
"Apple": "AAPL",
|
258 |
+
"Google": "GOOG",
|
259 |
+
"Tesla": "TSLA",
|
260 |
+
"Microsoft": "MSFT",
|
261 |
+
"Nvidia": "NVDA",
|
262 |
+
"Zeta Corp": "ZETA",
|
263 |
+
"Alpha Tech": "ALPH",
|
264 |
+
"Omega Industries": "OMEG",
|
265 |
+
"Quasar Ltd.": "QUAS",
|
266 |
+
"Neptune Systems": "NEPT",
|
267 |
+
"Synex Solutions": "SYNX",
|
268 |
+
"Amazon": "AMZN",
|
269 |
+
}
|
270 |
+
|
271 |
+
return {"symbol": symbol_map.get(name, "Stock not found")}
|
272 |
+
|
273 |
+
def get_stock_info(self, symbol: str) -> Dict[str, Union[float, int, str]]:
|
274 |
+
"""
|
275 |
+
Get the details of a stock.
|
276 |
+
|
277 |
+
Args:
|
278 |
+
symbol (str): Symbol that uniquely identifies the stock.
|
279 |
+
|
280 |
+
Returns:
|
281 |
+
price (float): Current price of the stock.
|
282 |
+
percent_change (float): Percentage change in stock price.
|
283 |
+
volume (float): Trading volume of the stock.
|
284 |
+
MA(5) (float): 5-day Moving Average of the stock.
|
285 |
+
MA(20) (float): 20-day Moving Average of the stock.
|
286 |
+
"""
|
287 |
+
if symbol not in self.stocks:
|
288 |
+
return {"error": f"Stock with symbol '{symbol}' not found."}
|
289 |
+
if self.long_context:
|
290 |
+
stock = self.stocks[symbol].copy()
|
291 |
+
stock["MA(5)"] = MA_5_EXTENSION
|
292 |
+
stock["MA(20)"] = MA_20_EXTENSION
|
293 |
+
return stock
|
294 |
+
return self.stocks[symbol]
|
295 |
+
|
296 |
+
def get_order_details(self, order_id: int) -> Dict[str, Union[str, float, int]]:
|
297 |
+
"""
|
298 |
+
Get the details of an order.
|
299 |
+
|
300 |
+
Args:
|
301 |
+
order_id (int): ID of the order.
|
302 |
+
|
303 |
+
Returns:
|
304 |
+
id (int): ID of the order.
|
305 |
+
order_type (str): Type of the order.
|
306 |
+
symbol (str): Symbol of the stock in the order.
|
307 |
+
price (float): Price at which the order was placed.
|
308 |
+
amount (int): Number of shares in the order.
|
309 |
+
status (str): Current status of the order. [Enum]: ["Open", "Pending", "Completed", "Cancelled"]
|
310 |
+
"""
|
311 |
+
if order_id not in self.orders:
|
312 |
+
return {
|
313 |
+
"error": f"Order with ID {order_id} not found."
|
314 |
+
+ "Here is the list of orders_id: "
|
315 |
+
+ str(list(self.orders.keys()))
|
316 |
+
}
|
317 |
+
|
318 |
+
if self.long_context:
|
319 |
+
order = self.orders[order_id].copy()
|
320 |
+
symbol = order["symbol"]
|
321 |
+
|
322 |
+
formatted_extension = {}
|
323 |
+
for key, value in ORDER_DETAIL_EXTENSION.items():
|
324 |
+
try:
|
325 |
+
formatted_extension[key] = value.format(symbol=symbol)
|
326 |
+
except KeyError as e:
|
327 |
+
return {"error": f"KeyError during formatting: {str(e)}"}
|
328 |
+
|
329 |
+
# Add formatted extension to the order metadata
|
330 |
+
order["metadata"] = formatted_extension
|
331 |
+
return order
|
332 |
+
|
333 |
+
return self.orders[order_id]
|
334 |
+
|
335 |
+
def cancel_order(self, order_id: int) -> Dict[str, Union[int, str]]:
|
336 |
+
"""
|
337 |
+
Cancel an order.
|
338 |
+
|
339 |
+
Args:
|
340 |
+
order_id (int): ID of the order to cancel.
|
341 |
+
|
342 |
+
Returns:
|
343 |
+
order_id (int): ID of the cancelled order.
|
344 |
+
status (str): New status of the order after cancellation attempt.
|
345 |
+
"""
|
346 |
+
if order_id not in self.orders:
|
347 |
+
return {"error": f"Order with ID {order_id} not found."}
|
348 |
+
if self.orders[order_id]["status"] == "Completed":
|
349 |
+
return {"error": f"Can't cancel order {order_id}. Order is already completed."}
|
350 |
+
self.orders[order_id]["status"] = "Cancelled"
|
351 |
+
return {"order_id": order_id, "status": "Cancelled"}
|
352 |
+
|
353 |
+
def place_order(
|
354 |
+
self, order_type: str, symbol: str, price: float, amount: int
|
355 |
+
) -> Dict[str, Union[int, str, float]]:
|
356 |
+
"""
|
357 |
+
Place an order.
|
358 |
+
|
359 |
+
Args:
|
360 |
+
order_type (str): Type of the order (Buy/Sell).
|
361 |
+
symbol (str): Symbol of the stock to trade.
|
362 |
+
price (float): Price at which to place the order.
|
363 |
+
amount (int): Number of shares to trade.
|
364 |
+
|
365 |
+
Returns:
|
366 |
+
order_id (int): ID of the newly placed order.
|
367 |
+
order_type (str): Type of the order (Buy/Sell).
|
368 |
+
status (str): Initial status of the order.
|
369 |
+
price (float): Price at which the order was placed.
|
370 |
+
amount (int): Number of shares in the order.
|
371 |
+
"""
|
372 |
+
if not self.authenticated:
|
373 |
+
return {"error": "User not authenticated. Please log in to place an order."}
|
374 |
+
if symbol not in self.stocks:
|
375 |
+
return {"error": f"Invalid stock symbol: {symbol}"}
|
376 |
+
if price <= 0 or amount <= 0:
|
377 |
+
return {"error": "Price and amount must be positive values."}
|
378 |
+
price = float(price)
|
379 |
+
order_id = self.order_counter
|
380 |
+
self.orders[order_id] = {
|
381 |
+
"id": order_id,
|
382 |
+
"order_type": order_type,
|
383 |
+
"symbol": symbol,
|
384 |
+
"price": price,
|
385 |
+
"amount": amount,
|
386 |
+
"status": "Open",
|
387 |
+
}
|
388 |
+
self.order_counter += 1
|
389 |
+
# We return the status as "Pending" to indicate that the order has been placed but not yet executed
|
390 |
+
# When polled later, the status will show as 'Open'
|
391 |
+
# This is to simulate the delay between placing an order and it being executed
|
392 |
+
return {
|
393 |
+
"order_id": order_id,
|
394 |
+
"order_type": order_type,
|
395 |
+
"status": "Pending",
|
396 |
+
"price": price,
|
397 |
+
"amount": amount,
|
398 |
+
}
|
399 |
+
|
400 |
+
def make_transaction(
|
401 |
+
self, account_id: int, xact_type: str, amount: float
|
402 |
+
) -> Dict[str, Union[str, float]]:
|
403 |
+
"""
|
404 |
+
Make a deposit or withdrawal based on specified amount.
|
405 |
+
|
406 |
+
Args:
|
407 |
+
account_id (int): ID of the account.
|
408 |
+
xact_type (str): Transaction type (deposit or withdrawal).
|
409 |
+
amount (float): Amount to deposit or withdraw.
|
410 |
+
|
411 |
+
Returns:
|
412 |
+
status (str): Status of the transaction.
|
413 |
+
new_balance (float): Updated account balance after the transaction.
|
414 |
+
"""
|
415 |
+
if not self.authenticated:
|
416 |
+
return {"error": "User not authenticated. Please log in to make a transaction."}
|
417 |
+
if self.market_status != "Open":
|
418 |
+
return {"error": "Market is closed. Transactions are not allowed."}
|
419 |
+
if account_id != self.account_info["account_id"]:
|
420 |
+
return {"error": f"Account with ID {account_id} not found."}
|
421 |
+
if amount <= 0:
|
422 |
+
return {"error": "Transaction amount must be positive."}
|
423 |
+
|
424 |
+
if xact_type == "deposit":
|
425 |
+
self.account_info["balance"] += amount
|
426 |
+
self.transaction_history.append(
|
427 |
+
{
|
428 |
+
"type": "deposit",
|
429 |
+
"amount": amount,
|
430 |
+
"timestamp": self._generate_transaction_timestamp(),
|
431 |
+
}
|
432 |
+
)
|
433 |
+
return {
|
434 |
+
"status": "Deposit successful",
|
435 |
+
"new_balance": self.account_info["balance"],
|
436 |
+
}
|
437 |
+
elif xact_type == "withdrawal":
|
438 |
+
if amount > self.account_info["balance"]:
|
439 |
+
return {"error": "Insufficient funds for withdrawal."}
|
440 |
+
self.account_info["balance"] -= amount
|
441 |
+
self.transaction_history.append(
|
442 |
+
{
|
443 |
+
"type": "withdrawal",
|
444 |
+
"amount": amount,
|
445 |
+
"timestamp": self._generate_transaction_timestamp(),
|
446 |
+
}
|
447 |
+
)
|
448 |
+
return {
|
449 |
+
"status": "Withdrawal successful",
|
450 |
+
"new_balance": self.account_info["balance"],
|
451 |
+
}
|
452 |
+
return {"error": "Invalid transaction type. Use 'deposit' or 'withdrawal'."}
|
453 |
+
|
454 |
+
def get_account_info(self) -> Dict[str, Union[int, float]]:
|
455 |
+
"""
|
456 |
+
Get account information.
|
457 |
+
|
458 |
+
Returns:
|
459 |
+
account_id (int): ID of the account.
|
460 |
+
balance (float): Current balance of the account.
|
461 |
+
binding_card (int): Card number associated with the account.
|
462 |
+
"""
|
463 |
+
if not self.authenticated:
|
464 |
+
return {
|
465 |
+
"error": "User not authenticated. Please log in to view account information."
|
466 |
+
}
|
467 |
+
return self.account_info
|
468 |
+
|
469 |
+
def trading_login(self, username: str, password: str) -> Dict[str, str]:
|
470 |
+
"""
|
471 |
+
Handle user login.
|
472 |
+
|
473 |
+
Args:
|
474 |
+
username (str): Username for authentication.
|
475 |
+
password (str): Password for authentication.
|
476 |
+
|
477 |
+
Returns:
|
478 |
+
status (str): Login status message.
|
479 |
+
"""
|
480 |
+
if self.authenticated:
|
481 |
+
return {"status": "Already logged in"}
|
482 |
+
# In a real system, we would validate the username and password here
|
483 |
+
self.authenticated = True
|
484 |
+
return {"status": "Logged in successfully"}
|
485 |
+
|
486 |
+
def trading_get_login_status(self) -> Dict[str, bool]:
|
487 |
+
"""
|
488 |
+
Get the login status.
|
489 |
+
|
490 |
+
Returns:
|
491 |
+
status (bool): Login status.
|
492 |
+
"""
|
493 |
+
|
494 |
+
return {"status": bool(self.authenticated)}
|
495 |
+
|
496 |
+
def trading_logout(self) -> Dict[str, str]:
|
497 |
+
"""
|
498 |
+
Handle user logout for trading system.
|
499 |
+
|
500 |
+
Returns:
|
501 |
+
status (str): Logout status message.
|
502 |
+
"""
|
503 |
+
if not self.authenticated:
|
504 |
+
return {"status": "No user is currently logged in"}
|
505 |
+
self.authenticated = False
|
506 |
+
return {"status": "Logged out successfully"}
|
507 |
+
|
508 |
+
def fund_account(self, amount: float) -> Dict[str, Union[str, float]]:
|
509 |
+
"""
|
510 |
+
Fund the account with the specified amount.
|
511 |
+
|
512 |
+
Args:
|
513 |
+
amount (float): Amount to fund the account with.
|
514 |
+
|
515 |
+
Returns:
|
516 |
+
status (str): Status of the funding operation.
|
517 |
+
new_balance (float): Updated account balance after funding.
|
518 |
+
"""
|
519 |
+
if not self.authenticated:
|
520 |
+
return {"error": "User not authenticated. Please log in to fund the account."}
|
521 |
+
if amount <= 0:
|
522 |
+
return {"error": "Funding amount must be positive."}
|
523 |
+
self.account_info["balance"] += amount
|
524 |
+
self.transaction_history.append(
|
525 |
+
{"type": "deposit", "amount": amount, "timestamp": self._generate_transaction_timestamp()}
|
526 |
+
)
|
527 |
+
return {
|
528 |
+
"status": "Account funded successfully",
|
529 |
+
"new_balance": self.account_info["balance"],
|
530 |
+
}
|
531 |
+
|
532 |
+
def remove_stock_from_watchlist(self, symbol: str) -> Dict[str, str]:
|
533 |
+
"""
|
534 |
+
Remove a stock from the watchlist.
|
535 |
+
|
536 |
+
Args:
|
537 |
+
symbol (str): Symbol of the stock to remove.
|
538 |
+
|
539 |
+
Returns:
|
540 |
+
status (str): Status of the removal operation.
|
541 |
+
"""
|
542 |
+
if not self.authenticated:
|
543 |
+
return {
|
544 |
+
"error": "User not authenticated. Please log in to modify the watchlist."
|
545 |
+
}
|
546 |
+
if symbol not in self.watch_list:
|
547 |
+
return {"error": f"Stock {symbol} not found in watchlist."}
|
548 |
+
self.watch_list.remove(symbol)
|
549 |
+
return {"status": f"Stock {symbol} removed from watchlist successfully."}
|
550 |
+
|
551 |
+
def get_watchlist(self) -> Dict[str, List[str]]:
|
552 |
+
"""
|
553 |
+
Get the watchlist.
|
554 |
+
|
555 |
+
Returns:
|
556 |
+
watchlist (List[str]): List of stock symbols in the watchlist.
|
557 |
+
"""
|
558 |
+
if not self.authenticated:
|
559 |
+
return ["Error: User not authenticated. Please log in to view the watchlist."]
|
560 |
+
|
561 |
+
if self.long_context:
|
562 |
+
watch_list = self.watch_list.copy()
|
563 |
+
watch_list.extend(WATCH_LIST_EXTENSION)
|
564 |
+
return watch_list
|
565 |
+
return {"watchlist": self.watch_list}
|
566 |
+
|
567 |
+
def get_order_history(self) -> Dict[str, List[Dict[str, Union[str, int, float]]]]:
|
568 |
+
"""
|
569 |
+
Get the stock order ID history.
|
570 |
+
|
571 |
+
Returns:
|
572 |
+
order_history (List[int]): List of orders ID in the order history.
|
573 |
+
"""
|
574 |
+
if not self.authenticated:
|
575 |
+
return [
|
576 |
+
{
|
577 |
+
"error": "User not authenticated. Please log in to view order history."
|
578 |
+
}
|
579 |
+
]
|
580 |
+
|
581 |
+
return {"history": list(self.orders.keys())}
|
582 |
+
|
583 |
+
def get_transaction_history(
|
584 |
+
self, start_date: Optional[str] = None, end_date: Optional[str] = None
|
585 |
+
) -> Dict[str, List[Dict[str, Union[str, float]]]]:
|
586 |
+
"""
|
587 |
+
Get the transaction history within a specified date range.
|
588 |
+
|
589 |
+
Args:
|
590 |
+
start_date (str): [Optional] Start date for the history (format: 'YYYY-MM-DD').
|
591 |
+
end_date (str): [Optional] End date for the history (format: 'YYYY-MM-DD').
|
592 |
+
|
593 |
+
Returns:
|
594 |
+
transaction_history (List[Dict]): List of transactions within the specified date range.
|
595 |
+
- type (str): Type of transaction. [Enum]: ["deposit", "withdrawal"]
|
596 |
+
- amount (float): Amount involved in the transaction.
|
597 |
+
- timestamp (str): Timestamp of the transaction, formatted as 'YYYY-MM-DD HH:MM:SS'.
|
598 |
+
"""
|
599 |
+
if not self.authenticated:
|
600 |
+
return [
|
601 |
+
{
|
602 |
+
"error": "User not authenticated. Please log in to view transaction history."
|
603 |
+
}
|
604 |
+
]
|
605 |
+
|
606 |
+
if start_date:
|
607 |
+
start = datetime.strptime(start_date, "%Y-%m-%d")
|
608 |
+
else:
|
609 |
+
start = datetime.min
|
610 |
+
|
611 |
+
if end_date:
|
612 |
+
end = datetime.strptime(end_date, "%Y-%m-%d")
|
613 |
+
else:
|
614 |
+
end = datetime.max
|
615 |
+
|
616 |
+
filtered_history = [
|
617 |
+
transaction
|
618 |
+
for transaction in self.transaction_history
|
619 |
+
if start
|
620 |
+
<= datetime.strptime(transaction["timestamp"], "%Y-%m-%d %H:%M:%S")
|
621 |
+
<= end
|
622 |
+
]
|
623 |
+
|
624 |
+
if self.long_context:
|
625 |
+
filtered_history.extend(TRANSACTION_HISTORY_EXTENSION)
|
626 |
+
|
627 |
+
return {"transaction_history": filtered_history}
|
628 |
+
|
629 |
+
def update_stock_price(
|
630 |
+
self, symbol: str, new_price: float
|
631 |
+
) -> Dict[str, Union[str, float]]:
|
632 |
+
"""
|
633 |
+
Update the price of a stock.
|
634 |
+
|
635 |
+
Args:
|
636 |
+
symbol (str): Symbol of the stock to update.
|
637 |
+
new_price (float): New price of the stock.
|
638 |
+
|
639 |
+
Returns:
|
640 |
+
symbol (str): Symbol of the updated stock.
|
641 |
+
old_price (float): Previous price of the stock.
|
642 |
+
new_price (float): Updated price of the stock.
|
643 |
+
"""
|
644 |
+
if symbol not in self.stocks:
|
645 |
+
return {"error": f"Stock with symbol '{symbol}' not found."}
|
646 |
+
if new_price <= 0:
|
647 |
+
return {"error": "New price must be a positive value."}
|
648 |
+
|
649 |
+
old_price = self.stocks[symbol]["price"]
|
650 |
+
self.stocks[symbol]["price"] = new_price
|
651 |
+
self.stocks[symbol]["percent_change"] = ((new_price - old_price) / old_price) * 100
|
652 |
+
|
653 |
+
return {"symbol": symbol, "old_price": old_price, "new_price": new_price}
|
654 |
+
|
655 |
+
# below contains a list of functions to be nested
|
656 |
+
def get_available_stocks(self, sector: str) -> Dict[str, List[str]]:
|
657 |
+
"""
|
658 |
+
Get a list of stock symbols in the given sector.
|
659 |
+
|
660 |
+
Args:
|
661 |
+
sector (str): The sector to retrieve stocks from (e.g., 'Technology').
|
662 |
+
|
663 |
+
Returns:
|
664 |
+
stock_list (List[str]): List of stock symbols in the specified sector.
|
665 |
+
"""
|
666 |
+
sector_map = {
|
667 |
+
"Technology": ["AAPL", "GOOG", "MSFT", "NVDA"],
|
668 |
+
"Automobile": ["TSLA", "F", "GM"],
|
669 |
+
}
|
670 |
+
|
671 |
+
if self.long_context:
|
672 |
+
sector_map["Technology"].extend(TECHNOLOGY_EXTENSION)
|
673 |
+
sector_map["Automobile"].extend(AUTOMOBILE_EXTENSION)
|
674 |
+
return {"stock_list": sector_map.get(sector, [])}
|
675 |
+
|
676 |
+
def filter_stocks_by_price(
|
677 |
+
self, stocks: List[str], min_price: float, max_price: float
|
678 |
+
) -> Dict[str, List[str]]:
|
679 |
+
"""
|
680 |
+
Filter stocks based on a price range.
|
681 |
+
|
682 |
+
Args:
|
683 |
+
stocks (List[str]): List of stock symbols to filter.
|
684 |
+
min_price (float): Minimum stock price.
|
685 |
+
max_price (float): Maximum stock price.
|
686 |
+
|
687 |
+
Returns:
|
688 |
+
filtered_stocks (List[str]): Filtered list of stock symbols within the price range.
|
689 |
+
"""
|
690 |
+
filtered_stocks = [
|
691 |
+
symbol
|
692 |
+
for symbol in stocks
|
693 |
+
if self.stocks.get(symbol, {}).get("price", 0) >= min_price
|
694 |
+
and self.stocks.get(symbol, {}).get("price", 0) <= max_price
|
695 |
+
]
|
696 |
+
return {"filtered_stocks": filtered_stocks}
|
697 |
+
|
698 |
+
def add_to_watchlist(self, stock: str) -> Dict[str, List[str]]:
|
699 |
+
"""
|
700 |
+
Add a stock to the watchlist.
|
701 |
+
|
702 |
+
Args:
|
703 |
+
stock (str): the stock symbol to add to the watchlist.
|
704 |
+
|
705 |
+
Returns:
|
706 |
+
symbol (str): the symbol that were successfully added to the watchlist.
|
707 |
+
"""
|
708 |
+
if stock not in self.watch_list:
|
709 |
+
if stock in self.stocks: # Ensure symbol is valid
|
710 |
+
self.watch_list.append(stock)
|
711 |
+
return {"symbol": self.watch_list}
|
712 |
+
|
713 |
+
def notify_price_change(self, stocks: List[str], threshold: float) -> Dict[str, str]:
|
714 |
+
"""
|
715 |
+
Notify if there is a significant price change in the stocks.
|
716 |
+
|
717 |
+
Args:
|
718 |
+
stocks (List[str]): List of stock symbols to check.
|
719 |
+
threshold (float): Percentage change threshold to trigger a notification.
|
720 |
+
|
721 |
+
Returns:
|
722 |
+
notification (str): Notification message about the price changes.
|
723 |
+
"""
|
724 |
+
changed_stocks = [
|
725 |
+
symbol
|
726 |
+
for symbol in stocks
|
727 |
+
if symbol in self.stocks
|
728 |
+
and abs(self.stocks[symbol]["percent_change"]) >= threshold
|
729 |
+
]
|
730 |
+
|
731 |
+
if changed_stocks:
|
732 |
+
return {"notification": f"Stocks {', '.join(changed_stocks)} have significant price changes."}
|
733 |
+
else:
|
734 |
+
return {"notification": "No significant price changes in the selected stocks."}
|