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,550 @@
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 BamlSyncClient:
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 __getstate__(self):
40
+ # Return state needed for pickling
41
+ return {"options": self.__options}
42
+
43
+ def __setstate__(self, state):
44
+ # Restore state from pickling
45
+ self.__options = state["options"]
46
+ self.__stream_client = BamlStreamClient(self.__options)
47
+ self.__http_request = BamlHttpRequestClient(self.__options)
48
+ self.__http_stream_request = BamlHttpStreamRequestClient(self.__options)
49
+ self.__llm_response_parser = LlmResponseParser(self.__options)
50
+ self.__llm_stream_parser = LlmStreamParser(self.__options)
51
+
52
+ def with_options(
53
+ self,
54
+ tb: typing.Optional[type_builder.TypeBuilder] = None,
55
+ client_registry: typing.Optional[baml_py.baml_py.ClientRegistry] = None,
56
+ collector: typing.Optional[
57
+ typing.Union[baml_py.baml_py.Collector, typing.List[baml_py.baml_py.Collector]]
58
+ ] = None,
59
+ env: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
60
+ ) -> "BamlSyncClient":
61
+ options: BamlCallOptions = {}
62
+ if tb is not None:
63
+ options["tb"] = tb
64
+ if client_registry is not None:
65
+ options["client_registry"] = client_registry
66
+ if collector is not None:
67
+ options["collector"] = collector
68
+ if env is not None:
69
+ options["env"] = env
70
+ return BamlSyncClient(self.__options.merge_options(options))
71
+
72
+ @property
73
+ def stream(self):
74
+ return self.__stream_client
75
+
76
+ @property
77
+ def request(self):
78
+ return self.__http_request
79
+
80
+ @property
81
+ def stream_request(self):
82
+ return self.__http_stream_request
83
+
84
+ @property
85
+ def parse(self):
86
+ return self.__llm_response_parser
87
+
88
+ @property
89
+ def parse_stream(self):
90
+ return self.__llm_stream_parser
91
+
92
+ def ExtractCategories(
93
+ self,
94
+ content: str,
95
+ baml_options: BamlCallOptions = {},
96
+ ) -> types.DefaultContentPrediction:
97
+ result = self.__options.merge_options(baml_options).call_function_sync(
98
+ function_name="ExtractCategories",
99
+ args={
100
+ "content": content,
101
+ },
102
+ )
103
+ return typing.cast(
104
+ types.DefaultContentPrediction,
105
+ result.cast_to(types, types, stream_types, False, __runtime__),
106
+ )
107
+
108
+ def ExtractContentGraphGeneric(
109
+ self,
110
+ content: str,
111
+ mode: typing.Optional[
112
+ typing.Union[
113
+ typing_extensions.Literal["simple"],
114
+ typing_extensions.Literal["base"],
115
+ typing_extensions.Literal["guided"],
116
+ typing_extensions.Literal["strict"],
117
+ typing_extensions.Literal["custom"],
118
+ ]
119
+ ] = None,
120
+ custom_prompt_content: typing.Optional[str] = None,
121
+ baml_options: BamlCallOptions = {},
122
+ ) -> types.KnowledgeGraph:
123
+ result = self.__options.merge_options(baml_options).call_function_sync(
124
+ function_name="ExtractContentGraphGeneric",
125
+ args={
126
+ "content": content,
127
+ "mode": mode,
128
+ "custom_prompt_content": custom_prompt_content,
129
+ },
130
+ )
131
+ return typing.cast(
132
+ types.KnowledgeGraph, result.cast_to(types, types, stream_types, False, __runtime__)
133
+ )
134
+
135
+ def ExtractDynamicContentGraph(
136
+ self,
137
+ content: str,
138
+ mode: typing.Optional[
139
+ typing.Union[
140
+ typing_extensions.Literal["simple"],
141
+ typing_extensions.Literal["base"],
142
+ typing_extensions.Literal["guided"],
143
+ typing_extensions.Literal["strict"],
144
+ typing_extensions.Literal["custom"],
145
+ ]
146
+ ] = None,
147
+ custom_prompt_content: typing.Optional[str] = None,
148
+ baml_options: BamlCallOptions = {},
149
+ ) -> types.DynamicKnowledgeGraph:
150
+ result = self.__options.merge_options(baml_options).call_function_sync(
151
+ function_name="ExtractDynamicContentGraph",
152
+ args={
153
+ "content": content,
154
+ "mode": mode,
155
+ "custom_prompt_content": custom_prompt_content,
156
+ },
157
+ )
158
+ return typing.cast(
159
+ types.DynamicKnowledgeGraph,
160
+ result.cast_to(types, types, stream_types, False, __runtime__),
161
+ )
162
+
163
+ def SummarizeCode(
164
+ self,
165
+ content: str,
166
+ baml_options: BamlCallOptions = {},
167
+ ) -> types.SummarizedCode:
168
+ result = self.__options.merge_options(baml_options).call_function_sync(
169
+ function_name="SummarizeCode",
170
+ args={
171
+ "content": content,
172
+ },
173
+ )
174
+ return typing.cast(
175
+ types.SummarizedCode, result.cast_to(types, types, stream_types, False, __runtime__)
176
+ )
177
+
178
+ def SummarizeContent(
179
+ self,
180
+ content: str,
181
+ baml_options: BamlCallOptions = {},
182
+ ) -> types.SummarizedContent:
183
+ result = self.__options.merge_options(baml_options).call_function_sync(
184
+ function_name="SummarizeContent",
185
+ args={
186
+ "content": content,
187
+ },
188
+ )
189
+ return typing.cast(
190
+ types.SummarizedContent, result.cast_to(types, types, stream_types, False, __runtime__)
191
+ )
192
+
193
+
194
+ class BamlStreamClient:
195
+ __options: DoNotUseDirectlyCallManager
196
+
197
+ def __init__(self, options: DoNotUseDirectlyCallManager):
198
+ self.__options = options
199
+
200
+ def ExtractCategories(
201
+ self,
202
+ content: str,
203
+ baml_options: BamlCallOptions = {},
204
+ ) -> baml_py.BamlSyncStream[
205
+ stream_types.DefaultContentPrediction, types.DefaultContentPrediction
206
+ ]:
207
+ ctx, result = self.__options.merge_options(baml_options).create_sync_stream(
208
+ function_name="ExtractCategories",
209
+ args={
210
+ "content": content,
211
+ },
212
+ )
213
+ return baml_py.BamlSyncStream[
214
+ stream_types.DefaultContentPrediction, types.DefaultContentPrediction
215
+ ](
216
+ result,
217
+ lambda x: typing.cast(
218
+ stream_types.DefaultContentPrediction,
219
+ x.cast_to(types, types, stream_types, True, __runtime__),
220
+ ),
221
+ lambda x: typing.cast(
222
+ types.DefaultContentPrediction,
223
+ x.cast_to(types, types, stream_types, False, __runtime__),
224
+ ),
225
+ ctx,
226
+ )
227
+
228
+ def ExtractContentGraphGeneric(
229
+ self,
230
+ content: str,
231
+ mode: typing.Optional[
232
+ typing.Union[
233
+ typing_extensions.Literal["simple"],
234
+ typing_extensions.Literal["base"],
235
+ typing_extensions.Literal["guided"],
236
+ typing_extensions.Literal["strict"],
237
+ typing_extensions.Literal["custom"],
238
+ ]
239
+ ] = None,
240
+ custom_prompt_content: typing.Optional[str] = None,
241
+ baml_options: BamlCallOptions = {},
242
+ ) -> baml_py.BamlSyncStream[stream_types.KnowledgeGraph, types.KnowledgeGraph]:
243
+ ctx, result = self.__options.merge_options(baml_options).create_sync_stream(
244
+ function_name="ExtractContentGraphGeneric",
245
+ args={
246
+ "content": content,
247
+ "mode": mode,
248
+ "custom_prompt_content": custom_prompt_content,
249
+ },
250
+ )
251
+ return baml_py.BamlSyncStream[stream_types.KnowledgeGraph, types.KnowledgeGraph](
252
+ result,
253
+ lambda x: typing.cast(
254
+ stream_types.KnowledgeGraph,
255
+ x.cast_to(types, types, stream_types, True, __runtime__),
256
+ ),
257
+ lambda x: typing.cast(
258
+ types.KnowledgeGraph, x.cast_to(types, types, stream_types, False, __runtime__)
259
+ ),
260
+ ctx,
261
+ )
262
+
263
+ def ExtractDynamicContentGraph(
264
+ self,
265
+ content: str,
266
+ mode: typing.Optional[
267
+ typing.Union[
268
+ typing_extensions.Literal["simple"],
269
+ typing_extensions.Literal["base"],
270
+ typing_extensions.Literal["guided"],
271
+ typing_extensions.Literal["strict"],
272
+ typing_extensions.Literal["custom"],
273
+ ]
274
+ ] = None,
275
+ custom_prompt_content: typing.Optional[str] = None,
276
+ baml_options: BamlCallOptions = {},
277
+ ) -> baml_py.BamlSyncStream[stream_types.DynamicKnowledgeGraph, types.DynamicKnowledgeGraph]:
278
+ ctx, result = self.__options.merge_options(baml_options).create_sync_stream(
279
+ function_name="ExtractDynamicContentGraph",
280
+ args={
281
+ "content": content,
282
+ "mode": mode,
283
+ "custom_prompt_content": custom_prompt_content,
284
+ },
285
+ )
286
+ return baml_py.BamlSyncStream[
287
+ stream_types.DynamicKnowledgeGraph, types.DynamicKnowledgeGraph
288
+ ](
289
+ result,
290
+ lambda x: typing.cast(
291
+ stream_types.DynamicKnowledgeGraph,
292
+ x.cast_to(types, types, stream_types, True, __runtime__),
293
+ ),
294
+ lambda x: typing.cast(
295
+ types.DynamicKnowledgeGraph,
296
+ x.cast_to(types, types, stream_types, False, __runtime__),
297
+ ),
298
+ ctx,
299
+ )
300
+
301
+ def SummarizeCode(
302
+ self,
303
+ content: str,
304
+ baml_options: BamlCallOptions = {},
305
+ ) -> baml_py.BamlSyncStream[stream_types.SummarizedCode, types.SummarizedCode]:
306
+ ctx, result = self.__options.merge_options(baml_options).create_sync_stream(
307
+ function_name="SummarizeCode",
308
+ args={
309
+ "content": content,
310
+ },
311
+ )
312
+ return baml_py.BamlSyncStream[stream_types.SummarizedCode, types.SummarizedCode](
313
+ result,
314
+ lambda x: typing.cast(
315
+ stream_types.SummarizedCode,
316
+ x.cast_to(types, types, stream_types, True, __runtime__),
317
+ ),
318
+ lambda x: typing.cast(
319
+ types.SummarizedCode, x.cast_to(types, types, stream_types, False, __runtime__)
320
+ ),
321
+ ctx,
322
+ )
323
+
324
+ def SummarizeContent(
325
+ self,
326
+ content: str,
327
+ baml_options: BamlCallOptions = {},
328
+ ) -> baml_py.BamlSyncStream[stream_types.SummarizedContent, types.SummarizedContent]:
329
+ ctx, result = self.__options.merge_options(baml_options).create_sync_stream(
330
+ function_name="SummarizeContent",
331
+ args={
332
+ "content": content,
333
+ },
334
+ )
335
+ return baml_py.BamlSyncStream[stream_types.SummarizedContent, types.SummarizedContent](
336
+ result,
337
+ lambda x: typing.cast(
338
+ stream_types.SummarizedContent,
339
+ x.cast_to(types, types, stream_types, True, __runtime__),
340
+ ),
341
+ lambda x: typing.cast(
342
+ types.SummarizedContent, x.cast_to(types, types, stream_types, False, __runtime__)
343
+ ),
344
+ ctx,
345
+ )
346
+
347
+
348
+ class BamlHttpRequestClient:
349
+ __options: DoNotUseDirectlyCallManager
350
+
351
+ def __init__(self, options: DoNotUseDirectlyCallManager):
352
+ self.__options = options
353
+
354
+ def ExtractCategories(
355
+ self,
356
+ content: str,
357
+ baml_options: BamlCallOptions = {},
358
+ ) -> baml_py.baml_py.HTTPRequest:
359
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
360
+ function_name="ExtractCategories",
361
+ args={
362
+ "content": content,
363
+ },
364
+ mode="request",
365
+ )
366
+ return result
367
+
368
+ def ExtractContentGraphGeneric(
369
+ self,
370
+ content: str,
371
+ mode: typing.Optional[
372
+ typing.Union[
373
+ typing_extensions.Literal["simple"],
374
+ typing_extensions.Literal["base"],
375
+ typing_extensions.Literal["guided"],
376
+ typing_extensions.Literal["strict"],
377
+ typing_extensions.Literal["custom"],
378
+ ]
379
+ ] = None,
380
+ custom_prompt_content: typing.Optional[str] = None,
381
+ baml_options: BamlCallOptions = {},
382
+ ) -> baml_py.baml_py.HTTPRequest:
383
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
384
+ function_name="ExtractContentGraphGeneric",
385
+ args={
386
+ "content": content,
387
+ "mode": mode,
388
+ "custom_prompt_content": custom_prompt_content,
389
+ },
390
+ mode="request",
391
+ )
392
+ return result
393
+
394
+ def ExtractDynamicContentGraph(
395
+ self,
396
+ content: str,
397
+ mode: typing.Optional[
398
+ typing.Union[
399
+ typing_extensions.Literal["simple"],
400
+ typing_extensions.Literal["base"],
401
+ typing_extensions.Literal["guided"],
402
+ typing_extensions.Literal["strict"],
403
+ typing_extensions.Literal["custom"],
404
+ ]
405
+ ] = None,
406
+ custom_prompt_content: typing.Optional[str] = None,
407
+ baml_options: BamlCallOptions = {},
408
+ ) -> baml_py.baml_py.HTTPRequest:
409
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
410
+ function_name="ExtractDynamicContentGraph",
411
+ args={
412
+ "content": content,
413
+ "mode": mode,
414
+ "custom_prompt_content": custom_prompt_content,
415
+ },
416
+ mode="request",
417
+ )
418
+ return result
419
+
420
+ def SummarizeCode(
421
+ self,
422
+ content: str,
423
+ baml_options: BamlCallOptions = {},
424
+ ) -> baml_py.baml_py.HTTPRequest:
425
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
426
+ function_name="SummarizeCode",
427
+ args={
428
+ "content": content,
429
+ },
430
+ mode="request",
431
+ )
432
+ return result
433
+
434
+ def SummarizeContent(
435
+ self,
436
+ content: str,
437
+ baml_options: BamlCallOptions = {},
438
+ ) -> baml_py.baml_py.HTTPRequest:
439
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
440
+ function_name="SummarizeContent",
441
+ args={
442
+ "content": content,
443
+ },
444
+ mode="request",
445
+ )
446
+ return result
447
+
448
+
449
+ class BamlHttpStreamRequestClient:
450
+ __options: DoNotUseDirectlyCallManager
451
+
452
+ def __init__(self, options: DoNotUseDirectlyCallManager):
453
+ self.__options = options
454
+
455
+ def ExtractCategories(
456
+ self,
457
+ content: str,
458
+ baml_options: BamlCallOptions = {},
459
+ ) -> baml_py.baml_py.HTTPRequest:
460
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
461
+ function_name="ExtractCategories",
462
+ args={
463
+ "content": content,
464
+ },
465
+ mode="stream",
466
+ )
467
+ return result
468
+
469
+ def ExtractContentGraphGeneric(
470
+ self,
471
+ content: str,
472
+ mode: typing.Optional[
473
+ typing.Union[
474
+ typing_extensions.Literal["simple"],
475
+ typing_extensions.Literal["base"],
476
+ typing_extensions.Literal["guided"],
477
+ typing_extensions.Literal["strict"],
478
+ typing_extensions.Literal["custom"],
479
+ ]
480
+ ] = None,
481
+ custom_prompt_content: typing.Optional[str] = None,
482
+ baml_options: BamlCallOptions = {},
483
+ ) -> baml_py.baml_py.HTTPRequest:
484
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
485
+ function_name="ExtractContentGraphGeneric",
486
+ args={
487
+ "content": content,
488
+ "mode": mode,
489
+ "custom_prompt_content": custom_prompt_content,
490
+ },
491
+ mode="stream",
492
+ )
493
+ return result
494
+
495
+ def ExtractDynamicContentGraph(
496
+ self,
497
+ content: str,
498
+ mode: typing.Optional[
499
+ typing.Union[
500
+ typing_extensions.Literal["simple"],
501
+ typing_extensions.Literal["base"],
502
+ typing_extensions.Literal["guided"],
503
+ typing_extensions.Literal["strict"],
504
+ typing_extensions.Literal["custom"],
505
+ ]
506
+ ] = None,
507
+ custom_prompt_content: typing.Optional[str] = None,
508
+ baml_options: BamlCallOptions = {},
509
+ ) -> baml_py.baml_py.HTTPRequest:
510
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
511
+ function_name="ExtractDynamicContentGraph",
512
+ args={
513
+ "content": content,
514
+ "mode": mode,
515
+ "custom_prompt_content": custom_prompt_content,
516
+ },
517
+ mode="stream",
518
+ )
519
+ return result
520
+
521
+ def SummarizeCode(
522
+ self,
523
+ content: str,
524
+ baml_options: BamlCallOptions = {},
525
+ ) -> baml_py.baml_py.HTTPRequest:
526
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
527
+ function_name="SummarizeCode",
528
+ args={
529
+ "content": content,
530
+ },
531
+ mode="stream",
532
+ )
533
+ return result
534
+
535
+ def SummarizeContent(
536
+ self,
537
+ content: str,
538
+ baml_options: BamlCallOptions = {},
539
+ ) -> baml_py.baml_py.HTTPRequest:
540
+ result = self.__options.merge_options(baml_options).create_http_request_sync(
541
+ function_name="SummarizeContent",
542
+ args={
543
+ "content": content,
544
+ },
545
+ mode="stream",
546
+ )
547
+ return result
548
+
549
+
550
+ b = BamlSyncClient(DoNotUseDirectlyCallManager({}))
@@ -0,0 +1,26 @@
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 .globals import DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX
14
+
15
+ trace = DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.trace_fn
16
+ set_tags = DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.upsert_tags
17
+
18
+
19
+ def flush():
20
+ DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.flush()
21
+
22
+
23
+ on_log_event = DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.on_log_event
24
+
25
+
26
+ __all__ = ["trace", "set_tags", "flush", "on_log_event"]