lionagi 0.0.114__py3-none-any.whl → 0.0.116__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. lionagi/__init__.py +7 -4
  2. lionagi/bridge/__init__.py +19 -4
  3. lionagi/bridge/langchain.py +23 -3
  4. lionagi/bridge/llama_index.py +5 -3
  5. lionagi/configs/__init__.py +1 -1
  6. lionagi/configs/oai_configs.py +88 -1
  7. lionagi/core/__init__.py +6 -9
  8. lionagi/core/conversations/__init__.py +5 -0
  9. lionagi/core/conversations/conversation.py +107 -0
  10. lionagi/core/flows/__init__.py +8 -0
  11. lionagi/core/flows/flow.py +8 -0
  12. lionagi/core/flows/flow_util.py +62 -0
  13. lionagi/core/instruction_set/__init__.py +5 -0
  14. lionagi/core/instruction_set/instruction_sets.py +7 -0
  15. lionagi/core/sessions/__init__.py +5 -0
  16. lionagi/core/sessions/sessions.py +187 -0
  17. lionagi/endpoints/__init__.py +5 -0
  18. lionagi/endpoints/assistants.py +0 -0
  19. lionagi/endpoints/audio.py +17 -0
  20. lionagi/endpoints/chatcompletion.py +54 -0
  21. lionagi/endpoints/embeddings.py +0 -0
  22. lionagi/endpoints/finetune.py +0 -0
  23. lionagi/endpoints/image.py +0 -0
  24. lionagi/endpoints/moderation.py +0 -0
  25. lionagi/endpoints/vision.py +0 -0
  26. lionagi/{loader → loaders}/__init__.py +7 -1
  27. lionagi/{loader → loaders}/chunker.py +6 -12
  28. lionagi/{utils/load_utils.py → loaders/load_util.py} +47 -6
  29. lionagi/{loader → loaders}/reader.py +4 -12
  30. lionagi/messages/__init__.py +11 -0
  31. lionagi/messages/instruction.py +15 -0
  32. lionagi/messages/message.py +110 -0
  33. lionagi/messages/response.py +33 -0
  34. lionagi/messages/system.py +12 -0
  35. lionagi/objs/__init__.py +10 -6
  36. lionagi/objs/abc_objs.py +39 -0
  37. lionagi/objs/async_queue.py +135 -0
  38. lionagi/objs/messenger.py +70 -148
  39. lionagi/objs/status_tracker.py +37 -0
  40. lionagi/objs/{tool_registry.py → tool_manager.py} +8 -6
  41. lionagi/schema/__init__.py +3 -3
  42. lionagi/schema/base_node.py +251 -0
  43. lionagi/schema/base_tool.py +8 -3
  44. lionagi/schema/data_logger.py +2 -3
  45. lionagi/schema/data_node.py +37 -0
  46. lionagi/services/__init__.py +1 -4
  47. lionagi/services/base_api_service.py +15 -5
  48. lionagi/services/oai.py +2 -2
  49. lionagi/services/openrouter.py +2 -3
  50. lionagi/structures/graph.py +96 -0
  51. lionagi/{structure → structures}/relationship.py +10 -2
  52. lionagi/structures/structure.py +102 -0
  53. lionagi/tests/test_api_util.py +46 -0
  54. lionagi/tests/test_call_util.py +115 -0
  55. lionagi/tests/test_convert_util.py +202 -0
  56. lionagi/tests/test_encrypt_util.py +33 -0
  57. lionagi/tests/{test_flatten_util.py → test_flat_util.py} +1 -1
  58. lionagi/tests/test_io_util.py +0 -0
  59. lionagi/tests/test_sys_util.py +0 -0
  60. lionagi/tools/__init__.py +5 -0
  61. lionagi/tools/tool_util.py +7 -0
  62. lionagi/utils/__init__.py +55 -35
  63. lionagi/utils/api_util.py +19 -17
  64. lionagi/utils/call_util.py +2 -1
  65. lionagi/utils/convert_util.py +229 -0
  66. lionagi/utils/encrypt_util.py +16 -0
  67. lionagi/utils/flat_util.py +38 -0
  68. lionagi/utils/io_util.py +2 -2
  69. lionagi/utils/sys_util.py +45 -10
  70. lionagi/version.py +1 -1
  71. {lionagi-0.0.114.dist-info → lionagi-0.0.116.dist-info}/METADATA +2 -2
  72. lionagi-0.0.116.dist-info/RECORD +110 -0
  73. lionagi/core/conversations.py +0 -108
  74. lionagi/core/flows.py +0 -1
  75. lionagi/core/instruction_sets.py +0 -1
  76. lionagi/core/messages.py +0 -166
  77. lionagi/core/sessions.py +0 -297
  78. lionagi/schema/base_schema.py +0 -252
  79. lionagi/services/chatcompletion.py +0 -48
  80. lionagi/services/service_objs.py +0 -282
  81. lionagi/structure/structure.py +0 -160
  82. lionagi/tools/coder.py +0 -1
  83. lionagi/tools/sandbox.py +0 -1
  84. lionagi/utils/tool_util.py +0 -92
  85. lionagi/utils/type_util.py +0 -81
  86. lionagi-0.0.114.dist-info/RECORD +0 -84
  87. /lionagi/configs/{openrouter_config.py → openrouter_configs.py} +0 -0
  88. /lionagi/{datastore → datastores}/__init__.py +0 -0
  89. /lionagi/{datastore → datastores}/chroma.py +0 -0
  90. /lionagi/{datastore → datastores}/deeplake.py +0 -0
  91. /lionagi/{datastore → datastores}/elasticsearch.py +0 -0
  92. /lionagi/{datastore → datastores}/lantern.py +0 -0
  93. /lionagi/{datastore → datastores}/pinecone.py +0 -0
  94. /lionagi/{datastore → datastores}/postgres.py +0 -0
  95. /lionagi/{datastore → datastores}/qdrant.py +0 -0
  96. /lionagi/{structure → structures}/__init__.py +0 -0
  97. {lionagi-0.0.114.dist-info → lionagi-0.0.116.dist-info}/LICENSE +0 -0
  98. {lionagi-0.0.114.dist-info → lionagi-0.0.116.dist-info}/WHEEL +0 -0
  99. {lionagi-0.0.114.dist-info → lionagi-0.0.116.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,110 @@
1
+ lionagi/__init__.py,sha256=19MF4mClDcA1MnveM-mMVzHozpm0SPB_Q9xr_iARUnM,905
2
+ lionagi/version.py,sha256=eLNosBjJzYQH-LOycm3M-_lc70PB3et54VYnvKM502o,24
3
+ lionagi/bridge/__init__.py,sha256=YDKi-pniFEknEXTSEvX6yEe4Y69f0kLvbjvEQ0TdrTU,575
4
+ lionagi/bridge/langchain.py,sha256=-3rlRnI5Df5vyfjZ2AoWD-4Rl623MD1lRqvMV7ZKjbs,5304
5
+ lionagi/bridge/llama_index.py,sha256=GwHksLzQZHxiSgXsWhviPccgSj3ZQWo9ujdPklQtU9k,5600
6
+ lionagi/configs/__init__.py,sha256=QOd4Rs7vjIpNWvIocxWQeU-q-MPRC-AOxh-gM-eBJ2o,142
7
+ lionagi/configs/oai_configs.py,sha256=w4rLSMRWwMWS43iaDGNDu9FGTe94t4zpbIDxrvkCo6U,2657
8
+ lionagi/configs/openrouter_configs.py,sha256=qbEQQqQPpzMp3eP5U8kuvGTUYdMgemuuq-BdgOYgYI8,1256
9
+ lionagi/core/__init__.py,sha256=lliZpl0OlISCd5HT_qPU-i9f61iCtY2Nc2PLEJiFLEI,243
10
+ lionagi/core/conversations/__init__.py,sha256=9-446R98YwBXRtKr1QzxZJDOfnhriMbuax4a-fmnJZg,72
11
+ lionagi/core/conversations/conversation.py,sha256=Dr2H4K1oI65rfB97F0mAWpbLWBumm4VDlqOnCrpcc2Y,4260
12
+ lionagi/core/flows/__init__.py,sha256=jT8rZsRuafEsHnfuv8bLCcZsMmWsK2ecy8L113RXF6o,103
13
+ lionagi/core/flows/flow.py,sha256=MFDyQlxRIbEu8tr28g7AjOJLOoJPJiUpzjFGjS3wxmo,186
14
+ lionagi/core/flows/flow_util.py,sha256=6O1Y6zHKvKRA1xshBzseNyDjGJyUkIL0DSbbkon-hUw,1974
15
+ lionagi/core/instruction_set/__init__.py,sha256=BUQ35fKuVAq55CWj8FMFYabULNdxYVhcOSwwOEA_BFE,83
16
+ lionagi/core/instruction_set/instruction_sets.py,sha256=3kKpXMjtLXHAcS51cElpgT8b6j31EzX7RBatnAl-hnQ,193
17
+ lionagi/core/sessions/__init__.py,sha256=orAbb5Ehq8arlPOoV_UkJBFtEXfeF_aROb_scNjppWo,58
18
+ lionagi/core/sessions/sessions.py,sha256=rK1pInjfFbyeY66en8C8sDSlnmT5PPjz9j0WOYBCbmc,7769
19
+ lionagi/datastores/__init__.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
20
+ lionagi/datastores/chroma.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
21
+ lionagi/datastores/deeplake.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
22
+ lionagi/datastores/elasticsearch.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
23
+ lionagi/datastores/lantern.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
24
+ lionagi/datastores/pinecone.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
25
+ lionagi/datastores/postgres.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
26
+ lionagi/datastores/qdrant.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
27
+ lionagi/endpoints/__init__.py,sha256=MqnVoSV0nalTRO_Lo29A_YkWLPrk_nwV4tQLe31qJH8,79
28
+ lionagi/endpoints/assistants.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ lionagi/endpoints/audio.py,sha256=D4ajEj41sATuc2XUKrbbIRrHBPoai1N100tfeDxq5qc,583
30
+ lionagi/endpoints/chatcompletion.py,sha256=ZgPKqD5vmMVV5sE-YSE2HloAYqVtuez9vBeTp4MkSB0,2372
31
+ lionagi/endpoints/embeddings.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
+ lionagi/endpoints/finetune.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
+ lionagi/endpoints/image.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
+ lionagi/endpoints/moderation.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
+ lionagi/endpoints/vision.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
+ lionagi/loaders/__init__.py,sha256=vOOwHkdI0yIA_jV_pNyOrdkS5Ghs0k4od75S1U60jJE,451
37
+ lionagi/loaders/chunker.py,sha256=c0K2cOpoNaHpo2IiB9L-z4rSzAiJJU5g9m-ooIUEE2Q,6156
38
+ lionagi/loaders/load_util.py,sha256=FD22-6dSdD6lpZTfaW6P7o_s5W4cLhIBKRUlMSMrnMk,8370
39
+ lionagi/loaders/reader.py,sha256=f7wBeA-SP5ACCYhxWp5IJv54W9_91YvWH4bq3vNj9qg,4315
40
+ lionagi/messages/__init__.py,sha256=szTxFuRTpJlWK6XvNR1NgG8KA9UwSq7WYXh4B8rP8TU,201
41
+ lionagi/messages/instruction.py,sha256=ghCDvJJwq8cjhog3A6PhDxcVFiCih2LYWLrk1luhiDI,447
42
+ lionagi/messages/message.py,sha256=4sIeaK6dZOrT7vFgN5KqCu1izWOxA0tsGe0EvX7_vgU,3686
43
+ lionagi/messages/response.py,sha256=c-B010THEH5YmRtENzU4k5lHIuEU2C4nzBlezSfuoDI,1423
44
+ lionagi/messages/system.py,sha256=I5tDx_1GAcxpBcuTj7KUNOoZ6R4vH5YByjrg7apOzcw,331
45
+ lionagi/objs/__init__.py,sha256=rF2eWSV-bIwuAMNyPVo_TzVxdFfA0gA9hIFuZK_iya0,237
46
+ lionagi/objs/abc_objs.py,sha256=p3lqQEuPJF7gdtf-VWZuwLmkKvMS4-Ak2PBjlVHESq4,1011
47
+ lionagi/objs/async_queue.py,sha256=ZrqOiXx-qsAweSe0lFYUhqMAok5mGgroZjDV7_EYCCo,4610
48
+ lionagi/objs/messenger.py,sha256=MsWf2FpPNsoF9j99wkjfEuRyHu7fEF1f0jP4nEcXRqQ,2444
49
+ lionagi/objs/status_tracker.py,sha256=6otnTSMrH5jM0PUDiDeK3zG0VOSKfNBDzNN6Bts2tmA,1236
50
+ lionagi/objs/tool_manager.py,sha256=3QUTr_EeItS2PrqBZMOJTcUJ8XCQOCiykJ4C-HXL7lc,9557
51
+ lionagi/schema/__init__.py,sha256=XRWXK9sztycoIMCTzwLEVMxxc1wgWKNUDRbWTpn5Ie0,208
52
+ lionagi/schema/base_condition.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
53
+ lionagi/schema/base_node.py,sha256=QsvnV5_FdbPHSvF6jRtQxnSugB3IreY7VQy2TlqDq7g,8935
54
+ lionagi/schema/base_tool.py,sha256=G--n6upq8ZoHJU5nYch8Q2VrLiozwqWwpR2nP9CANFM,314
55
+ lionagi/schema/data_logger.py,sha256=Nvovj7I5FdxsI3KewwowexbFWp-61HTvGMaSiDIoxd4,3218
56
+ lionagi/schema/data_node.py,sha256=ChdYfVsrNt01R4qNt6kiWinzSdKet3bRBbdoA3xTUos,950
57
+ lionagi/services/__init__.py,sha256=bcRRZBM6L2jgGzOW9o8hxnZb3d_b6fgc3rZUhWThbnk,247
58
+ lionagi/services/anthropic.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
59
+ lionagi/services/anyscale.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
+ lionagi/services/azure.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
61
+ lionagi/services/base_api_service.py,sha256=x9bvHwEn-uKQlWvHcR3Gw07n9ym_E857RAIhE6NkGZc,10183
62
+ lionagi/services/bedrock.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
+ lionagi/services/everlyai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
+ lionagi/services/gemini.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
+ lionagi/services/gpt4all.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
+ lionagi/services/huggingface.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
+ lionagi/services/litellm.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
68
+ lionagi/services/localai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
+ lionagi/services/mistralai.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
+ lionagi/services/oai.py,sha256=ocuaX4jcqEwZUi9ffbk7qCnLK7NL-b1mAaJ-r-ZBMtY,1122
71
+ lionagi/services/ollama.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
72
+ lionagi/services/openllm.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
+ lionagi/services/openrouter.py,sha256=muyQxS7vzyq_Z02IoRE7q4TQHZVZ8rYKpnC5SUdXDis,1107
74
+ lionagi/services/perplexity.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
75
+ lionagi/services/predibase.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
+ lionagi/services/rungpt.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
+ lionagi/services/vllm.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
78
+ lionagi/services/xinference.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
79
+ lionagi/structures/__init__.py,sha256=wMPekT2vbWwUkJ5aW5o-lzJC9Fzhta6RHDiFPTNUm_0,120
80
+ lionagi/structures/graph.py,sha256=dfuW7aYMIvtJNLUTJ-ZBTxMz4B60olUjL4ZI5G_NdXc,4040
81
+ lionagi/structures/relationship.py,sha256=crMyKTY-iqErRLCBaJb5PHnln_s7jJYtHZm9zaRh8tg,4641
82
+ lionagi/structures/structure.py,sha256=ahjYgsT85N9cLD6GwQWfSpwmqM8Lz9UcqqrY6rbd_gI,3098
83
+ lionagi/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
84
+ lionagi/tests/test_api_util.py,sha256=of07_X6jEPgEnnnrD7C0F-DU-x-8629jkrDSVSBoE5I,1778
85
+ lionagi/tests/test_call_util.py,sha256=7HSU8-goN5TvFOMhtKspotOMJ9jCawKqxxNFkT2NK0I,4478
86
+ lionagi/tests/test_convert_util.py,sha256=WkiMsGCg7Wv4lp-rtjKkf-ga4vTdJ6pE1zO8grFn4mk,6870
87
+ lionagi/tests/test_encrypt_util.py,sha256=LBwa4_W0_uOiq51xDcAzI6j8LnLlgqiioYS4QSf69tI,1208
88
+ lionagi/tests/test_flat_util.py,sha256=tMztcNE38AiPBW4iYUYg62g3DvNdjvI8srixT8EgHWY,17368
89
+ lionagi/tests/test_io_util.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
90
+ lionagi/tests/test_sys_util.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
91
+ lionagi/tools/__init__.py,sha256=ZEck-ReP5Co05nAA2gUXTpKoDN2QZqrL7DvU9Z09gqg,69
92
+ lionagi/tools/planner.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
93
+ lionagi/tools/prompter.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
94
+ lionagi/tools/scorer.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
95
+ lionagi/tools/summarizer.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
96
+ lionagi/tools/tool_util.py,sha256=cM64AIvOLZLA4gde8FwRrVqlGZXIUWHiGKnNMp_a1_Q,290
97
+ lionagi/tools/validator.py,sha256=chG3GNX2BBDTWIuSVfZUJ_YF_ZVBSoel2d_AN0OChS0,6
98
+ lionagi/utils/__init__.py,sha256=lg3zxTrXTOB2vbQ4BoOaA6JPCWt6gBaeXfeUTj04PFA,1618
99
+ lionagi/utils/api_util.py,sha256=OFi6NbU1MMZ1GGQ4Nz6kwc38D8A8wTXzcxUOywusAOU,2846
100
+ lionagi/utils/call_util.py,sha256=PLbRnElWpyFj5YH6ufdLrKHSsNQQX_daYzgLEtBvKgI,12469
101
+ lionagi/utils/convert_util.py,sha256=HGVTPfiDHcoIsWyoDvCUVSky5QQDoqtQrzU8t0vL0Co,7893
102
+ lionagi/utils/encrypt_util.py,sha256=JBUrLRkgmPgbvLvf20Ufw1SjxI6qx2FlzVZZCKzx3XQ,552
103
+ lionagi/utils/flat_util.py,sha256=RR2c0AwCWG9dI8vLsCE8PIJLQkGlR6kPYL65UnVEaSg,24210
104
+ lionagi/utils/io_util.py,sha256=2nOfHcWR05HhezYFcsDrYGQEGVvX6XE8Q4fUaar8Y6I,3531
105
+ lionagi/utils/sys_util.py,sha256=NNeBEo3QNj0BRlFLtZvWMtwT25u7IOgbcp9Y49-vQ4o,7362
106
+ lionagi-0.0.116.dist-info/LICENSE,sha256=TBnSyG8fs_tMRtK805GzA1cIyExleKyzoN_kuVxT9IY,11358
107
+ lionagi-0.0.116.dist-info/METADATA,sha256=36Zw3nGYhrDfemxXFBXf3674j6exozg10HUD2BpBgb0,18025
108
+ lionagi-0.0.116.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
109
+ lionagi-0.0.116.dist-info/top_level.txt,sha256=szvch_d2jE1Lu9ZIKsl26Ll6BGfYfbOgt5lm-UpFSo4,8
110
+ lionagi-0.0.116.dist-info/RECORD,,
@@ -1,108 +0,0 @@
1
- from .messages import Message
2
-
3
-
4
- class Conversation:
5
- """
6
- A class representing a conversation between users and the assistant.
7
-
8
- This class manages the exchange of messages within a conversation, including system settings,
9
- user instructions, and assistant responses.
10
-
11
- Attributes:
12
- response_counts (int):
13
- The count of assistant responses in the conversation.
14
- messages (list):
15
- A list to store messages in the conversation.
16
- msg (Message):
17
- An instance of the Message class for creating messages.
18
- responses (list):
19
- A list to store assistant responses in the conversation.
20
-
21
- Methods:
22
- initiate_conversation(system, instruction, context=None, name=None):
23
- Initiate a conversation with a system setting and user instruction.
24
-
25
- add_messages(system, instruction, context=None, response=None, tool=None, name=None):
26
- Add messages to the conversation, including system setting, user instruction, and assistant response.
27
-
28
- change_system(system):
29
- Change the system setting in the conversation.
30
-
31
- keep_last_n_exchanges(n: int):
32
- Keep the last n exchanges in the conversation.
33
- """
34
- response_counts = 0
35
-
36
- def __init__(self, messages=None) -> None:
37
- """
38
- Initialize a Conversation object.
39
-
40
- Parameters:
41
- messages (list): A list of messages to initialize the conversation. Default is None.
42
-
43
- """
44
- self.messages = messages or []
45
- self.msg = Message()
46
- self.responses = []
47
-
48
- def initiate_conversation(self, system=None, instruction=None, context=None, name=None):
49
- """
50
- Initiate a conversation with a system setting and user instruction.
51
-
52
- Parameters:
53
- system (str): The system setting for the conversation.
54
-
55
- instruction (str): The user instruction to initiate the conversation.
56
-
57
- context (dict): Additional context for the conversation. Default is None.
58
-
59
- name (str): The name associated with the user. Default is None.
60
- """
61
- self.messages, self.responses = [], []
62
- self.add_messages(system=system)
63
- self.add_messages(instruction=instruction, context=context, name=name)
64
-
65
- # modify the message adding to accomodate tools
66
- def add_messages(self, system=None, instruction=None, context=None, response=None, name=None):
67
- """
68
- Add messages to the conversation, including system setting, user instruction, and assistant response.
69
-
70
- Parameters:
71
- system (str): The system setting for the message. Default is None.
72
-
73
- instruction (str): The instruction content for the message. Default is None.
74
-
75
- context (dict): Additional context for the message. Default is None.
76
-
77
- response (dict): The response content for the message. Default is None.
78
-
79
- name (str): The name associated with the message. Default is None.
80
- """
81
- msg = self.msg(system=system, instruction=instruction, context=context,
82
- response=response, name=name)
83
- self.messages.append(msg)
84
-
85
- def change_system(self, system):
86
- """
87
- Change the system setting in the conversation.
88
-
89
- Parameters:
90
- system (str): The new system setting for the conversation.
91
- """
92
- self.messages[0] = self.msg(system=system)
93
-
94
- def keep_last_n_exchanges(self, n: int):
95
- """
96
- Keep the last n exchanges in the conversation.
97
-
98
- Parameters:
99
- n (int): The number of exchanges to keep.
100
- """
101
- # keep last n_exchanges, one exchange is marked by one assistant response
102
- response_indices = [
103
- index for index, message in enumerate(self.messages[1:]) if message["role"] == "assistant"
104
- ]
105
- if len(response_indices) >= n:
106
- first_index_to_keep = response_indices[-n] + 1
107
- self.messages = [self.system] + self.messages[first_index_to_keep:]
108
-
lionagi/core/flows.py DELETED
@@ -1 +0,0 @@
1
- # represents structured sessions
@@ -1 +0,0 @@
1
- # dynamically structured preconfigured instructions
lionagi/core/messages.py DELETED
@@ -1,166 +0,0 @@
1
- from datetime import datetime
2
- import json
3
- from ..utils import create_id, lcall
4
- from ..schema import DataLogger
5
-
6
-
7
- class Message:
8
- """
9
- A class representing a message in a conversation.
10
-
11
- This class encapsulates messages from users, the assistant, systems, and external tools.
12
-
13
- Attributes:
14
- role (str):
15
- The role of the message, indicating if it's from the user, assistant, system, or tool.
16
- content:
17
- The content of the message, which can be an instruction, response, system setting, or tool information.
18
- name (str):
19
- The name associated with the message, specifying the source (user, assistant, system, or tool).
20
- metadata (dict):
21
- Additional metadata including id, timestamp, and name.
22
- _logger (DataLogger):
23
- An instance of the DataLogger class for logging message details.
24
-
25
- Methods:
26
- create_message(system, instruction, context, response, tool, name):
27
- Create a message based on the provided information.
28
-
29
- to_json() -> dict:
30
- Convert the message to a JSON format.
31
-
32
- __call__(system, instruction, context, response, name, tool) -> dict:
33
- Create and return a message in JSON format.
34
-
35
- to_csv(dir, filename, verbose, timestamp, dir_exist_ok, file_exist_ok):
36
- Save the message to a CSV file.
37
- """
38
- def __init__(self) -> None:
39
- """
40
- Initialize a Message object.
41
- """
42
- self.role = None
43
- self.content = None
44
- self.name = None
45
- self.metadata = None
46
- self._logger = DataLogger()
47
-
48
- def create_message(self, system=None, instruction=None, context=None, response=None, name=None):
49
-
50
- """
51
- Create a message based on the provided information.
52
-
53
- Parameters:
54
- system (str): The system setting for the message. Default is None.
55
-
56
- instruction (str): The instruction content for the message. Default is None.
57
-
58
- context (dict): Additional context for the message. Default is None.
59
-
60
- response (dict): The response content for the message. Default is None.
61
-
62
- name (str): The name associated with the message. Default is None.
63
- """
64
- if sum(lcall([system, instruction, response], bool)) > 1:
65
- raise ValueError("Error: Message cannot have more than one role.")
66
-
67
- else:
68
- if response:
69
- self.role = "assistant"
70
- try:
71
- response = response["message"]
72
- if str(response['content']) == "None":
73
- try:
74
- tool_count = 0
75
- func_list = []
76
- while tool_count < len(response['tool_calls']):
77
- if response['tool_calls'][tool_count]['type'] == 'function':
78
- func_content = {"function": ("func_" + response['tool_calls'][tool_count]['function']['name']),
79
- "arguments": response['tool_calls'][tool_count]['function']['arguments']}
80
- func_list.append(func_content)
81
- tool_count += 1
82
-
83
- self.name = name or "func_request"
84
- self.content = {'function_list': func_list}
85
- except:
86
- raise ValueError("Response message must be one of regular response or function calling")
87
- else:
88
- self.content = response['content']
89
- self.name = name or "assistant"
90
- except:
91
- self.name = name or "func_call"
92
- self.content = response
93
-
94
- elif instruction:
95
- self.role = "user"
96
- self.content = {"instruction": instruction}
97
- self.name = name or "user"
98
- if context:
99
- self.content.update({"context": context})
100
- elif system:
101
- self.role = "system"
102
- self.content = system
103
- self.name = name or "system"
104
-
105
- def to_json(self):
106
- """
107
- Convert the message to a JSON format.
108
-
109
- Returns:
110
- dict: The message in JSON format.
111
- """
112
- out = {
113
- "role": self.role,
114
- "content": json.dumps(self.content) if isinstance(self.content, dict) else self.content
115
- }
116
-
117
- self.metadata = {
118
- "id": create_id(),
119
- "timestamp": datetime.now().isoformat(),
120
- "name": self.name}
121
-
122
- self._logger({**self.metadata, **out})
123
- return out
124
-
125
- def __call__(self, system=None, instruction=None, context=None,
126
- response=None, name=None):
127
- """
128
- Create and return a message in JSON format.
129
-
130
- Parameters:
131
- system (str): The system setting for the message. Default is None.
132
-
133
- instruction (str): The instruction content for the message. Default is None.
134
-
135
- context (dict): Additional context for the message. Default is None.
136
-
137
- response (dict): The response content for the message. Default is None.
138
-
139
- name (str): The name associated with the message. Default is None.
140
-
141
- Returns:
142
- dict: The message in JSON format.
143
- """
144
- self.create_message(system=system, instruction=instruction,
145
- context=context, response=response, name=name)
146
- return self.to_json()
147
-
148
- def to_csv(self, filename=None,dir=None, verbose=True, timestamp=True, dir_exist_ok=True, file_exist_ok=False):
149
- """
150
- Save the message to a CSV file.
151
-
152
- Parameters:
153
- dir (str): The directory path for saving the CSV file. Default is None.
154
-
155
- filename (str): The filename for the CSV file. Default is None.
156
-
157
- verbose (bool): Whether to include verbose information in the CSV. Default is True.
158
-
159
- timestamp (bool): Whether to include timestamps in the CSV. Default is True.
160
-
161
- dir_exist_ok (bool): Whether to allow the directory to exist. Default is True.
162
-
163
- file_exist_ok (bool): Whether to allow the file to exist. Default is False.
164
- """
165
- self._logger.to_csv(filename,dir=dir, verbose=verbose, timestamp=timestamp, dir_exist_ok=dir_exist_ok, file_exist_ok=file_exist_ok)
166
-