langroid 0.16.7__py3-none-any.whl → 0.17.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- langroid/agent/base.py +45 -21
- langroid/agent/chat_agent.py +22 -14
- langroid/agent/chat_document.py +22 -13
- langroid/agent/tool_message.py +11 -11
- langroid/agent/tools/file_tools.py +234 -0
- langroid/agent/xml_tool_message.py +178 -45
- langroid/utils/constants.py +2 -0
- langroid/utils/git_utils.py +251 -0
- langroid/utils/system.py +78 -0
- {langroid-0.16.7.dist-info → langroid-0.17.0.dist-info}/METADATA +6 -3
- {langroid-0.16.7.dist-info → langroid-0.17.0.dist-info}/RECORD +14 -89
- pyproject.toml +3 -2
- langroid/agent/md_tool_message_grammar.py +0 -455
- langroid/agent/tools/code_file_tool_parse.py +0 -150
- langroid/agent/tools/code_file_tool_pyparsing.py +0 -194
- langroid/agent/tools/code_file_tool_pyparsing2.py +0 -199
- langroid/agent/tools/extract_tool.py +0 -96
- langroid/agent/tools/formatted_model_custom.py +0 -150
- langroid/agent/tools/formatted_model_custom2.py +0 -168
- langroid/agent/tools/formatted_model_custom3.py +0 -279
- langroid/agent/tools/formatted_model_custom4.py +0 -395
- langroid/agent/tools/formatted_model_jinja.py +0 -133
- langroid/agent/tools/formatted_model_jinja.py-e +0 -122
- langroid/agent/tools/formatted_model_jinja2.py +0 -145
- langroid/agent/tools/formatted_model_jinja2.py-e +0 -135
- langroid/agent/tools/formatted_model_lark.py +0 -0
- langroid/agent/tools/formatted_model_lark2.py +0 -168
- langroid/agent/tools/formatted_model_parse.py +0 -105
- langroid/agent/tools/formatted_model_parse.py-e +0 -98
- langroid/agent/tools/formatted_model_parse2.py +0 -113
- langroid/agent/tools/formatted_model_parse2.py-e +0 -109
- langroid/agent/tools/formatted_model_parse3.py +0 -114
- langroid/agent/tools/formatted_model_parse3.py-e +0 -110
- langroid/agent/tools/formatted_model_parsimon.py +0 -194
- langroid/agent/tools/formatted_model_parsimon.py-e +0 -186
- langroid/agent/tools/formatted_model_pyparsing.py +0 -169
- langroid/agent/tools/formatted_model_pyparsing.py-e +0 -149
- langroid/agent/tools/formatted_model_pyparsing2.py +0 -159
- langroid/agent/tools/formatted_model_pyparsing2.py-e +0 -143
- langroid/agent/tools/formatted_model_pyparsing3.py +0 -133
- langroid/agent/tools/formatted_model_pyparsing3.py-e +0 -121
- langroid/agent/tools/formatted_model_pyparsing4.py +0 -213
- langroid/agent/tools/formatted_model_pyparsing4.py-e +0 -176
- langroid/agent/tools/formatted_model_pyparsing5.py +0 -173
- langroid/agent/tools/formatted_model_pyparsing5.py-e +0 -142
- langroid/agent/tools/formatted_model_regex.py +0 -246
- langroid/agent/tools/formatted_model_regex.py-e +0 -248
- langroid/agent/tools/formatted_model_regex2.py +0 -250
- langroid/agent/tools/formatted_model_regex2.py-e +0 -253
- langroid/agent/tools/formatted_model_tatsu.py +0 -172
- langroid/agent/tools/formatted_model_tatsu.py-e +0 -160
- langroid/agent/tools/formatted_model_template.py +0 -217
- langroid/agent/tools/formatted_model_template.py-e +0 -200
- langroid/agent/tools/formatted_model_xml.py +0 -178
- langroid/agent/tools/formatted_model_xml2.py +0 -178
- langroid/agent/tools/formatted_model_xml3.py +0 -132
- langroid/agent/tools/formatted_model_xml4.py +0 -130
- langroid/agent/tools/formatted_model_xml5.py +0 -130
- langroid/agent/tools/formatted_model_xml6.py +0 -113
- langroid/agent/tools/formatted_model_xml7.py +0 -117
- langroid/agent/tools/formatted_model_xml8.py +0 -164
- langroid/agent/tools/generator_tool.py +0 -20
- langroid/agent/tools/generic_tool.py +0 -165
- langroid/agent/tools/generic_tool_tatsu.py +0 -275
- langroid/agent/tools/grammar_based_model.py +0 -132
- langroid/agent/tools/grammar_based_model.py-e +0 -128
- langroid/agent/tools/grammar_based_model_lark.py +0 -156
- langroid/agent/tools/grammar_based_model_lark.py-e +0 -153
- langroid/agent/tools/grammar_based_model_parse.py +0 -86
- langroid/agent/tools/grammar_based_model_parse.py-e +0 -80
- langroid/agent/tools/grammar_based_model_parsimonious.py +0 -129
- langroid/agent/tools/grammar_based_model_parsimonious.py-e +0 -120
- langroid/agent/tools/grammar_based_model_pyparsing.py +0 -105
- langroid/agent/tools/grammar_based_model_pyparsing.py-e +0 -103
- langroid/agent/tools/grammar_based_model_regex.py +0 -139
- langroid/agent/tools/grammar_based_model_regex.py-e +0 -130
- langroid/agent/tools/grammar_based_model_regex2.py +0 -124
- langroid/agent/tools/grammar_based_model_regex2.py-e +0 -116
- langroid/agent/tools/grammar_based_model_tatsu.py +0 -80
- langroid/agent/tools/grammar_based_model_tatsu.py-e +0 -77
- langroid/agent/tools/lark_earley_example.py +0 -135
- langroid/agent/tools/lark_earley_example.py-e +0 -117
- langroid/agent/tools/lark_example.py +0 -72
- langroid/agent/tools/note_tool.py +0 -0
- langroid/agent/tools/parse_example.py +0 -76
- langroid/agent/tools/parse_example2.py +0 -87
- langroid/agent/tools/parse_example3.py +0 -42
- langroid/agent/tools/parse_test.py +0 -791
- langroid/agent/tools/run_python_code.py +0 -60
- {langroid-0.16.7.dist-info → langroid-0.17.0.dist-info}/LICENSE +0 -0
- {langroid-0.16.7.dist-info → langroid-0.17.0.dist-info}/WHEEL +0 -0
@@ -1,14 +1,13 @@
|
|
1
1
|
langroid/__init__.py,sha256=z_fCOLQJPOw3LLRPBlFB5-2HyCjpPgQa4m4iY5Fvb8Y,1800
|
2
2
|
langroid/agent/__init__.py,sha256=ll0Cubd2DZ-fsCMl7e10hf9ZjFGKzphfBco396IKITY,786
|
3
|
-
langroid/agent/base.py,sha256=
|
3
|
+
langroid/agent/base.py,sha256=hX_IGnEWcIhFGaLyhkZr6HWe_nQ4y6ERko-2H9mTkhM,64047
|
4
4
|
langroid/agent/batch.py,sha256=QZdlt1563hx4l3AXrCaGovE-PNG93M3DsvQAbDzdiS8,13705
|
5
5
|
langroid/agent/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
langroid/agent/callbacks/chainlit.py,sha256=Qedk1-CBCgo9PdaIa7AboLBFCTgAMg9q5nGmoqpZ378,22050
|
7
|
-
langroid/agent/chat_agent.py,sha256=
|
8
|
-
langroid/agent/chat_document.py,sha256=
|
7
|
+
langroid/agent/chat_agent.py,sha256=m1fs-XsBzusRicwBETId3dpTQG8qEaS0yym_o4mfAI0,49931
|
8
|
+
langroid/agent/chat_document.py,sha256=FZ_PkeKU5OVp1IUlMvspfqxIXzlyd7J_F32DSYrxQ7E,17651
|
9
9
|
langroid/agent/helpers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
langroid/agent/junk,sha256=LxfuuW7Cijsg0szAzT81OjWWv1PMNI-6w_-DspVIO2s,339
|
11
|
-
langroid/agent/md_tool_message_grammar.py,sha256=shr5Tk_U69Peywg64KOAzUb63xUGiDO5PNCraRkrI10,14940
|
12
11
|
langroid/agent/openai_assistant.py,sha256=2rjCZw45ysNBEGNzQM4uf0bTC4KkatGYAWcVcW4xcek,34337
|
13
12
|
langroid/agent/special/__init__.py,sha256=gik_Xtm_zV7U9s30Mn8UX3Gyuy4jTjQe9zjiE3HWmEo,1273
|
14
13
|
langroid/agent/special/doc_chat_agent.py,sha256=r1uPunYf2lQcqYQ4fsD8Q5gB9cZyf7cn0KPcR_CLtrU,59065
|
@@ -35,94 +34,19 @@ langroid/agent/special/sql/utils/tools.py,sha256=vFYysk6Vi7HJjII8B4RitA3pt_z3gkS
|
|
35
34
|
langroid/agent/special/table_chat_agent.py,sha256=d9v2wsblaRx7oMnKhLV7uO_ujvk9gh59pSGvBXyeyNc,9659
|
36
35
|
langroid/agent/structured_message.py,sha256=y7pud1EgRNeTFZlJmBkLmwME3yQJ_IYik-Xds9kdZbY,282
|
37
36
|
langroid/agent/task.py,sha256=GDnP24wsoXSZbwlG0g-OmKWM_pY-G4KGUgnCEbCsrYM,84660
|
38
|
-
langroid/agent/tool_message.py,sha256=
|
37
|
+
langroid/agent/tool_message.py,sha256=jkN7uq7YwUC_wBcSCNUYjrB_His2YCfQay_lqIa4Tww,10498
|
39
38
|
langroid/agent/tools/__init__.py,sha256=IMgCte-_ZIvCkozGQmvMqxIw7_nKLKzD78ccJL1bnQU,804
|
40
|
-
langroid/agent/tools/code_file_tool_parse.py,sha256=nuoXc7eD-bYxG55mf2tZ4o-wL1ZzUymK795c5rZTVx8,4786
|
41
|
-
langroid/agent/tools/code_file_tool_pyparsing.py,sha256=ZUJGeWZJ1UA353Q7eDOK30JlEH0UetPsUwJsXPE5GMo,6336
|
42
|
-
langroid/agent/tools/code_file_tool_pyparsing2.py,sha256=DE-uWtyIFBh-G2Nj43LXEO8X15vF-lLVHc15Xj4jjhQ,5761
|
43
39
|
langroid/agent/tools/duckduckgo_search_tool.py,sha256=NhsCaGZkdv28nja7yveAhSK_w6l_Ftym8agbrdzqgfo,1935
|
44
|
-
langroid/agent/tools/
|
45
|
-
langroid/agent/tools/formatted_model_custom.py,sha256=Zbqim8SxuIWscbIrOAlTrQzL4ziJMtmqFvT9uh_3DIE,4278
|
46
|
-
langroid/agent/tools/formatted_model_custom2.py,sha256=hQ1AsZSqCCPb1K2N5Oa-XDTPmsNsLZSTpj-J6EzJrMY,5547
|
47
|
-
langroid/agent/tools/formatted_model_custom3.py,sha256=rtI9n2HXlaCb4xEYHUH3qHCuMwDLjOS0rrPi8ialYdk,9491
|
48
|
-
langroid/agent/tools/formatted_model_custom4.py,sha256=Uz4GRzqZrtt6jv2UZ1xs9O3qtQHqVTAL70EMFYLeoig,13122
|
49
|
-
langroid/agent/tools/formatted_model_jinja.py,sha256=oeohyL_mKL0iSLpqd0C53f1pFr36Hv7EpLe9U-3ucmc,3496
|
50
|
-
langroid/agent/tools/formatted_model_jinja.py-e,sha256=JICiI_L4sLRFGDpndzSrCwcoZGFZo4oWIx2rXcVP7ws,3451
|
51
|
-
langroid/agent/tools/formatted_model_jinja2.py,sha256=rA3Gtmu25vzsNfVZgetJm9negqdc0bVL8jgCDtliV1s,3516
|
52
|
-
langroid/agent/tools/formatted_model_jinja2.py-e,sha256=6ux26NPP0GkwMaDdFwBFdVLYv0gxBO3YNrf3_hRBoro,3447
|
53
|
-
langroid/agent/tools/formatted_model_lark.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
|
-
langroid/agent/tools/formatted_model_lark2.py,sha256=Or1oSSNB9RM52ctnQmiDinDbmDrXUYwbLyFmBwWtGAk,4603
|
55
|
-
langroid/agent/tools/formatted_model_parse.py,sha256=Azo1bO1DjMThVsYjxYk-80mdK86MGO6ixcrbec1KDig,2938
|
56
|
-
langroid/agent/tools/formatted_model_parse.py-e,sha256=D0gA8I7paSiAWrZwujcyhJDjil4Y4G0rBTqV03Qh82o,2907
|
57
|
-
langroid/agent/tools/formatted_model_parse2.py,sha256=hCnmgiJML9yJYKpLJCquRQj5GzgEoCGwAw5Fw4FRFDs,2721
|
58
|
-
langroid/agent/tools/formatted_model_parse2.py-e,sha256=F2avICGPMBYd731bmhreBym1hsKbswjeVpAWf0W5rzQ,2709
|
59
|
-
langroid/agent/tools/formatted_model_parse3.py,sha256=x43Ag3jvdQ7Xn_m7Qc5QAL8EYVDzQxuL9wQB282FuHQ,2741
|
60
|
-
langroid/agent/tools/formatted_model_parse3.py-e,sha256=s3YxHF89qlBoS4v_m6PdEEFfN8ATNlgBHkkb4fkZ4tc,2729
|
61
|
-
langroid/agent/tools/formatted_model_parsimon.py,sha256=2blN778yEc9-G-R6Xp84-yIJi3TnqmYgkTVEULOsGTk,5476
|
62
|
-
langroid/agent/tools/formatted_model_parsimon.py-e,sha256=y9YD_llbrAGOlAhWZ4GPsb7za0k1hko7Fp_TBQixrKU,5447
|
63
|
-
langroid/agent/tools/formatted_model_pyparsing.py,sha256=FjVWnd6nxDd494Fp0-xZzupsvXvWYwhVhi0vYSv4C5E,4578
|
64
|
-
langroid/agent/tools/formatted_model_pyparsing.py-e,sha256=iNNNaMR0tUGp42XwCzNZ3swQQJkd7mlZZqFjNchrlk4,4458
|
65
|
-
langroid/agent/tools/formatted_model_pyparsing2.py,sha256=pvWxRVcqmGL9H01fdhi2ZzQwh2Urw-j8LBs3p4x9O4w,4339
|
66
|
-
langroid/agent/tools/formatted_model_pyparsing2.py-e,sha256=eSzxvapLgCDlD04Z7Abol6rje5DW9OAPUhzCkKcE_Yg,4322
|
67
|
-
langroid/agent/tools/formatted_model_pyparsing3.py,sha256=9mSqTce4gV1vefrUTfHFDwebWr-PVbNT1TQA4GJ06xI,3547
|
68
|
-
langroid/agent/tools/formatted_model_pyparsing3.py-e,sha256=V5eLPsw67IgEkTW1jRndS38jcd-2USsDfpkVY2nocIQ,3565
|
69
|
-
langroid/agent/tools/formatted_model_pyparsing4.py,sha256=UEUTCtgAHjmOSNweLEMMfoeTrM4VD6vUxI3TSh3DeJc,6393
|
70
|
-
langroid/agent/tools/formatted_model_pyparsing4.py-e,sha256=advqwI1g651LGzTedpj8E_gQLisz3Kgf5wVtib2z3tQ,6029
|
71
|
-
langroid/agent/tools/formatted_model_pyparsing5.py,sha256=2Dbfv1IVqdynb4xEDOS45eczPndwJTtvUsrGdJslTko,4462
|
72
|
-
langroid/agent/tools/formatted_model_pyparsing5.py-e,sha256=QIqwcHMWOGRFrna_4Q2OOcB_xT4ZOXOEAjZFD4Omzws,4257
|
73
|
-
langroid/agent/tools/formatted_model_regex.py,sha256=6pEyjKqh7K-KF409aJJj2UBIa0XotaRmT6eldSPMUZw,6252
|
74
|
-
langroid/agent/tools/formatted_model_regex.py-e,sha256=ijFGHBKFIC2elMHGxaViva8sPi1HZNtJUeTyQE9jb0o,6400
|
75
|
-
langroid/agent/tools/formatted_model_regex2.py,sha256=ws4q-3WehEfIlwxDfEVoFJsjz3gCRc-uiiKPWPcymio,6482
|
76
|
-
langroid/agent/tools/formatted_model_regex2.py-e,sha256=ceymTjZAqa-t0oRkuWkYwNZ6b2_2ssP4ChIZgM1AFgI,6703
|
77
|
-
langroid/agent/tools/formatted_model_tatsu.py,sha256=xvWiVrRIPdLKbc0jaj8saiBjpBNCDo9ay1adKaZOcZ0,4716
|
78
|
-
langroid/agent/tools/formatted_model_tatsu.py-e,sha256=yBPktA5oHqCurnHnanjtYtF4aXQZ0JO1_Y-AhSTXSSE,4646
|
79
|
-
langroid/agent/tools/formatted_model_template.py,sha256=139SM0ciPwOjvt9AbFiYl-fhQgSyt3a5xkYOkfy4DSc,6388
|
80
|
-
langroid/agent/tools/formatted_model_template.py-e,sha256=yKcP6xXIaAfg3cbnn2Vq4HpmLj1FPTS6jmdHzrzxui8,6311
|
81
|
-
langroid/agent/tools/formatted_model_xml.py,sha256=PPmWw_eSGoxOs6Z8MSPa5WuC4WPUVAjnfNRdgNyXHMw,5170
|
82
|
-
langroid/agent/tools/formatted_model_xml2.py,sha256=FEz4fL6o3foL-EFpcnxOsas0ZsSTW_TpP21cHRLTwls,5224
|
83
|
-
langroid/agent/tools/formatted_model_xml3.py,sha256=AqmC13oZAwrxhlGk_EQvpnl1tyAc3RLGnpYyhnJX8MM,4052
|
84
|
-
langroid/agent/tools/formatted_model_xml4.py,sha256=LpWsV-3Dyyfe0tq2c2nxK9g0M4CtBXVIyqq0YNoe70c,3901
|
85
|
-
langroid/agent/tools/formatted_model_xml5.py,sha256=HoG1d_1JZq3-PWJeCncyR_Yxn9sPdrR38e5qSzs0mAc,4165
|
86
|
-
langroid/agent/tools/formatted_model_xml6.py,sha256=QUVwQXs5K1dLu4aZ3g8uHG02hIRqU1f3byZUc2hObbM,3401
|
87
|
-
langroid/agent/tools/formatted_model_xml7.py,sha256=7hdB1seQ5scdTLY9pjR-h7tFJP-ijc-9kAxYqPp_LRk,3553
|
88
|
-
langroid/agent/tools/formatted_model_xml8.py,sha256=z3eyNKWK_dvVxDT5o8bEc58hC058QqsxqxarEazhPTA,5259
|
89
|
-
langroid/agent/tools/generator_tool.py,sha256=y0fB0ZObjA0b3L0uSTtrqRCKHDUR95arBftqiUeKD2o,663
|
90
|
-
langroid/agent/tools/generic_tool.py,sha256=kSv8i2iHuaRBelnqX3zIuUUTuOSg7TCPYu9labQpKQg,5563
|
91
|
-
langroid/agent/tools/generic_tool_tatsu.py,sha256=G1rVpR6Xl3Y0B2R-KAYovsxwIYRj5dyw0J-NTdPuvkI,9315
|
40
|
+
langroid/agent/tools/file_tools.py,sha256=GjPB5YDILucYapElnvvoYpGJuZQ25ecLs2REv7edPEo,7292
|
92
41
|
langroid/agent/tools/google_search_tool.py,sha256=y7b-3FtgXf0lfF4AYxrZ3K5pH2dhidvibUOAGBE--WI,1456
|
93
|
-
langroid/agent/tools/grammar_based_model.py,sha256=Nj0YtY89ErfEhviOyXmfxKMGBke-wEEaPrpSTGYBN7w,4224
|
94
|
-
langroid/agent/tools/grammar_based_model.py-e,sha256=13zU8Id-imokzL93OxkUYQ0BNeCN2ykYCZEgyoC_T7M,4217
|
95
|
-
langroid/agent/tools/grammar_based_model_lark.py,sha256=oGRQtkwIrMzYTB9Ac8m1w1p4C30FOejC1Ipey6aDExM,4607
|
96
|
-
langroid/agent/tools/grammar_based_model_lark.py-e,sha256=xZrfXJZbMRj2u-um0tAcnuDh-TPPIzoyKKMmOm16hyo,4596
|
97
|
-
langroid/agent/tools/grammar_based_model_parse.py,sha256=ZmQ_hqnxxgnxJyz6mkypqVCp-6f40xvQKrHu1g3fUlg,1958
|
98
|
-
langroid/agent/tools/grammar_based_model_parse.py-e,sha256=iycM-FqxjkpZhzrlgrL0aDzMVLI9oZ0z6rVZRO6Gvqo,1944
|
99
|
-
langroid/agent/tools/grammar_based_model_parsimonious.py,sha256=mSbOKAs9FtCb9hGGSYFPOiEqnfW6J44c-hiG2m5Fbq4,4050
|
100
|
-
langroid/agent/tools/grammar_based_model_parsimonious.py-e,sha256=kEvodQI-FjoteXCsR_aUhGuLHcSeqDz7uFtfq4_HZt4,3842
|
101
|
-
langroid/agent/tools/grammar_based_model_pyparsing.py,sha256=TZx81K6fwLs7K0tWOoqYbjzZG981cck4W2svB6BDMBA,2709
|
102
|
-
langroid/agent/tools/grammar_based_model_pyparsing.py-e,sha256=aiKhr8pTMjpwsEYapag2t5bW6XbgdjfutQ-vZwUPqTw,2708
|
103
|
-
langroid/agent/tools/grammar_based_model_regex.py,sha256=r0RYC7y_vnx2KvQEG-tkjBk7YdE_l4w3c8rmZ-30uDo,3882
|
104
|
-
langroid/agent/tools/grammar_based_model_regex.py-e,sha256=7_19HiK0lTpUZgGjUW_1t-Ebo_arpoyYA4N0gbgU130,3827
|
105
|
-
langroid/agent/tools/grammar_based_model_regex2.py,sha256=c4tP5Xm4gpUolaWmqIWVtZmaVK2yZ4Ne93DdJK6jCBs,3487
|
106
|
-
langroid/agent/tools/grammar_based_model_regex2.py-e,sha256=tl3xXIfWXfu5pJV6pCn1NQbvWKIQyxcMglIT8x1zvHA,3444
|
107
|
-
langroid/agent/tools/grammar_based_model_tatsu.py,sha256=A-J8flmfvJ5ob-N66ENvzFlCwhv_Ln0sbAiwMpMUbLc,2244
|
108
|
-
langroid/agent/tools/grammar_based_model_tatsu.py-e,sha256=Dgu9w1LWstiGWEm-xmwjwuyQsPSwlfZ5Q31dqErfqis,2240
|
109
|
-
langroid/agent/tools/lark_earley_example.py,sha256=p5CavHMeiRpMNApzlXv21dM8IkgMj04vpAssibZ809c,3269
|
110
|
-
langroid/agent/tools/lark_earley_example.py-e,sha256=cPK0Mkz-Dz38Sqy6Zxw_kwlRoOiDRdzMPd_bgvPyv9Y,3250
|
111
|
-
langroid/agent/tools/lark_example.py,sha256=G-DUh8vqWceu_joNoLli_vy373py09vnwPWAfg7oJuY,1669
|
112
42
|
langroid/agent/tools/metaphor_search_tool.py,sha256=qj4gt453cLEX3EGW7nVzVu6X7LCdrwjSlcNY0qJW104,2489
|
113
|
-
langroid/agent/tools/note_tool.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
114
43
|
langroid/agent/tools/orchestration.py,sha256=afIt8Ah0dfrY2TQ7aNrkxUFLV288VTQ0L40Yse_-HeY,10785
|
115
|
-
langroid/agent/tools/parse_example.py,sha256=rAi7C37Lb2sAie7lBkBTmhUBUc8jBNzgDwqhrCT--AM,1974
|
116
|
-
langroid/agent/tools/parse_example2.py,sha256=zbs8WUP-6CUKL3MCD1FG38BclKWrvCthqiD2Okf5TEU,2166
|
117
|
-
langroid/agent/tools/parse_example3.py,sha256=FdBtvpfdIDfxOFnsPRBGTI8eJhM9uVd_NTuNrTD0WSE,1008
|
118
|
-
langroid/agent/tools/parse_test.py,sha256=-kkHRrmbzOmHzg8u9AWcmnhoM5qhfDnULgqOLJxRvMw,25509
|
119
44
|
langroid/agent/tools/recipient_tool.py,sha256=0m2kQhYKTeGujAxhSPqH5z6hSAhVB_Dqour6uul2U30,9427
|
120
45
|
langroid/agent/tools/retrieval_tool.py,sha256=2q2pfoYbZNfbWQ0McxrtmfF0ekGglIgRl-6uF26pa-E,871
|
121
46
|
langroid/agent/tools/rewind_tool.py,sha256=XAXL3BpNhCmBGYq_qi_sZfHJuIw7NY2jp4wnojJ7WRs,5606
|
122
|
-
langroid/agent/tools/run_python_code.py,sha256=BvoxYzzHijU-p4703n2iVlt5BCieR1oMSy50w0tQZAg,1787
|
123
47
|
langroid/agent/tools/segment_extract_tool.py,sha256=__srZ_VGYLVOdPrITUM8S0HpmX4q7r5FHWMDdHdEv8w,1440
|
124
48
|
langroid/agent/typed_task.py,sha256=oxja0Z3uLTv0BcR1xIMqDpo85MIGOruz4XsZ4ghjsW4,689
|
125
|
-
langroid/agent/xml_tool_message.py,sha256=
|
49
|
+
langroid/agent/xml_tool_message.py,sha256=W4mjZlvizuYRDGOtttoIzJjfB8wRcV87nE8ZGfg_hqs,9043
|
126
50
|
langroid/agent_config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
127
51
|
langroid/cachedb/__init__.py,sha256=icAT2s7Vhf-ZGUeqpDQGNU6ob6o0aFEyjwcxxUGRFjg,225
|
128
52
|
langroid/cachedb/base.py,sha256=ztVjB1DtN6pLCujCWnR6xruHxwVj3XkYniRTYAKKqk0,1354
|
@@ -187,8 +111,9 @@ langroid/utils/__init__.py,sha256=Sruos2tB4G7Tn0vlblvYlX9PEGR0plI2uE0PJ4d_EC4,35
|
|
187
111
|
langroid/utils/algorithms/__init__.py,sha256=WylYoZymA0fnzpB4vrsH_0n7WsoLhmuZq8qxsOCjUpM,41
|
188
112
|
langroid/utils/algorithms/graph.py,sha256=JbdpPnUOhw4-D6O7ou101JLA3xPCD0Lr3qaPoFCaRfo,2866
|
189
113
|
langroid/utils/configuration.py,sha256=LgjHGB0qgKKTwBaVt84APiqvJbz6pLwylUvHWYmzyP0,3303
|
190
|
-
langroid/utils/constants.py,sha256=
|
114
|
+
langroid/utils/constants.py,sha256=vKIdkAJwyPT-bRA5MDPiOl7-EppBRmewRBIOcdXi4I4,959
|
191
115
|
langroid/utils/docker.py,sha256=kJQOLTgM0x9j9pgIIqp0dZNZCTvoUDhp6i8tYBq1Jr0,1105
|
116
|
+
langroid/utils/git_utils.py,sha256=lNvUd612NhOGNS1l7rN_JV6reoKf8BuJjNwedRTZvS8,7909
|
192
117
|
langroid/utils/globals.py,sha256=Az9dOFqR6n9CoTYSqa2kLikQWS0oCQ9DFQIQAnG-2q8,1355
|
193
118
|
langroid/utils/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
194
119
|
langroid/utils/llms/strings.py,sha256=CSAX9Z6FQOLXOzbLMe_Opqtc3ruDAKTTk7cPqc6Blh0,263
|
@@ -200,7 +125,7 @@ langroid/utils/output/printing.py,sha256=yzPJZN-8_jyOJmI9N_oLwEDfjMwVgk3IDiwnZ4e
|
|
200
125
|
langroid/utils/output/status.py,sha256=rzbE7mDJcgNNvdtylCseQcPGCGghtJvVq3lB-OPJ49E,1049
|
201
126
|
langroid/utils/pandas_utils.py,sha256=UctS986Jtl_MvU5rA7-GfrjEHXP7MNu8ePhepv0bTn0,755
|
202
127
|
langroid/utils/pydantic_utils.py,sha256=iRy7uQhHhQmIDZTTPNX5jXb6fqefMe9N67p3fPfOmTI,20624
|
203
|
-
langroid/utils/system.py,sha256=
|
128
|
+
langroid/utils/system.py,sha256=CZKEnERYMzFLdb2vBE5SfQRX5yeG-2AnezjmycsvQAU,7651
|
204
129
|
langroid/utils/types.py,sha256=4GrOnU3HLWh-UwaUPp7LlB3V413q3K5OSzc0ggDoQ6A,2510
|
205
130
|
langroid/utils/web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
206
131
|
langroid/utils/web/login.py,sha256=1iz9eUAHa87vpKIkzwkmFa00avwFWivDSAr7QUhK7U0,2528
|
@@ -212,8 +137,8 @@ langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3Hmh
|
|
212
137
|
langroid/vector_store/momento.py,sha256=qR-zBF1RKVHQZPZQYW_7g-XpTwr46p8HJuYPCkfJbM4,10534
|
213
138
|
langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
|
214
139
|
langroid/vector_store/qdrantdb.py,sha256=v88lqFkepADvlN6lByUj9I4NEKa9X9lWH16uTPPbYrE,17457
|
215
|
-
pyproject.toml,sha256=
|
216
|
-
langroid-0.
|
217
|
-
langroid-0.
|
218
|
-
langroid-0.
|
219
|
-
langroid-0.
|
140
|
+
pyproject.toml,sha256=olj3ishnFpF3nPogWJJYBDdduQUnRQiWD1qM08LKna0,7179
|
141
|
+
langroid-0.17.0.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
142
|
+
langroid-0.17.0.dist-info/METADATA,sha256=3PBPiOQIuduXHEPuZEqnPV3OjgnfIJpxc33dONV2GM0,56325
|
143
|
+
langroid-0.17.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
144
|
+
langroid-0.17.0.dist-info/RECORD,,
|
pyproject.toml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "langroid"
|
3
|
-
version = "0.
|
3
|
+
version = "0.17.0"
|
4
4
|
description = "Harness LLMs with Multi-Agent Programming"
|
5
5
|
authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
|
6
6
|
readme = "README.md"
|
@@ -87,8 +87,9 @@ nest-asyncio = "^1.6.0"
|
|
87
87
|
async-generator = "^1.10"
|
88
88
|
|
89
89
|
python-magic = "^0.4.27"
|
90
|
-
json-repair = "^0.29.
|
90
|
+
json-repair = "^0.29.9"
|
91
91
|
cerebras-cloud-sdk = "^1.1.0"
|
92
|
+
gitpython = "^3.1.43"
|
92
93
|
|
93
94
|
|
94
95
|
[tool.poetry.extras]
|
@@ -1,455 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Subclass of `ToolMessage`, specialized for markdown-formatted structured messages.
|
3
|
-
Helpful when LLM is producing code as part of a tool-message -- code within JSON
|
4
|
-
tends to cause all kinds of issues, especially with weaker LLMs.
|
5
|
-
An LLM more reliably generates code within fenced blocks in a markdown doc.
|
6
|
-
"""
|
7
|
-
|
8
|
-
import re
|
9
|
-
import textwrap
|
10
|
-
from random import choice
|
11
|
-
from typing import Any, Dict, List, Tuple, Type, TypeVar, Union
|
12
|
-
|
13
|
-
from langroid.agent.tool_message import ToolMessage
|
14
|
-
from langroid.language_models.base import LLMFunctionSpec
|
15
|
-
from langroid.pydantic_v1 import BaseModel, Extra
|
16
|
-
|
17
|
-
|
18
|
-
class FileContents(BaseModel):
|
19
|
-
file_path: str
|
20
|
-
contents: str
|
21
|
-
|
22
|
-
|
23
|
-
T = TypeVar("T", bound="MdToolMessage")
|
24
|
-
|
25
|
-
from lark import Lark
|
26
|
-
|
27
|
-
md_tool_message_grammar = """
|
28
|
-
start: section+
|
29
|
-
|
30
|
-
section: header content
|
31
|
-
|
32
|
-
header: "#" WS WORD
|
33
|
-
|
34
|
-
content: primitive
|
35
|
-
| list
|
36
|
-
| file_contents
|
37
|
-
| list_file_contents
|
38
|
-
|
39
|
-
primitive: value
|
40
|
-
|
41
|
-
list: list_item+
|
42
|
-
list_item: "-" WS value
|
43
|
-
|
44
|
-
file_contents: "file_path:" WS FILEPATH NEWLINE CODE_BLOCK
|
45
|
-
list_file_contents: file_contents+
|
46
|
-
|
47
|
-
CODE_BLOCK: /```[^`]*```/
|
48
|
-
FILEPATH: /[^\\n]+/
|
49
|
-
WORD: /[a-zA-Z_]+/
|
50
|
-
value: /[^\\n]+/
|
51
|
-
|
52
|
-
%import common.WS
|
53
|
-
%import common.NEWLINE
|
54
|
-
"""
|
55
|
-
|
56
|
-
parser = Lark(md_tool_message_grammar, start="start", parser="lalr")
|
57
|
-
|
58
|
-
|
59
|
-
def apply_grammar(markdown_content: str):
|
60
|
-
tree = parser.parse(markdown_content)
|
61
|
-
return tree
|
62
|
-
|
63
|
-
|
64
|
-
@classmethod
|
65
|
-
def from_markdown(cls: Type[T], markdown_content: str) -> T:
|
66
|
-
"""
|
67
|
-
Parse markdown content and create an instance of the MdToolMessage subclass.
|
68
|
-
"""
|
69
|
-
tree = apply_grammar(markdown_content)
|
70
|
-
parsed_data = cls._extract_data_from_tree(tree)
|
71
|
-
return cls(**parsed_data)
|
72
|
-
|
73
|
-
|
74
|
-
@classmethod
|
75
|
-
def _extract_data_from_tree(cls, tree):
|
76
|
-
parsed_data = {}
|
77
|
-
for section in tree.children:
|
78
|
-
key = section.children[0].children[1].value.lower()
|
79
|
-
value = cls._parse_content(section.children[1])
|
80
|
-
parsed_data[key] = value
|
81
|
-
return parsed_data
|
82
|
-
|
83
|
-
|
84
|
-
@classmethod
|
85
|
-
def _parse_content(cls, content):
|
86
|
-
if content.data == "primitive":
|
87
|
-
return cls._parse_primitive(content.children[0].value)
|
88
|
-
elif content.data == "list":
|
89
|
-
return [item.children[1].value for item in content.children]
|
90
|
-
elif content.data == "file_contents":
|
91
|
-
return cls._parse_file_contents(content)
|
92
|
-
elif content.data == "list_file_contents":
|
93
|
-
return [cls._parse_file_contents(fc) for fc in content.children]
|
94
|
-
|
95
|
-
|
96
|
-
@classmethod
|
97
|
-
def _parse_file_contents(cls, file_contents):
|
98
|
-
file_path = file_contents.children[1].value
|
99
|
-
content = file_contents.children[2].value.strip("`").strip()
|
100
|
-
return FileContents(file_path=file_path, contents=content)
|
101
|
-
|
102
|
-
|
103
|
-
class MdToolMessage(ToolMessage):
|
104
|
-
"""
|
105
|
-
Subclass of ToolMessage, with LLM instructions to generate markdown rather than
|
106
|
-
json format.
|
107
|
-
|
108
|
-
Limited to simple tool messages where each field is:
|
109
|
-
- of type str, int, float, bool, FileContents, or list of these
|
110
|
-
|
111
|
-
The corresponding markdown format would look like:
|
112
|
-
|
113
|
-
```md
|
114
|
-
# request
|
115
|
-
<request>
|
116
|
-
|
117
|
-
# purpose
|
118
|
-
<purpose>
|
119
|
-
|
120
|
-
# <field1>
|
121
|
-
<value1>
|
122
|
-
|
123
|
-
# <field2>
|
124
|
-
<value2>
|
125
|
-
|
126
|
-
# <list_field>
|
127
|
-
- item1
|
128
|
-
- item2
|
129
|
-
- item3
|
130
|
-
|
131
|
-
|
132
|
-
# <list_of_file_contents_field_name>
|
133
|
-
file_path:<file_path1>
|
134
|
-
<contents1> (ensure code is in a fenced block, e.g. ```rust ... ```)
|
135
|
-
file_path:<file_path2>
|
136
|
-
<contents2>
|
137
|
-
...
|
138
|
-
```
|
139
|
-
|
140
|
-
Attributes:
|
141
|
-
request (str): name of agent method to map to. This is the method that
|
142
|
-
would handle the LLM's generated tool call.
|
143
|
-
purpose (str): purpose of agent method, expressed in general terms.
|
144
|
-
(This is used when auto-generating the tool instruction to the LLM)
|
145
|
-
"""
|
146
|
-
|
147
|
-
request: str
|
148
|
-
purpose: str
|
149
|
-
id: str = "" # placeholder for OpenAI-API tool_call_id
|
150
|
-
|
151
|
-
_allow_llm_use: bool = True # allow an LLM to use (i.e. generate) this tool?
|
152
|
-
|
153
|
-
# model_config = ConfigDict(extra=Extra.allow)
|
154
|
-
|
155
|
-
class Config:
|
156
|
-
# This is NOT inherited from ToolMessage.Config, so we do it here again
|
157
|
-
extra = Extra.allow
|
158
|
-
arbitrary_types_allowed = False
|
159
|
-
validate_all = True
|
160
|
-
validate_assignment = True
|
161
|
-
# do not include these fields in the generated schema
|
162
|
-
# since we don't require the LLM to specify them
|
163
|
-
schema_extra = {"exclude": {"purpose", "id"}}
|
164
|
-
|
165
|
-
@classmethod
|
166
|
-
def __init_subclass__(cls, **kwargs: Any) -> None:
|
167
|
-
super().__init_subclass__(**kwargs)
|
168
|
-
for name, field in cls.__fields__.items():
|
169
|
-
if name not in ["request", "purpose", "id"]:
|
170
|
-
if field.type_ not in [
|
171
|
-
str,
|
172
|
-
int,
|
173
|
-
float,
|
174
|
-
bool,
|
175
|
-
FileContents,
|
176
|
-
List[str],
|
177
|
-
List[int],
|
178
|
-
List[float],
|
179
|
-
List[bool],
|
180
|
-
List[FileContents],
|
181
|
-
]:
|
182
|
-
raise ValueError(
|
183
|
-
f"""
|
184
|
-
Field '{name}' must be of type str, int, float, bool,
|
185
|
-
or list of these,
|
186
|
-
FileContents, or list of these
|
187
|
-
"""
|
188
|
-
)
|
189
|
-
|
190
|
-
@classmethod
|
191
|
-
def examples(cls) -> List["ToolMessage" | Tuple[str, "ToolMessage"]]:
|
192
|
-
"""
|
193
|
-
Examples to use in few-shot demos with markdown formatting instructions.
|
194
|
-
Each example can be either:
|
195
|
-
- just an MdToolMessage instance, e.g. MyTool(param1=1, param2="hello"), or
|
196
|
-
- a tuple (description, MdToolMessage instance), where the description is
|
197
|
-
a natural language "thought" that leads to the tool usage,
|
198
|
-
e.g. ("I want to find the square of 5", SquareTool(num=5))
|
199
|
-
In some scenarios, including such a description can significantly
|
200
|
-
enhance reliability of tool use.
|
201
|
-
Returns:
|
202
|
-
"""
|
203
|
-
return []
|
204
|
-
|
205
|
-
@classmethod
|
206
|
-
def usage_examples(cls, random: bool = False) -> str:
|
207
|
-
"""
|
208
|
-
Instruction to the LLM showing examples of how to use the tool-message.
|
209
|
-
|
210
|
-
Args:
|
211
|
-
random (bool): whether to pick a random example from the list of examples.
|
212
|
-
Set to `true` when using this to illustrate a dialog between LLM and
|
213
|
-
user.
|
214
|
-
(if false, use ALL examples)
|
215
|
-
Returns:
|
216
|
-
str: examples of how to use the tool/function-call
|
217
|
-
"""
|
218
|
-
# pick a random example of the fields
|
219
|
-
if len(cls.examples()) == 0:
|
220
|
-
return ""
|
221
|
-
if random:
|
222
|
-
examples = [choice(cls.examples())]
|
223
|
-
else:
|
224
|
-
examples = cls.examples()
|
225
|
-
examples_jsons = [
|
226
|
-
(
|
227
|
-
f"EXAMPLE {i}: (THOUGHT: {ex[0]}) => \n{ex[1].format_example()}"
|
228
|
-
if isinstance(ex, tuple)
|
229
|
-
else f"EXAMPLE {i}:\n {ex.format_example()}"
|
230
|
-
)
|
231
|
-
for i, ex in enumerate(examples, 1)
|
232
|
-
]
|
233
|
-
return "\n\n".join(examples_jsons)
|
234
|
-
|
235
|
-
def tree_to_markdown(tree):
|
236
|
-
markdown = []
|
237
|
-
for section in tree.children:
|
238
|
-
header = section.children[0].children[1].value
|
239
|
-
content = section.children[1]
|
240
|
-
markdown.append(f"# {header}")
|
241
|
-
markdown.append(cls._content_to_markdown(content))
|
242
|
-
return "\n\n".join(markdown)
|
243
|
-
|
244
|
-
@classmethod
|
245
|
-
def _content_to_markdown(cls, content):
|
246
|
-
if content.data == "primitive":
|
247
|
-
return content.children[0].value
|
248
|
-
elif content.data == "list":
|
249
|
-
return "\n".join(f"- {item.children[1].value}" for item in content.children)
|
250
|
-
elif content.data == "file_contents":
|
251
|
-
return cls._file_contents_to_markdown(content)
|
252
|
-
elif content.data == "list_file_contents":
|
253
|
-
return "\n\n".join(
|
254
|
-
cls._file_contents_to_markdown(fc) for fc in content.children
|
255
|
-
)
|
256
|
-
|
257
|
-
@classmethod
|
258
|
-
def _file_contents_to_markdown(cls, file_contents):
|
259
|
-
file_path = file_contents.children[1].value
|
260
|
-
content = file_contents.children[2].value.strip("`").strip()
|
261
|
-
return f"file_path: {file_path}\n{content}"
|
262
|
-
|
263
|
-
def to_markdown(self) -> str:
|
264
|
-
tree = apply_grammar(self.format_example())
|
265
|
-
return tree_to_markdown(tree)
|
266
|
-
|
267
|
-
def format_example(self) -> str:
|
268
|
-
"""
|
269
|
-
Override json_example to use our new to_markdown method
|
270
|
-
"""
|
271
|
-
return self.to_markdown()
|
272
|
-
|
273
|
-
@classmethod
|
274
|
-
def format_instructions(cls) -> str:
|
275
|
-
fields = cls.__fields__
|
276
|
-
excluded_fields = cls.Config.schema_extra.get("exclude", set())
|
277
|
-
|
278
|
-
instructions = [
|
279
|
-
cls._field_instruction(name, field)
|
280
|
-
for name, field in fields.items()
|
281
|
-
if name not in excluded_fields
|
282
|
-
]
|
283
|
-
all_instructions = "\n\n".join(instructions)
|
284
|
-
|
285
|
-
examples_str = ""
|
286
|
-
if cls.examples():
|
287
|
-
examples_str = "# Examples\n\n" + cls.usage_examples()
|
288
|
-
|
289
|
-
return f"{all_instructions}\n\n{examples_str}"
|
290
|
-
|
291
|
-
@classmethod
|
292
|
-
def _field_instruction(cls, name: str, field: Any) -> str:
|
293
|
-
field_type = field.outer_type_
|
294
|
-
|
295
|
-
if field_type in (str, int, float, bool):
|
296
|
-
return cls._primitive_instruction(name, field_type)
|
297
|
-
elif field_type == FileContents:
|
298
|
-
return cls._file_contents_instruction(name)
|
299
|
-
elif field_type == List[str]:
|
300
|
-
return cls._list_primitive_instruction(name, str)
|
301
|
-
elif field_type == List[int]:
|
302
|
-
return cls._list_primitive_instruction(name, int)
|
303
|
-
elif field_type == List[float]:
|
304
|
-
return cls._list_primitive_instruction(name, float)
|
305
|
-
elif field_type == List[bool]:
|
306
|
-
return cls._list_primitive_instruction(name, bool)
|
307
|
-
elif field_type == List[FileContents]:
|
308
|
-
return cls._list_file_contents_instruction(name)
|
309
|
-
|
310
|
-
raise ValueError(f"Unsupported field type: {field_type}")
|
311
|
-
|
312
|
-
@staticmethod
|
313
|
-
def _primitive_instruction(name: str, field_type: Type[Any]) -> str:
|
314
|
-
type_name = field_type.__name__
|
315
|
-
return f"# {name}\n<{name}> ({type_name}, required)"
|
316
|
-
|
317
|
-
@staticmethod
|
318
|
-
def _list_primitive_instruction(name: str, item_type: Type[Any]) -> str:
|
319
|
-
type_name = item_type.__name__
|
320
|
-
return f"# {name}\n- <{name}1> ({type_name})\n- <{name}2> ({type_name})\n..."
|
321
|
-
|
322
|
-
@staticmethod
|
323
|
-
def _file_contents_instruction(name: str) -> str:
|
324
|
-
return (
|
325
|
-
f"# {name}\n"
|
326
|
-
f"file_path: <file_path> (string)\n"
|
327
|
-
f"<contents> "
|
328
|
-
f"(string, ensure code is within code-fence, e.g. ```python ... ```)"
|
329
|
-
)
|
330
|
-
|
331
|
-
@staticmethod
|
332
|
-
def _list_file_contents_instruction(name: str) -> str:
|
333
|
-
return (
|
334
|
-
f"# {name}\n"
|
335
|
-
f"file_path: <file_path1> (string)\n"
|
336
|
-
f"<contents1> "
|
337
|
-
f"(string, ensure code is within code-fence, e.g. ```python ... ```)\n\n"
|
338
|
-
f"file_path: <file_path2> (string)\n"
|
339
|
-
f"<contents2> "
|
340
|
-
f"(string, ensure code is within code-fence, e.g. ```python ... ```)\n"
|
341
|
-
f"..."
|
342
|
-
)
|
343
|
-
|
344
|
-
@staticmethod
|
345
|
-
def json_group_instructions() -> str:
|
346
|
-
"""Template for instructions for a group of tools.
|
347
|
-
Works with GPT4 but override this for weaker LLMs if needed.
|
348
|
-
"""
|
349
|
-
return textwrap.dedent(
|
350
|
-
"""
|
351
|
-
=== ALL AVAILABLE TOOLS and THEIR JSON FORMAT INSTRUCTIONS ===
|
352
|
-
You have access to the following TOOLS to accomplish your task:
|
353
|
-
|
354
|
-
{json_instructions}
|
355
|
-
|
356
|
-
When one of the above TOOLs is applicable, you must express your
|
357
|
-
request as "TOOL:" followed by the request in the above JSON format.
|
358
|
-
"""
|
359
|
-
)
|
360
|
-
|
361
|
-
@classmethod
|
362
|
-
def llm_function_schema(
|
363
|
-
cls,
|
364
|
-
request: bool = False,
|
365
|
-
defaults: bool = True,
|
366
|
-
) -> LLMFunctionSpec:
|
367
|
-
raise NotImplementedError(
|
368
|
-
"""
|
369
|
-
The MdToolMessage class cannot be used with OpenAI function/tools.
|
370
|
-
In your ChatAgentConfig, set `use_functions_api=False` and `use_tools=True`
|
371
|
-
"""
|
372
|
-
)
|
373
|
-
|
374
|
-
@classmethod
|
375
|
-
def from_markdown(cls: Type[T], markdown_content: str) -> T:
|
376
|
-
"""
|
377
|
-
Parse markdown content and create an instance of the MdToolMessage subclass.
|
378
|
-
"""
|
379
|
-
parsed_data = cls._parse_markdown(markdown_content)
|
380
|
-
return cls(**parsed_data)
|
381
|
-
|
382
|
-
@classmethod
|
383
|
-
def _parse_markdown(cls, markdown_content: str) -> Dict[str, Any]:
|
384
|
-
sections = re.split(r"\n# ", markdown_content)
|
385
|
-
parsed_data = {}
|
386
|
-
|
387
|
-
for section in sections:
|
388
|
-
if not section.strip():
|
389
|
-
continue
|
390
|
-
lines = section.strip().split("\n")
|
391
|
-
key = lines[0].lower()
|
392
|
-
value = cls._parse_section_value(lines[1:])
|
393
|
-
parsed_data[key] = value
|
394
|
-
|
395
|
-
return parsed_data
|
396
|
-
|
397
|
-
@classmethod
|
398
|
-
def _parse_section_value(cls, lines: List[str]) -> Any:
|
399
|
-
if not lines:
|
400
|
-
return None
|
401
|
-
|
402
|
-
if lines[0].startswith("- "):
|
403
|
-
return [line.strip("- ").strip() for line in lines]
|
404
|
-
|
405
|
-
if "file_path:" in lines[0]:
|
406
|
-
return cls._parse_file_contents(lines)
|
407
|
-
|
408
|
-
if len(lines) == 1:
|
409
|
-
return cls._parse_primitive(lines[0])
|
410
|
-
|
411
|
-
return "\n".join(lines)
|
412
|
-
|
413
|
-
@staticmethod
|
414
|
-
def _parse_file_contents(lines: List[str]) -> FileContents | List[FileContents]:
|
415
|
-
file_contents_list = []
|
416
|
-
current_file = None
|
417
|
-
|
418
|
-
for line in lines:
|
419
|
-
if line.startswith("file_path:"):
|
420
|
-
if current_file:
|
421
|
-
file_contents_list.append(FileContents(**current_file))
|
422
|
-
current_file = {"file_path": line.split(":", 1)[1].strip()}
|
423
|
-
elif current_file:
|
424
|
-
current_file["contents"] = (
|
425
|
-
current_file.get("contents", "") + line + "\n"
|
426
|
-
)
|
427
|
-
current_file["contents"] = current_file["contents"].strip()
|
428
|
-
lines = current_file["contents"].split("\n")
|
429
|
-
# if first , last line contain backticks, discard them
|
430
|
-
if lines and "```" in lines[0]:
|
431
|
-
lines = lines[1:]
|
432
|
-
if lines and "```" in lines[-1]:
|
433
|
-
lines = lines[:-1]
|
434
|
-
current_file["contents"] = "\n".join(lines)
|
435
|
-
|
436
|
-
if current_file:
|
437
|
-
file_contents_list.append(FileContents(**current_file))
|
438
|
-
|
439
|
-
return (
|
440
|
-
file_contents_list if len(file_contents_list) > 1 else file_contents_list[0]
|
441
|
-
)
|
442
|
-
|
443
|
-
@staticmethod
|
444
|
-
def _parse_primitive(value: str) -> Union[str, int, float, bool]:
|
445
|
-
if value.lower() == "true":
|
446
|
-
return True
|
447
|
-
if value.lower() == "false":
|
448
|
-
return False
|
449
|
-
try:
|
450
|
-
return int(value)
|
451
|
-
except ValueError:
|
452
|
-
try:
|
453
|
-
return float(value)
|
454
|
-
except ValueError:
|
455
|
-
return value
|