cognee 0.2.1.dev7__py3-none-any.whl → 0.2.2.dev1__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.
Files changed (223) hide show
  1. cognee/api/client.py +44 -4
  2. cognee/api/health.py +332 -0
  3. cognee/api/v1/add/add.py +5 -2
  4. cognee/api/v1/add/routers/get_add_router.py +3 -0
  5. cognee/api/v1/cognify/code_graph_pipeline.py +3 -1
  6. cognee/api/v1/cognify/cognify.py +8 -0
  7. cognee/api/v1/cognify/routers/get_cognify_router.py +8 -1
  8. cognee/api/v1/config/config.py +3 -1
  9. cognee/api/v1/datasets/routers/get_datasets_router.py +2 -8
  10. cognee/api/v1/delete/delete.py +16 -12
  11. cognee/api/v1/responses/routers/get_responses_router.py +3 -1
  12. cognee/api/v1/search/search.py +10 -0
  13. cognee/api/v1/settings/routers/get_settings_router.py +0 -2
  14. cognee/base_config.py +1 -0
  15. cognee/eval_framework/evaluation/direct_llm_eval_adapter.py +5 -6
  16. cognee/infrastructure/databases/graph/config.py +2 -0
  17. cognee/infrastructure/databases/graph/get_graph_engine.py +58 -12
  18. cognee/infrastructure/databases/graph/graph_db_interface.py +15 -10
  19. cognee/infrastructure/databases/graph/kuzu/adapter.py +43 -16
  20. cognee/infrastructure/databases/graph/kuzu/kuzu_migrate.py +281 -0
  21. cognee/infrastructure/databases/graph/neo4j_driver/adapter.py +151 -77
  22. cognee/infrastructure/databases/graph/neptune_driver/__init__.py +15 -0
  23. cognee/infrastructure/databases/graph/neptune_driver/adapter.py +1427 -0
  24. cognee/infrastructure/databases/graph/neptune_driver/exceptions.py +115 -0
  25. cognee/infrastructure/databases/graph/neptune_driver/neptune_utils.py +224 -0
  26. cognee/infrastructure/databases/graph/networkx/adapter.py +3 -3
  27. cognee/infrastructure/databases/hybrid/neptune_analytics/NeptuneAnalyticsAdapter.py +449 -0
  28. cognee/infrastructure/databases/relational/sqlalchemy/SqlAlchemyAdapter.py +11 -3
  29. cognee/infrastructure/databases/vector/chromadb/ChromaDBAdapter.py +8 -3
  30. cognee/infrastructure/databases/vector/create_vector_engine.py +31 -23
  31. cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +3 -1
  32. cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +21 -6
  33. cognee/infrastructure/databases/vector/embeddings/OllamaEmbeddingEngine.py +4 -3
  34. cognee/infrastructure/databases/vector/embeddings/get_embedding_engine.py +3 -1
  35. cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py +22 -16
  36. cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py +36 -34
  37. cognee/infrastructure/databases/vector/vector_db_interface.py +78 -7
  38. cognee/infrastructure/files/utils/get_data_file_path.py +39 -0
  39. cognee/infrastructure/files/utils/guess_file_type.py +2 -2
  40. cognee/infrastructure/files/utils/open_data_file.py +4 -23
  41. cognee/infrastructure/llm/LLMGateway.py +137 -0
  42. cognee/infrastructure/llm/__init__.py +14 -4
  43. cognee/infrastructure/llm/config.py +29 -1
  44. cognee/infrastructure/llm/prompts/answer_hotpot_question.txt +1 -1
  45. cognee/infrastructure/llm/prompts/answer_hotpot_using_cognee_search.txt +1 -1
  46. cognee/infrastructure/llm/prompts/answer_simple_question.txt +1 -1
  47. cognee/infrastructure/llm/prompts/answer_simple_question_restricted.txt +1 -1
  48. cognee/infrastructure/llm/prompts/categorize_categories.txt +1 -1
  49. cognee/infrastructure/llm/prompts/classify_content.txt +1 -1
  50. cognee/infrastructure/llm/prompts/context_for_question.txt +1 -1
  51. cognee/infrastructure/llm/prompts/graph_context_for_question.txt +1 -1
  52. cognee/infrastructure/llm/prompts/natural_language_retriever_system.txt +1 -1
  53. cognee/infrastructure/llm/prompts/patch_gen_instructions.txt +1 -1
  54. cognee/infrastructure/llm/prompts/search_type_selector_prompt.txt +130 -0
  55. cognee/infrastructure/llm/prompts/summarize_code.txt +2 -2
  56. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/__init__.py +57 -0
  57. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/async_client.py +533 -0
  58. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/config.py +94 -0
  59. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/globals.py +37 -0
  60. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/inlinedbaml.py +21 -0
  61. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/parser.py +131 -0
  62. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/runtime.py +266 -0
  63. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/stream_types.py +137 -0
  64. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/sync_client.py +550 -0
  65. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/tracing.py +26 -0
  66. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_builder.py +962 -0
  67. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_map.py +52 -0
  68. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/types.py +166 -0
  69. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_categories.baml +109 -0
  70. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_content_graph.baml +343 -0
  71. cognee/{modules/data → infrastructure/llm/structured_output_framework/baml/baml_src}/extraction/__init__.py +1 -0
  72. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_summary.py +89 -0
  73. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/extract_content_graph.py +33 -0
  74. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/generators.baml +18 -0
  75. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/extraction/__init__.py +3 -0
  76. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/extraction/extract_categories.py +12 -0
  77. cognee/{modules/data → infrastructure/llm/structured_output_framework/litellm_instructor}/extraction/extract_summary.py +16 -7
  78. cognee/{modules/data → infrastructure/llm/structured_output_framework/litellm_instructor}/extraction/knowledge_graph/extract_content_graph.py +7 -6
  79. cognee/infrastructure/llm/{anthropic → structured_output_framework/litellm_instructor/llm/anthropic}/adapter.py +10 -4
  80. cognee/infrastructure/llm/{gemini → structured_output_framework/litellm_instructor/llm/gemini}/adapter.py +6 -5
  81. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/generic_llm_api/__init__.py +0 -0
  82. cognee/infrastructure/llm/{generic_llm_api → structured_output_framework/litellm_instructor/llm/generic_llm_api}/adapter.py +7 -3
  83. cognee/infrastructure/llm/{get_llm_client.py → structured_output_framework/litellm_instructor/llm/get_llm_client.py} +18 -6
  84. cognee/infrastructure/llm/{llm_interface.py → structured_output_framework/litellm_instructor/llm/llm_interface.py} +2 -2
  85. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/ollama/__init__.py +0 -0
  86. cognee/infrastructure/llm/{ollama → structured_output_framework/litellm_instructor/llm/ollama}/adapter.py +4 -2
  87. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/openai/__init__.py +0 -0
  88. cognee/infrastructure/llm/{openai → structured_output_framework/litellm_instructor/llm/openai}/adapter.py +6 -4
  89. cognee/infrastructure/llm/{rate_limiter.py → structured_output_framework/litellm_instructor/llm/rate_limiter.py} +0 -5
  90. cognee/infrastructure/llm/tokenizer/Gemini/adapter.py +4 -2
  91. cognee/infrastructure/llm/tokenizer/TikToken/adapter.py +7 -3
  92. cognee/infrastructure/llm/tokenizer/__init__.py +4 -0
  93. cognee/infrastructure/llm/utils.py +3 -1
  94. cognee/infrastructure/loaders/LoaderEngine.py +156 -0
  95. cognee/infrastructure/loaders/LoaderInterface.py +73 -0
  96. cognee/infrastructure/loaders/__init__.py +18 -0
  97. cognee/infrastructure/loaders/core/__init__.py +7 -0
  98. cognee/infrastructure/loaders/core/audio_loader.py +98 -0
  99. cognee/infrastructure/loaders/core/image_loader.py +114 -0
  100. cognee/infrastructure/loaders/core/text_loader.py +90 -0
  101. cognee/infrastructure/loaders/create_loader_engine.py +32 -0
  102. cognee/infrastructure/loaders/external/__init__.py +22 -0
  103. cognee/infrastructure/loaders/external/pypdf_loader.py +96 -0
  104. cognee/infrastructure/loaders/external/unstructured_loader.py +127 -0
  105. cognee/infrastructure/loaders/get_loader_engine.py +18 -0
  106. cognee/infrastructure/loaders/supported_loaders.py +18 -0
  107. cognee/infrastructure/loaders/use_loader.py +21 -0
  108. cognee/infrastructure/loaders/utils/__init__.py +0 -0
  109. cognee/modules/data/methods/__init__.py +1 -0
  110. cognee/modules/data/methods/get_authorized_dataset.py +23 -0
  111. cognee/modules/data/models/Data.py +13 -3
  112. cognee/modules/data/processing/document_types/AudioDocument.py +2 -2
  113. cognee/modules/data/processing/document_types/ImageDocument.py +2 -2
  114. cognee/modules/data/processing/document_types/PdfDocument.py +4 -11
  115. cognee/modules/data/processing/document_types/UnstructuredDocument.py +2 -5
  116. cognee/modules/engine/utils/generate_edge_id.py +5 -0
  117. cognee/modules/graph/cognee_graph/CogneeGraph.py +45 -35
  118. cognee/modules/graph/methods/get_formatted_graph_data.py +8 -2
  119. cognee/modules/graph/utils/get_graph_from_model.py +93 -101
  120. cognee/modules/ingestion/data_types/TextData.py +8 -2
  121. cognee/modules/ingestion/save_data_to_file.py +1 -1
  122. cognee/modules/pipelines/exceptions/__init__.py +1 -0
  123. cognee/modules/pipelines/exceptions/exceptions.py +12 -0
  124. cognee/modules/pipelines/models/DataItemStatus.py +5 -0
  125. cognee/modules/pipelines/models/PipelineRunInfo.py +6 -0
  126. cognee/modules/pipelines/models/__init__.py +1 -0
  127. cognee/modules/pipelines/operations/pipeline.py +10 -2
  128. cognee/modules/pipelines/operations/run_tasks.py +252 -20
  129. cognee/modules/pipelines/operations/run_tasks_distributed.py +1 -1
  130. cognee/modules/retrieval/chunks_retriever.py +23 -1
  131. cognee/modules/retrieval/code_retriever.py +66 -9
  132. cognee/modules/retrieval/completion_retriever.py +11 -9
  133. cognee/modules/retrieval/context_providers/TripletSearchContextProvider.py +0 -2
  134. cognee/modules/retrieval/graph_completion_context_extension_retriever.py +0 -2
  135. cognee/modules/retrieval/graph_completion_cot_retriever.py +8 -9
  136. cognee/modules/retrieval/graph_completion_retriever.py +1 -1
  137. cognee/modules/retrieval/insights_retriever.py +4 -0
  138. cognee/modules/retrieval/natural_language_retriever.py +9 -15
  139. cognee/modules/retrieval/summaries_retriever.py +23 -1
  140. cognee/modules/retrieval/utils/brute_force_triplet_search.py +23 -4
  141. cognee/modules/retrieval/utils/completion.py +6 -9
  142. cognee/modules/retrieval/utils/description_to_codepart_search.py +2 -3
  143. cognee/modules/search/methods/search.py +5 -1
  144. cognee/modules/search/operations/__init__.py +1 -0
  145. cognee/modules/search/operations/select_search_type.py +42 -0
  146. cognee/modules/search/types/SearchType.py +1 -0
  147. cognee/modules/settings/get_settings.py +0 -8
  148. cognee/modules/settings/save_vector_db_config.py +1 -1
  149. cognee/shared/data_models.py +3 -1
  150. cognee/shared/logging_utils.py +0 -5
  151. cognee/tasks/chunk_naive_llm_classifier/chunk_naive_llm_classifier.py +2 -2
  152. cognee/tasks/documents/extract_chunks_from_documents.py +10 -12
  153. cognee/tasks/entity_completion/entity_extractors/llm_entity_extractor.py +4 -6
  154. cognee/tasks/graph/cascade_extract/utils/extract_content_nodes_and_relationship_names.py +4 -6
  155. cognee/tasks/graph/cascade_extract/utils/extract_edge_triplets.py +6 -7
  156. cognee/tasks/graph/cascade_extract/utils/extract_nodes.py +4 -7
  157. cognee/tasks/graph/extract_graph_from_code.py +3 -2
  158. cognee/tasks/graph/extract_graph_from_data.py +4 -3
  159. cognee/tasks/graph/infer_data_ontology.py +5 -6
  160. cognee/tasks/ingestion/data_item_to_text_file.py +79 -0
  161. cognee/tasks/ingestion/ingest_data.py +91 -61
  162. cognee/tasks/ingestion/resolve_data_directories.py +3 -0
  163. cognee/tasks/repo_processor/get_repo_file_dependencies.py +3 -0
  164. cognee/tasks/storage/index_data_points.py +1 -1
  165. cognee/tasks/storage/index_graph_edges.py +4 -1
  166. cognee/tasks/summarization/summarize_code.py +2 -3
  167. cognee/tasks/summarization/summarize_text.py +3 -2
  168. cognee/tests/test_cognee_server_start.py +12 -7
  169. cognee/tests/test_deduplication.py +2 -2
  170. cognee/tests/test_deletion.py +58 -17
  171. cognee/tests/test_graph_visualization_permissions.py +161 -0
  172. cognee/tests/test_neptune_analytics_graph.py +309 -0
  173. cognee/tests/test_neptune_analytics_hybrid.py +176 -0
  174. cognee/tests/{test_weaviate.py → test_neptune_analytics_vector.py} +86 -11
  175. cognee/tests/test_pgvector.py +5 -5
  176. cognee/tests/test_s3.py +1 -6
  177. cognee/tests/unit/infrastructure/databases/test_rate_limiter.py +11 -10
  178. cognee/tests/unit/infrastructure/databases/vector/__init__.py +0 -0
  179. cognee/tests/unit/infrastructure/mock_embedding_engine.py +1 -1
  180. cognee/tests/unit/infrastructure/test_embedding_rate_limiting_realistic.py +5 -5
  181. cognee/tests/unit/infrastructure/test_rate_limiting_realistic.py +6 -4
  182. cognee/tests/unit/infrastructure/test_rate_limiting_retry.py +1 -1
  183. cognee/tests/unit/interfaces/graph/get_graph_from_model_unit_test.py +61 -3
  184. cognee/tests/unit/modules/retrieval/graph_completion_retriever_test.py +84 -9
  185. cognee/tests/unit/modules/search/search_methods_test.py +55 -0
  186. {cognee-0.2.1.dev7.dist-info → cognee-0.2.2.dev1.dist-info}/METADATA +13 -9
  187. {cognee-0.2.1.dev7.dist-info → cognee-0.2.2.dev1.dist-info}/RECORD +203 -164
  188. cognee/infrastructure/databases/vector/pinecone/adapter.py +0 -8
  189. cognee/infrastructure/databases/vector/qdrant/QDrantAdapter.py +0 -514
  190. cognee/infrastructure/databases/vector/qdrant/__init__.py +0 -2
  191. cognee/infrastructure/databases/vector/weaviate_db/WeaviateAdapter.py +0 -527
  192. cognee/infrastructure/databases/vector/weaviate_db/__init__.py +0 -1
  193. cognee/modules/data/extraction/extract_categories.py +0 -14
  194. cognee/tests/test_qdrant.py +0 -99
  195. distributed/Dockerfile +0 -34
  196. distributed/app.py +0 -4
  197. distributed/entrypoint.py +0 -71
  198. distributed/entrypoint.sh +0 -5
  199. distributed/modal_image.py +0 -11
  200. distributed/queues.py +0 -5
  201. distributed/tasks/queued_add_data_points.py +0 -13
  202. distributed/tasks/queued_add_edges.py +0 -13
  203. distributed/tasks/queued_add_nodes.py +0 -13
  204. distributed/test.py +0 -28
  205. distributed/utils.py +0 -19
  206. distributed/workers/data_point_saving_worker.py +0 -93
  207. distributed/workers/graph_saving_worker.py +0 -104
  208. /cognee/infrastructure/databases/{graph/memgraph → hybrid/neptune_analytics}/__init__.py +0 -0
  209. /cognee/infrastructure/{llm → databases/vector/embeddings}/embedding_rate_limiter.py +0 -0
  210. /cognee/infrastructure/{databases/vector/pinecone → llm/structured_output_framework}/__init__.py +0 -0
  211. /cognee/infrastructure/llm/{anthropic → structured_output_framework/baml/baml_src}/__init__.py +0 -0
  212. /cognee/infrastructure/llm/{gemini/__init__.py → structured_output_framework/baml/baml_src/extraction/extract_categories.py} +0 -0
  213. /cognee/infrastructure/llm/{generic_llm_api → structured_output_framework/baml/baml_src/extraction/knowledge_graph}/__init__.py +0 -0
  214. /cognee/infrastructure/llm/{ollama → structured_output_framework/litellm_instructor}/__init__.py +0 -0
  215. /cognee/{modules/data → infrastructure/llm/structured_output_framework/litellm_instructor}/extraction/knowledge_graph/__init__.py +0 -0
  216. /cognee/{modules/data → infrastructure/llm/structured_output_framework/litellm_instructor}/extraction/texts.json +0 -0
  217. /cognee/infrastructure/llm/{openai → structured_output_framework/litellm_instructor/llm}/__init__.py +0 -0
  218. {distributed → cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/anthropic}/__init__.py +0 -0
  219. {distributed/tasks → cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/gemini}/__init__.py +0 -0
  220. /cognee/modules/data/{extraction/knowledge_graph → methods}/add_model_class_to_graph.py +0 -0
  221. {cognee-0.2.1.dev7.dist-info → cognee-0.2.2.dev1.dist-info}/WHEEL +0 -0
  222. {cognee-0.2.1.dev7.dist-info → cognee-0.2.2.dev1.dist-info}/licenses/LICENSE +0 -0
  223. {cognee-0.2.1.dev7.dist-info → cognee-0.2.2.dev1.dist-info}/licenses/NOTICE.md +0 -0
