lionagi 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. lionagi/core/agent/base_agent.py +2 -3
  2. lionagi/core/branch/base.py +1 -1
  3. lionagi/core/branch/branch.py +2 -1
  4. lionagi/core/branch/flow_mixin.py +1 -1
  5. lionagi/core/branch/util.py +1 -1
  6. lionagi/core/execute/base_executor.py +1 -4
  7. lionagi/core/execute/branch_executor.py +66 -3
  8. lionagi/core/execute/instruction_map_executor.py +48 -0
  9. lionagi/core/execute/neo4j_executor.py +381 -0
  10. lionagi/core/execute/structure_executor.py +120 -4
  11. lionagi/core/flow/monoflow/ReAct.py +21 -19
  12. lionagi/core/flow/monoflow/chat_mixin.py +1 -1
  13. lionagi/core/flow/monoflow/followup.py +14 -13
  14. lionagi/core/flow/polyflow/__init__.py +1 -1
  15. lionagi/core/generic/component.py +197 -122
  16. lionagi/core/generic/condition.py +3 -1
  17. lionagi/core/generic/edge.py +77 -25
  18. lionagi/core/graph/graph.py +1 -1
  19. lionagi/core/mail/mail_manager.py +3 -2
  20. lionagi/core/session/session.py +1 -1
  21. lionagi/core/tool/tool_manager.py +10 -9
  22. lionagi/experimental/__init__.py +0 -0
  23. lionagi/experimental/directive/__init__.py +0 -0
  24. lionagi/experimental/directive/evaluator/__init__.py +0 -0
  25. lionagi/experimental/directive/evaluator/ast_evaluator.py +115 -0
  26. lionagi/experimental/directive/evaluator/base_evaluator.py +202 -0
  27. lionagi/experimental/directive/evaluator/sandbox_.py +14 -0
  28. lionagi/experimental/directive/evaluator/script_engine.py +83 -0
  29. lionagi/experimental/directive/parser/__init__.py +0 -0
  30. lionagi/experimental/directive/parser/base_parser.py +215 -0
  31. lionagi/experimental/directive/schema.py +36 -0
  32. lionagi/experimental/directive/template_/__init__.py +0 -0
  33. lionagi/experimental/directive/template_/base_template.py +63 -0
  34. lionagi/experimental/report/__init__.py +0 -0
  35. lionagi/experimental/report/form.py +64 -0
  36. lionagi/experimental/report/report.py +138 -0
  37. lionagi/experimental/report/util.py +47 -0
  38. lionagi/experimental/tool/__init__.py +0 -0
  39. lionagi/experimental/tool/function_calling.py +43 -0
  40. lionagi/experimental/tool/manual.py +66 -0
  41. lionagi/experimental/tool/schema.py +59 -0
  42. lionagi/experimental/tool/tool_manager.py +138 -0
  43. lionagi/experimental/tool/util.py +16 -0
  44. lionagi/experimental/validator/__init__.py +0 -0
  45. lionagi/experimental/validator/rule.py +139 -0
  46. lionagi/experimental/validator/validator.py +56 -0
  47. lionagi/experimental/work/__init__.py +10 -0
  48. lionagi/experimental/work/async_queue.py +54 -0
  49. lionagi/experimental/work/schema.py +73 -0
  50. lionagi/experimental/work/work_function.py +67 -0
  51. lionagi/experimental/work/worker.py +56 -0
  52. lionagi/experimental/work2/__init__.py +0 -0
  53. lionagi/experimental/work2/form.py +371 -0
  54. lionagi/experimental/work2/report.py +289 -0
  55. lionagi/experimental/work2/schema.py +30 -0
  56. lionagi/experimental/work2/tests.py +72 -0
  57. lionagi/experimental/work2/util.py +0 -0
  58. lionagi/experimental/work2/work.py +0 -0
  59. lionagi/experimental/work2/work_function.py +89 -0
  60. lionagi/experimental/work2/worker.py +12 -0
  61. lionagi/integrations/bridge/autogen_/__init__.py +0 -0
  62. lionagi/integrations/bridge/autogen_/autogen_.py +124 -0
  63. lionagi/integrations/bridge/llamaindex_/get_index.py +294 -0
  64. lionagi/integrations/bridge/llamaindex_/llama_pack.py +227 -0
  65. lionagi/integrations/bridge/transformers_/__init__.py +0 -0
  66. lionagi/integrations/bridge/transformers_/install_.py +36 -0
  67. lionagi/integrations/config/oai_configs.py +1 -1
  68. lionagi/integrations/config/ollama_configs.py +1 -1
  69. lionagi/integrations/config/openrouter_configs.py +1 -1
  70. lionagi/integrations/storage/__init__.py +3 -0
  71. lionagi/integrations/storage/neo4j.py +673 -0
  72. lionagi/integrations/storage/storage_util.py +289 -0
  73. lionagi/integrations/storage/structure_excel.py +268 -0
  74. lionagi/integrations/storage/to_csv.py +63 -0
  75. lionagi/integrations/storage/to_excel.py +76 -0
  76. lionagi/libs/__init__.py +4 -0
  77. lionagi/libs/ln_knowledge_graph.py +405 -0
  78. lionagi/libs/ln_queue.py +101 -0
  79. lionagi/libs/ln_tokenizer.py +57 -0
  80. lionagi/libs/sys_util.py +1 -1
  81. lionagi/lions/__init__.py +0 -0
  82. lionagi/lions/coder/__init__.py +0 -0
  83. lionagi/lions/coder/add_feature.py +20 -0
  84. lionagi/lions/coder/base_prompts.py +22 -0
  85. lionagi/lions/coder/coder.py +121 -0
  86. lionagi/lions/coder/util.py +91 -0
  87. lionagi/lions/researcher/__init__.py +0 -0
  88. lionagi/lions/researcher/data_source/__init__.py +0 -0
  89. lionagi/lions/researcher/data_source/finhub_.py +191 -0
  90. lionagi/lions/researcher/data_source/google_.py +199 -0
  91. lionagi/lions/researcher/data_source/wiki_.py +96 -0
  92. lionagi/lions/researcher/data_source/yfinance_.py +21 -0
  93. lionagi/tests/libs/test_queue.py +67 -0
  94. lionagi/tests/test_core/generic/__init__.py +0 -0
  95. lionagi/tests/test_core/generic/test_component.py +89 -0
  96. lionagi/tests/test_core/test_branch.py +0 -1
  97. lionagi/version.py +1 -1
  98. {lionagi-0.1.0.dist-info → lionagi-0.1.2.dist-info}/METADATA +1 -1
  99. lionagi-0.1.2.dist-info/RECORD +206 -0
  100. lionagi-0.1.0.dist-info/RECORD +0 -136
  101. {lionagi-0.1.0.dist-info → lionagi-0.1.2.dist-info}/LICENSE +0 -0
  102. {lionagi-0.1.0.dist-info → lionagi-0.1.2.dist-info}/WHEEL +0 -0
  103. {lionagi-0.1.0.dist-info → lionagi-0.1.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,227 @@
1
+ class LlamaPack:
2
+
3
+ @staticmethod
4
+ def download(pack_name, pack_path):
5
+ try:
6
+ from llama_index.llama_pack import download_llama_pack
7
+
8
+ return download_llama_pack(pack_name, pack_path)
9
+ except Exception as e:
10
+ raise ImportError(f"Error in downloading llama pack: {e}")
11
+
12
+ @staticmethod
13
+ def build(pack_name, pack_path, args=[], **kwargs):
14
+ pack = LlamaPack.download(pack_name, pack_path)
15
+ return pack(*args, **kwargs)
16
+
17
+ @staticmethod
18
+ def stock_market_pack(pack_path="./stock_market_data_pack", args=[], **kwargs):
19
+ name_ = "StockMarketDataQueryEnginePack"
20
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
21
+
22
+ @staticmethod
23
+ def embedded_table_pack(
24
+ pack_path="./embedded_tables_unstructured_pack", args=[], **kwargs
25
+ ):
26
+ name_ = "RecursiveRetrieverSmallToBigPack"
27
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
28
+
29
+ @staticmethod
30
+ def rag_evaluator_pack(pack_path="./rag_evaluator_pack", args=[], **kwargs):
31
+ name_ = "RagEvaluatorPack"
32
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
33
+
34
+ @staticmethod
35
+ def ollma_pack(pack_path="./ollama_pack", args=[], **kwargs):
36
+ name_ = "OllamaQueryEnginePack"
37
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
38
+
39
+ @staticmethod
40
+ def llm_compiler_agent_pack(
41
+ pack_path="./llm_compiler_agent_pack", args=[], **kwargs
42
+ ):
43
+ name_ = "LLMCompilerAgentPack"
44
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
45
+
46
+ @staticmethod
47
+ def resume_screener_pack(pack_path="./resume_screener_pack", args=[], **kwargs):
48
+ name_ = "ResumeScreenerPack"
49
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
50
+
51
+ @staticmethod
52
+ def ragatouille_retriever_pack(pack_path="./ragatouille_pack", args=[], **kwargs):
53
+ name_ = "RAGatouilleRetrieverPack"
54
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
55
+
56
+ @staticmethod
57
+ def chain_of_table_pack(pack_path="./chain_of_table_pack", args=[], **kwargs):
58
+ name_ = "ChainOfTablePack"
59
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
60
+
61
+ @staticmethod
62
+ def hybrid_fusion_retriever_pack(
63
+ pack_path="./hybrid_fusion_pack", args=[], **kwargs
64
+ ):
65
+ name_ = "HybridFusionRetrieverPack"
66
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
67
+
68
+ @staticmethod
69
+ def neo4j_query_engine_pack(pack_path="./neo4j_pack", args=[], **kwargs):
70
+ name_ = "Neo4jQueryEnginePack"
71
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
72
+
73
+ @staticmethod
74
+ def llava_completion_pack(pack_path="./llava_pack", args=[], **kwargs):
75
+ name_ = "LlavaCompletionPack"
76
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
77
+
78
+ @staticmethod
79
+ def sentence_window_retriever_pack(
80
+ pack_path="./sentence_window_retriever_pack", args=[], **kwargs
81
+ ):
82
+ name_ = "SentenceWindowRetrieverPack"
83
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
84
+
85
+ @staticmethod
86
+ def dense_x_retrieval_pack(pack_path="./dense_pack", args=[], **kwargs):
87
+ name_ = "DenseXRetrievalPack"
88
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
89
+
90
+ @staticmethod
91
+ def zephyr_query_engine_pack(pack_path="./zephyr_pack", args=[], **kwargs):
92
+ name_ = "ZephyrQueryEnginePack"
93
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
94
+
95
+ @staticmethod
96
+ def query_rewriting_retriever_pack(
97
+ pack_path="./query_rewriting_pack", args=[], **kwargs
98
+ ):
99
+ name_ = "QueryRewritingRetrieverPack"
100
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
101
+
102
+ @staticmethod
103
+ def fuzzy_citation_engine_pack(
104
+ pack_path="./fuzzy_citation_pack", args=[], **kwargs
105
+ ):
106
+ name_ = "FuzzyCitationEnginePack"
107
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
108
+
109
+ @staticmethod
110
+ def multidoc_auto_retriever_pack(
111
+ pack_path="./multidoc_autoretrieval_pack", args=[], **kwargs
112
+ ):
113
+ name_ = "MultiDocAutoRetrieverPack"
114
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
115
+
116
+ @staticmethod
117
+ def auto_merging_retriever_pack(
118
+ pack_path="./auto_merging_retriever_pack", args=[], **kwargs
119
+ ):
120
+ name_ = "AutoMergingRetrieverPack"
121
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
122
+
123
+ @staticmethod
124
+ def voyage_query_engine_pack(pack_path="./voyage_pack", args=[], **kwargs):
125
+ name_ = "VoyageQueryEnginePack"
126
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
127
+
128
+ @staticmethod
129
+ def mix_self_consistency_pack(
130
+ pack_path="./mix_self_consistency_pack", args=[], **kwargs
131
+ ):
132
+ name_ = "MixSelfConsistencyPack"
133
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
134
+
135
+ @staticmethod
136
+ def rag_fusion_pipeline_pack(
137
+ pack_path="./rag_fusion_pipeline_pack", args=[], **kwargs
138
+ ):
139
+ name_ = "RAGFusionPipelinePack"
140
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
141
+
142
+ @staticmethod
143
+ def multi_document_agents_pack(
144
+ pack_path="./multi_doc_agents_pack", args=[], **kwargs
145
+ ):
146
+ name_ = "MultiDocumentAgentsPack"
147
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
148
+
149
+ @staticmethod
150
+ def llama_guard_moderator_pack(pack_path="./llamaguard_pack", args=[], **kwargs):
151
+ name_ = "LlamaGuardModeratorPack"
152
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
153
+
154
+ @staticmethod
155
+ def evaluator_benchmarker_pack(
156
+ pack_path="./eval_benchmark_pack", args=[], **kwargs
157
+ ):
158
+ name_ = "EvaluatorBenchmarkerPack"
159
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
160
+
161
+ @staticmethod
162
+ def amazon_product_extraction_pack(
163
+ pack_path="./amazon_product_extraction_pack", args=[], **kwargs
164
+ ):
165
+ name_ = "AmazonProductExtractionPack"
166
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
167
+
168
+ @staticmethod
169
+ def llama_dataset_metadata_pack(
170
+ pack_path="./llama_dataset_metadata_pack", args=[], **kwargs
171
+ ):
172
+ name_ = "LlamaDatasetMetadataPack"
173
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
174
+
175
+ @staticmethod
176
+ def multi_tenancy_rag_pack(pack_path="./multitenancy_rag_pack", args=[], **kwargs):
177
+ name_ = "MultiTenancyRAGPack"
178
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
179
+
180
+ @staticmethod
181
+ def gmail_openai_agent_pack(pack_path="./gmail_pack", args=[], **kwargs):
182
+ name_ = "GmailOpenAIAgentPack"
183
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
184
+
185
+ @staticmethod
186
+ def snowflake_query_engine_pack(pack_path="./snowflake_pack", args=[], **kwargs):
187
+ name_ = "SnowflakeQueryEnginePack"
188
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
189
+
190
+ @staticmethod
191
+ def agent_search_retriever_pack(pack_path="./agent_search_pack", args=[], **kwargs):
192
+ name_ = "AgentSearchRetrieverPack"
193
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
194
+
195
+ @staticmethod
196
+ def vectara_rag_pack(pack_path="./vectara_rag_pack", args=[], **kwargs):
197
+ name_ = "VectaraRagPack"
198
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
199
+
200
+ @staticmethod
201
+ def chroma_autoretrieval_pack(pack_path="./chroma_pack", args=[], **kwargs):
202
+ name_ = "ChromaAutoretrievalPack"
203
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
204
+
205
+ @staticmethod
206
+ def arize_phoenix_query_engine_pack(pack_path="./arize_pack", args=[], **kwargs):
207
+ name_ = "ArizePhoenixQueryEnginePack"
208
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
209
+
210
+ @staticmethod
211
+ def redis_ingestion_pipeline_pack(
212
+ pack_path="./redis_ingestion_pack", args=[], **kwargs
213
+ ):
214
+ name_ = "RedisIngestionPipelinePack"
215
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
216
+
217
+ @staticmethod
218
+ def nebula_graph_query_engine_pack(
219
+ pack_path="./nebulagraph_pack", args=[], **kwargs
220
+ ):
221
+ name_ = "NebulaGraphQueryEnginePack"
222
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
223
+
224
+ @staticmethod
225
+ def weaviate_retry_engine_pack(pack_path="./weaviate_pack", args=[], **kwargs):
226
+ name_ = "WeaviateRetryEnginePack"
227
+ return LlamaPack.build(name_, pack_path, args, **kwargs)
File without changes
@@ -0,0 +1,36 @@
1
+ import subprocess
2
+ from lionagi.libs import SysUtil
3
+
4
+
5
+ def get_pytorch_install_command():
6
+ cpu_arch = SysUtil.get_cpu_architecture()
7
+
8
+ if cpu_arch == "apple_silicon":
9
+ return "pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu"
10
+ else:
11
+ # Default CPU installation
12
+ return "pip install torch torchvision torchaudio"
13
+
14
+
15
+ def install_pytorch():
16
+ command = get_pytorch_install_command()
17
+ try:
18
+ subprocess.run(command.split(), check=True)
19
+ print("PyTorch installed successfully.")
20
+ except subprocess.CalledProcessError as e:
21
+ print(f"Failed to install PyTorch: {e}")
22
+
23
+
24
+ def install_transformers():
25
+ if not SysUtil.is_package_installed("torch"):
26
+ in_ = input(
27
+ "PyTorch is required for transformers. Would you like to install it now? (y/n): "
28
+ )
29
+ if in_ == "y":
30
+ install_pytorch()
31
+ if not SysUtil.is_package_installed("transformers"):
32
+ in_ = input(
33
+ "transformers is required. Would you like to install it now? (y/n): "
34
+ )
35
+ if in_ == "y":
36
+ SysUtil.install_import(package_name="transformers", import_name="pipeline")
@@ -2,7 +2,7 @@
2
2
 
3
3
  # ChatCompletion
4
4
  oai_chat_llmconfig = {
5
- "model": "gpt-4-turbo-preview",
5
+ "model": "gpt-4-turbo",
6
6
  "frequency_penalty": 0,
7
7
  "max_tokens": None,
8
8
  "n": 1,
@@ -1 +1 @@
1
- model = "llama2"
1
+ model = "llama3"
@@ -1,5 +1,5 @@
1
1
  openrouter_chat_llmconfig = {
2
- "model": "gpt-4-turbo-preview",
2
+ "model": "gpt-4-turbo",
3
3
  "frequency_penalty": 0,
4
4
  "max_tokens": None,
5
5
  "num": 1,
@@ -0,0 +1,3 @@
1
+ from lionagi.integrations.storage.neo4j import Neo4j
2
+
3
+ __all__ = ["Neo4j"]