@@ -0,0 +1,533 @@
1
+ # ----------------------------------------------------------------------------
2
+ #
3
+ # Welcome to Baml! To use this generated code, please run the following:
4
+ #
5
+ # $ pip install baml
6
+ #
7
+ # ----------------------------------------------------------------------------
8
+
9
+ # This file was generated by BAML: please do not edit it. Instead, edit the
10
+ # BAML files and re-generate this code using: baml-cli generate
11
+ # baml-cli is available with the baml package.
12
+
13
+ import typing
14
+ import typing_extensions
15
+ import baml_py
16
+
17
+ from . import stream_types, types, type_builder
18
+ from .parser import LlmResponseParser, LlmStreamParser
19
+ from .runtime import DoNotUseDirectlyCallManager, BamlCallOptions
20
+ from .globals import DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME as __runtime__
21
+
22
+
23
+ class BamlAsyncClient:
24
+ __options: DoNotUseDirectlyCallManager
25
+ __stream_client: "BamlStreamClient"
26
+ __http_request: "BamlHttpRequestClient"
27
+ __http_stream_request: "BamlHttpStreamRequestClient"
28
+ __llm_response_parser: LlmResponseParser
29
+ __llm_stream_parser: LlmStreamParser
30
+
31
+ def __init__(self, options: DoNotUseDirectlyCallManager):
32
+ self.__options = options
33
+ self.__stream_client = BamlStreamClient(options)
34
+ self.__http_request = BamlHttpRequestClient(options)
35
+ self.__http_stream_request = BamlHttpStreamRequestClient(options)
36
+ self.__llm_response_parser = LlmResponseParser(options)
37
+ self.__llm_stream_parser = LlmStreamParser(options)
38
+
39
+ def with_options(
40
+ self,
41
+ tb: typing.Optional[type_builder.TypeBuilder] = None,
42
+ client_registry: typing.Optional[baml_py.baml_py.ClientRegistry] = None,
43
+ collector: typing.Optional[
44
+ typing.Union[baml_py.baml_py.Collector, typing.List[baml_py.baml_py.Collector]]
45
+ ] = None,
46
+ env: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
47
+ ) -> "BamlAsyncClient":
48
+ options: BamlCallOptions = {}
49
+ if tb is not None:
50
+ options["tb"] = tb
51
+ if client_registry is not None:
52
+ options["client_registry"] = client_registry
53
+ if collector is not None:
54
+ options["collector"] = collector
55
+ if env is not None:
56
+ options["env"] = env
57
+ return BamlAsyncClient(self.__options.merge_options(options))
58
+
59
+ @property
60
+ def stream(self):
61
+ return self.__stream_client
62
+
63
+ @property
64
+ def request(self):
65
+ return self.__http_request
66
+
67
+ @property
68
+ def stream_request(self):
69
+ return self.__http_stream_request
70
+
71
+ @property
72
+ def parse(self):
73
+ return self.__llm_response_parser
74
+
75
+ @property
76
+ def parse_stream(self):
77
+ return self.__llm_stream_parser
78
+
79
+ async def ExtractCategories(
80
+ self,
81
+ content: str,
82
+ baml_options: BamlCallOptions = {},
83
+ ) -> types.DefaultContentPrediction:
84
+ result = await self.__options.merge_options(baml_options).call_function_async(
85
+ function_name="ExtractCategories",
86
+ args={
87
+ "content": content,
88
+ },
89
+ )
90
+ return typing.cast(
91
+ types.DefaultContentPrediction,
92
+ result.cast_to(types, types, stream_types, False, __runtime__),
93
+ )
94
+
95
+ async def ExtractContentGraphGeneric(
96
+ self,
97
+ content: str,
98
+ mode: typing.Optional[
99
+ typing.Union[
100
+ typing_extensions.Literal["simple"],
101
+ typing_extensions.Literal["base"],
102
+ typing_extensions.Literal["guided"],
103
+ typing_extensions.Literal["strict"],
104
+ typing_extensions.Literal["custom"],
105
+ ]
106
+ ] = None,
107
+ custom_prompt_content: typing.Optional[str] = None,
108
+ baml_options: BamlCallOptions = {},
109
+ ) -> types.KnowledgeGraph:
110
+ result = await self.__options.merge_options(baml_options).call_function_async(
111
+ function_name="ExtractContentGraphGeneric",
112
+ args={
113
+ "content": content,
114
+ "mode": mode,
115
+ "custom_prompt_content": custom_prompt_content,
116
+ },
117
+ )
118
+ return typing.cast(
119
+ types.KnowledgeGraph, result.cast_to(types, types, stream_types, False, __runtime__)
120
+ )
121
+
122
+ async def ExtractDynamicContentGraph(
123
+ self,
124
+ content: str,
125
+ mode: typing.Optional[
126
+ typing.Union[
127
+ typing_extensions.Literal["simple"],
128
+ typing_extensions.Literal["base"],
129
+ typing_extensions.Literal["guided"],
130
+ typing_extensions.Literal["strict"],
131
+ typing_extensions.Literal["custom"],
132
+ ]
133
+ ] = None,
134
+ custom_prompt_content: typing.Optional[str] = None,
135
+ baml_options: BamlCallOptions = {},
136
+ ) -> types.DynamicKnowledgeGraph:
137
+ result = await self.__options.merge_options(baml_options).call_function_async(
138
+ function_name="ExtractDynamicContentGraph",
139
+ args={
140
+ "content": content,
141
+ "mode": mode,
142
+ "custom_prompt_content": custom_prompt_content,
143
+ },
144
+ )
145
+ return typing.cast(
146
+ types.DynamicKnowledgeGraph,
147
+ result.cast_to(types, types, stream_types, False, __runtime__),
148
+ )
149
+
150
+ async def SummarizeCode(
151
+ self,
152
+ content: str,
153
+ baml_options: BamlCallOptions = {},
154
+ ) -> types.SummarizedCode:
155
+ result = await self.__options.merge_options(baml_options).call_function_async(
156
+ function_name="SummarizeCode",
157
+ args={
158
+ "content": content,
159
+ },
160
+ )
161
+ return typing.cast(
162
+ types.SummarizedCode, result.cast_to(types, types, stream_types, False, __runtime__)
163
+ )
164
+
165
+ async def SummarizeContent(
166
+ self,
167
+ content: str,
168
+ baml_options: BamlCallOptions = {},
169
+ ) -> types.SummarizedContent:
170
+ result = await self.__options.merge_options(baml_options).call_function_async(
171
+ function_name="SummarizeContent",
172
+ args={
173
+ "content": content,
174
+ },
175
+ )
176
+ return typing.cast(
177
+ types.SummarizedContent, result.cast_to(types, types, stream_types, False, __runtime__)
178
+ )
179
+
180
+
181
+ class BamlStreamClient:
182
+ __options: DoNotUseDirectlyCallManager
183
+
184
+ def __init__(self, options: DoNotUseDirectlyCallManager):
185
+ self.__options = options
186
+
187
+ def ExtractCategories(
188
+ self,
189
+ content: str,
190
+ baml_options: BamlCallOptions = {},
191
+ ) -> baml_py.BamlStream[stream_types.DefaultContentPrediction, types.DefaultContentPrediction]:
192
+ ctx, result = self.__options.merge_options(baml_options).create_async_stream(
193
+ function_name="ExtractCategories",
194
+ args={
195
+ "content": content,
196
+ },
197
+ )
198
+ return baml_py.BamlStream[
199
+ stream_types.DefaultContentPrediction, types.DefaultContentPrediction
200
+ ](
201
+ result,
202
+ lambda x: typing.cast(
203
+ stream_types.DefaultContentPrediction,
204
+ x.cast_to(types, types, stream_types, True, __runtime__),
205
+ ),
206
+ lambda x: typing.cast(
207
+ types.DefaultContentPrediction,
208
+ x.cast_to(types, types, stream_types, False, __runtime__),
209
+ ),
210
+ ctx,
211
+ )
212
+
213
+ def ExtractContentGraphGeneric(
214
+ self,
215
+ content: str,
216
+ mode: typing.Optional[
217
+ typing.Union[
218
+ typing_extensions.Literal["simple"],
219
+ typing_extensions.Literal["base"],
220
+ typing_extensions.Literal["guided"],
221
+ typing_extensions.Literal["strict"],
222
+ typing_extensions.Literal["custom"],
223
+ ]
224
+ ] = None,
225
+ custom_prompt_content: typing.Optional[str] = None,
226
+ baml_options: BamlCallOptions = {},
227
+ ) -> baml_py.BamlStream[stream_types.KnowledgeGraph, types.KnowledgeGraph]:
228
+ ctx, result = self.__options.merge_options(baml_options).create_async_stream(
229
+ function_name="ExtractContentGraphGeneric",
230
+ args={
231
+ "content": content,
232
+ "mode": mode,
233
+ "custom_prompt_content": custom_prompt_content,
234
+ },
235
+ )
236
+ return baml_py.BamlStream[stream_types.KnowledgeGraph, types.KnowledgeGraph](
237
+ result,
238
+ lambda x: typing.cast(
239
+ stream_types.KnowledgeGraph,
240
+ x.cast_to(types, types, stream_types, True, __runtime__),
241
+ ),
242
+ lambda x: typing.cast(
243
+ types.KnowledgeGraph, x.cast_to(types, types, stream_types, False, __runtime__)
244
+ ),
245
+ ctx,
246
+ )
247
+
248
+ def ExtractDynamicContentGraph(
249
+ self,
250
+ content: str,
251
+ mode: typing.Optional[
252
+ typing.Union[
253
+ typing_extensions.Literal["simple"],
254
+ typing_extensions.Literal["base"],
255
+ typing_extensions.Literal["guided"],
256
+ typing_extensions.Literal["strict"],
257
+ typing_extensions.Literal["custom"],
258
+ ]
259
+ ] = None,
260
+ custom_prompt_content: typing.Optional[str] = None,
261
+ baml_options: BamlCallOptions = {},
262
+ ) -> baml_py.BamlStream[stream_types.DynamicKnowledgeGraph, types.DynamicKnowledgeGraph]:
263
+ ctx, result = self.__options.merge_options(baml_options).create_async_stream(
264
+ function_name="ExtractDynamicContentGraph",
265
+ args={
266
+ "content": content,
267
+ "mode": mode,
268
+ "custom_prompt_content": custom_prompt_content,
269
+ },
270
+ )
271
+ return baml_py.BamlStream[stream_types.DynamicKnowledgeGraph, types.DynamicKnowledgeGraph](
272
+ result,
273
+ lambda x: typing.cast(
274
+ stream_types.DynamicKnowledgeGraph,
275
+ x.cast_to(types, types, stream_types, True, __runtime__),
276
+ ),
277
+ lambda x: typing.cast(
278
+ types.DynamicKnowledgeGraph,
279
+ x.cast_to(types, types, stream_types, False, __runtime__),
280
+ ),
281
+ ctx,
282
+ )
283
+
284
+ def SummarizeCode(
285
+ self,
286
+ content: str,
287
+ baml_options: BamlCallOptions = {},
288
+ ) -> baml_py.BamlStream[stream_types.SummarizedCode, types.SummarizedCode]:
289
+ ctx, result = self.__options.merge_options(baml_options).create_async_stream(
290
+ function_name="SummarizeCode",
291
+ args={
292
+ "content": content,
293
+ },
294
+ )
295
+ return baml_py.BamlStream[stream_types.SummarizedCode, types.SummarizedCode](
296
+ result,
297
+ lambda x: typing.cast(
298
+ stream_types.SummarizedCode,
299
+ x.cast_to(types, types, stream_types, True, __runtime__),
300
+ ),
301
+ lambda x: typing.cast(
302
+ types.SummarizedCode, x.cast_to(types, types, stream_types, False, __runtime__)
303
+ ),
304
+ ctx,
305
+ )
306
+
307
+ def SummarizeContent(
308
+ self,
309
+ content: str,
310
+ baml_options: BamlCallOptions = {},
311
+ ) -> baml_py.BamlStream[stream_types.SummarizedContent, types.SummarizedContent]:
312
+ ctx, result = self.__options.merge_options(baml_options).create_async_stream(
313
+ function_name="SummarizeContent",
314
+ args={
315
+ "content": content,
316
+ },
317
+ )
318
+ return baml_py.BamlStream[stream_types.SummarizedContent, types.SummarizedContent](
319
+ result,
320
+ lambda x: typing.cast(
321
+ stream_types.SummarizedContent,
322
+ x.cast_to(types, types, stream_types, True, __runtime__),
323
+ ),
324
+ lambda x: typing.cast(
325
+ types.SummarizedContent, x.cast_to(types, types, stream_types, False, __runtime__)
326
+ ),
327
+ ctx,
328
+ )
329
+
330
+
331
+ class BamlHttpRequestClient:
332
+ __options: DoNotUseDirectlyCallManager
333
+
334
+ def __init__(self, options: DoNotUseDirectlyCallManager):
335
+ self.__options = options
336
+
337
+ async def ExtractCategories(
338
+ self,
339
+ content: str,
340
+ baml_options: BamlCallOptions = {},
341
+ ) -> baml_py.baml_py.HTTPRequest:
342
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
343
+ function_name="ExtractCategories",
344
+ args={
345
+ "content": content,
346
+ },
347
+ mode="request",
348
+ )
349
+ return result
350
+
351
+ async def ExtractContentGraphGeneric(
352
+ self,
353
+ content: str,
354
+ mode: typing.Optional[
355
+ typing.Union[
356
+ typing_extensions.Literal["simple"],
357
+ typing_extensions.Literal["base"],
358
+ typing_extensions.Literal["guided"],
359
+ typing_extensions.Literal["strict"],
360
+ typing_extensions.Literal["custom"],
361
+ ]
362
+ ] = None,
363
+ custom_prompt_content: typing.Optional[str] = None,
364
+ baml_options: BamlCallOptions = {},
365
+ ) -> baml_py.baml_py.HTTPRequest:
366
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
367
+ function_name="ExtractContentGraphGeneric",
368
+ args={
369
+ "content": content,
370
+ "mode": mode,
371
+ "custom_prompt_content": custom_prompt_content,
372
+ },
373
+ mode="request",
374
+ )
375
+ return result
376
+
377
+ async def ExtractDynamicContentGraph(
378
+ self,
379
+ content: str,
380
+ mode: typing.Optional[
381
+ typing.Union[
382
+ typing_extensions.Literal["simple"],
383
+ typing_extensions.Literal["base"],
384
+ typing_extensions.Literal["guided"],
385
+ typing_extensions.Literal["strict"],
386
+ typing_extensions.Literal["custom"],
387
+ ]
388
+ ] = None,
389
+ custom_prompt_content: typing.Optional[str] = None,
390
+ baml_options: BamlCallOptions = {},
391
+ ) -> baml_py.baml_py.HTTPRequest:
392
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
393
+ function_name="ExtractDynamicContentGraph",
394
+ args={
395
+ "content": content,
396
+ "mode": mode,
397
+ "custom_prompt_content": custom_prompt_content,
398
+ },
399
+ mode="request",
400
+ )
401
+ return result
402
+
403
+ async def SummarizeCode(
404
+ self,
405
+ content: str,
406
+ baml_options: BamlCallOptions = {},
407
+ ) -> baml_py.baml_py.HTTPRequest:
408
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
409
+ function_name="SummarizeCode",
410
+ args={
411
+ "content": content,
412
+ },
413
+ mode="request",
414
+ )
415
+ return result
416
+
417
+ async def SummarizeContent(
418
+ self,
419
+ content: str,
420
+ baml_options: BamlCallOptions = {},
421
+ ) -> baml_py.baml_py.HTTPRequest:
422
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
423
+ function_name="SummarizeContent",
424
+ args={
425
+ "content": content,
426
+ },
427
+ mode="request",
428
+ )
429
+ return result
430
+
431
+
432
+ class BamlHttpStreamRequestClient:
433
+ __options: DoNotUseDirectlyCallManager
434
+
435
+ def __init__(self, options: DoNotUseDirectlyCallManager):
436
+ self.__options = options
437
+
438
+ async def ExtractCategories(
439
+ self,
440
+ content: str,
441
+ baml_options: BamlCallOptions = {},
442
+ ) -> baml_py.baml_py.HTTPRequest:
443
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
444
+ function_name="ExtractCategories",
445
+ args={
446
+ "content": content,
447
+ },
448
+ mode="stream",
449
+ )
450
+ return result
451
+
452
+ async def ExtractContentGraphGeneric(
453
+ self,
454
+ content: str,
455
+ mode: typing.Optional[
456
+ typing.Union[
457
+ typing_extensions.Literal["simple"],
458
+ typing_extensions.Literal["base"],
459
+ typing_extensions.Literal["guided"],
460
+ typing_extensions.Literal["strict"],
461
+ typing_extensions.Literal["custom"],
462
+ ]
463
+ ] = None,
464
+ custom_prompt_content: typing.Optional[str] = None,
465
+ baml_options: BamlCallOptions = {},
466
+ ) -> baml_py.baml_py.HTTPRequest:
467
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
468
+ function_name="ExtractContentGraphGeneric",
469
+ args={
470
+ "content": content,
471
+ "mode": mode,
472
+ "custom_prompt_content": custom_prompt_content,
473
+ },
474
+ mode="stream",
475
+ )
476
+ return result
477
+
478
+ async def ExtractDynamicContentGraph(
479
+ self,
480
+ content: str,
481
+ mode: typing.Optional[
482
+ typing.Union[
483
+ typing_extensions.Literal["simple"],
484
+ typing_extensions.Literal["base"],
485
+ typing_extensions.Literal["guided"],
486
+ typing_extensions.Literal["strict"],
487
+ typing_extensions.Literal["custom"],
488
+ ]
489
+ ] = None,
490
+ custom_prompt_content: typing.Optional[str] = None,
491
+ baml_options: BamlCallOptions = {},
492
+ ) -> baml_py.baml_py.HTTPRequest:
493
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
494
+ function_name="ExtractDynamicContentGraph",
495
+ args={
496
+ "content": content,
497
+ "mode": mode,
498
+ "custom_prompt_content": custom_prompt_content,
499
+ },
500
+ mode="stream",
501
+ )
502
+ return result
503
+
504
+ async def SummarizeCode(
505
+ self,
506
+ content: str,
507
+ baml_options: BamlCallOptions = {},
508
+ ) -> baml_py.baml_py.HTTPRequest:
509
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
510
+ function_name="SummarizeCode",
511
+ args={
512
+ "content": content,
513
+ },
514
+ mode="stream",
515
+ )
516
+ return result
517
+
518
+ async def SummarizeContent(
519
+ self,
520
+ content: str,
521
+ baml_options: BamlCallOptions = {},
522
+ ) -> baml_py.baml_py.HTTPRequest:
523
+ result = await self.__options.merge_options(baml_options).create_http_request_async(
524
+ function_name="SummarizeContent",
525
+ args={
526
+ "content": content,
527
+ },
528
+ mode="stream",
529
+ )
530
+ return result
531
+
532
+
533
+ b = BamlAsyncClient(DoNotUseDirectlyCallManager({}))
@@ -0,0 +1,94 @@
1
+ # ----------------------------------------------------------------------------
2
+ #
3
+ # Welcome to Baml! To use this generated code, please run the following:
4
+ #
5
+ # $ pip install baml
6
+ #
7
+ # ----------------------------------------------------------------------------
8
+
9
+ # This file was generated by BAML: please do not edit it. Instead, edit the
10
+ # BAML files and re-generate this code using: baml-cli generate
11
+ # baml-cli is available with the baml package.
12
+
13
+ from __future__ import annotations
14
+
15
+ import os
16
+ import warnings
17
+ import typing_extensions
18
+ import typing
19
+ import functools
20
+
21
+ from baml_py.logging import (
22
+ get_log_level as baml_get_log_level,
23
+ set_log_level as baml_set_log_level,
24
+ )
25
+ from .globals import reset_baml_env_vars
26
+
27
+ rT = typing_extensions.TypeVar("rT") # return type
28
+ pT = typing_extensions.ParamSpec("pT") # parameters type
29
+
30
+
31
+ def _deprecated(message: str):
32
+ def decorator(func: typing.Callable[pT, rT]) -> typing.Callable[pT, rT]:
33
+ """Use this decorator to mark functions as deprecated.
34
+ Every time the decorated function runs, it will emit
35
+ a "deprecation" warning."""
36
+
37
+ @functools.wraps(func)
38
+ def new_func(*args: pT.args, **kwargs: pT.kwargs):
39
+ warnings.simplefilter("always", DeprecationWarning) # turn off filter
40
+ warnings.warn(
41
+ "Call to a deprecated function {}.".format(func.__name__) + message,
42
+ category=DeprecationWarning,
43
+ stacklevel=2,
44
+ )
45
+ warnings.simplefilter("default", DeprecationWarning) # reset filter
46
+ return func(*args, **kwargs)
47
+
48
+ return new_func
49
+
50
+ return decorator
51
+
52
+
53
+ @_deprecated("Use os.environ['BAML_LOG'] instead")
54
+ def get_log_level():
55
+ """
56
+ Get the log level for the BAML Python client.
57
+ """
58
+ return baml_get_log_level()
59
+
60
+
61
+ @_deprecated("Use os.environ['BAML_LOG'] instead")
62
+ def set_log_level(
63
+ level: typing_extensions.Literal["DEBUG", "INFO", "WARN", "ERROR", "OFF"] | str,
64
+ ):
65
+ """
66
+ Set the log level for the BAML Python client
67
+ """
68
+ baml_set_log_level(level)
69
+ os.environ["BAML_LOG"] = level
70
+
71
+
72
+ @_deprecated("Use os.environ['BAML_LOG_JSON_MODE'] instead")
73
+ def set_log_json_mode():
74
+ """
75
+ Set the log JSON mode for the BAML Python client.
76
+ """
77
+ os.environ["BAML_LOG_JSON_MODE"] = "true"
78
+
79
+
80
+ @_deprecated("Use os.environ['BAML_LOG_MAX_CHUNK_LENGTH'] instead")
81
+ def set_log_max_chunk_length():
82
+ """
83
+ Set the maximum log chunk length for the BAML Python client.
84
+ """
85
+ os.environ["BAML_LOG_MAX_CHUNK_LENGTH"] = "1000"
86
+
87
+
88
+ __all__ = [
89
+ "set_log_level",
90
+ "get_log_level",
91
+ "set_log_json_mode",
92
+ "reset_baml_env_vars",
93
+ "set_log_max_chunk_length",
94
+ ]
@@ -0,0 +1,37 @@
1
+ # ----------------------------------------------------------------------------
2
+ #
3
+ # Welcome to Baml! To use this generated code, please run the following:
4
+ #
5
+ # $ pip install baml
6
+ #
7
+ # ----------------------------------------------------------------------------
8
+
9
+ # This file was generated by BAML: please do not edit it. Instead, edit the
10
+ # BAML files and re-generate this code using: baml-cli generate
11
+ # baml-cli is available with the baml package.
12
+
13
+ from __future__ import annotations
14
+ import os
15
+ import warnings
16
+
17
+ from baml_py import BamlCtxManager, BamlRuntime
18
+ from .inlinedbaml import get_baml_files
19
+ from typing import Dict
20
+
21
+ DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME = BamlRuntime.from_files(
22
+ "baml_src", get_baml_files(), os.environ.copy()
23
+ )
24
+ DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX = BamlCtxManager(
25
+ DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME
26
+ )
27
+
28
+
29
+ def reset_baml_env_vars(env_vars: Dict[str, str]):
30
+ warnings.warn(
31
+ "reset_baml_env_vars is deprecated and should be removed. Environment variables are now lazily loaded on each function call",
32
+ DeprecationWarning,
33
+ stacklevel=2,
34
+ )
35
+
36
+
37
+ __all__ = []