cognee 0.3.4.dev4__py3-none-any.whl → 0.3.6__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 (184) hide show
  1. cognee/api/client.py +16 -7
  2. cognee/api/health.py +5 -9
  3. cognee/api/v1/add/add.py +3 -1
  4. cognee/api/v1/cognify/cognify.py +44 -7
  5. cognee/api/v1/permissions/routers/get_permissions_router.py +8 -4
  6. cognee/api/v1/search/search.py +3 -0
  7. cognee/api/v1/ui/__init__.py +1 -1
  8. cognee/api/v1/ui/ui.py +215 -150
  9. cognee/api/v1/update/__init__.py +1 -0
  10. cognee/api/v1/update/routers/__init__.py +1 -0
  11. cognee/api/v1/update/routers/get_update_router.py +90 -0
  12. cognee/api/v1/update/update.py +100 -0
  13. cognee/base_config.py +5 -2
  14. cognee/cli/_cognee.py +28 -10
  15. cognee/cli/commands/delete_command.py +34 -2
  16. cognee/eval_framework/corpus_builder/task_getters/get_default_tasks_by_indices.py +2 -2
  17. cognee/eval_framework/evaluation/direct_llm_eval_adapter.py +3 -2
  18. cognee/eval_framework/modal_eval_dashboard.py +9 -1
  19. cognee/infrastructure/databases/graph/config.py +9 -9
  20. cognee/infrastructure/databases/graph/get_graph_engine.py +4 -21
  21. cognee/infrastructure/databases/graph/kuzu/adapter.py +60 -9
  22. cognee/infrastructure/databases/hybrid/neptune_analytics/NeptuneAnalyticsAdapter.py +3 -3
  23. cognee/infrastructure/databases/relational/config.py +4 -4
  24. cognee/infrastructure/databases/relational/create_relational_engine.py +11 -3
  25. cognee/infrastructure/databases/vector/chromadb/ChromaDBAdapter.py +7 -3
  26. cognee/infrastructure/databases/vector/config.py +7 -7
  27. cognee/infrastructure/databases/vector/create_vector_engine.py +7 -15
  28. cognee/infrastructure/databases/vector/embeddings/EmbeddingEngine.py +9 -0
  29. cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +11 -0
  30. cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +19 -2
  31. cognee/infrastructure/databases/vector/embeddings/OllamaEmbeddingEngine.py +11 -0
  32. cognee/infrastructure/databases/vector/embeddings/config.py +8 -0
  33. cognee/infrastructure/databases/vector/embeddings/get_embedding_engine.py +5 -0
  34. cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py +11 -10
  35. cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py +48 -38
  36. cognee/infrastructure/databases/vector/vector_db_interface.py +8 -4
  37. cognee/infrastructure/files/storage/S3FileStorage.py +15 -5
  38. cognee/infrastructure/files/storage/s3_config.py +1 -0
  39. cognee/infrastructure/files/utils/open_data_file.py +7 -14
  40. cognee/infrastructure/llm/LLMGateway.py +19 -117
  41. cognee/infrastructure/llm/config.py +28 -13
  42. cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_categories.py +2 -1
  43. cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_event_entities.py +3 -2
  44. cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_summary.py +3 -2
  45. cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/extract_content_graph.py +2 -1
  46. cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/extract_event_graph.py +3 -2
  47. cognee/infrastructure/llm/prompts/read_query_prompt.py +3 -2
  48. cognee/infrastructure/llm/prompts/show_prompt.py +35 -0
  49. cognee/infrastructure/llm/prompts/test.txt +1 -0
  50. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/__init__.py +2 -2
  51. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/async_client.py +50 -397
  52. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/inlinedbaml.py +2 -3
  53. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/parser.py +8 -88
  54. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/runtime.py +78 -0
  55. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/stream_types.py +2 -99
  56. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/sync_client.py +49 -401
  57. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_builder.py +19 -882
  58. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_map.py +2 -34
  59. cognee/infrastructure/llm/structured_output_framework/baml/baml_client/types.py +2 -107
  60. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/acreate_structured_output.baml +26 -0
  61. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/__init__.py +1 -2
  62. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/acreate_structured_output.py +76 -0
  63. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/create_dynamic_baml_type.py +122 -0
  64. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/generators.baml +3 -3
  65. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/anthropic/adapter.py +0 -32
  66. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/gemini/adapter.py +107 -98
  67. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/generic_llm_api/adapter.py +5 -6
  68. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/get_llm_client.py +5 -6
  69. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/llm_interface.py +0 -26
  70. cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/openai/adapter.py +17 -67
  71. cognee/infrastructure/llm/tokenizer/Gemini/adapter.py +8 -7
  72. cognee/infrastructure/llm/utils.py +4 -4
  73. cognee/infrastructure/loaders/LoaderEngine.py +5 -2
  74. cognee/infrastructure/loaders/external/__init__.py +7 -0
  75. cognee/infrastructure/loaders/external/advanced_pdf_loader.py +244 -0
  76. cognee/infrastructure/loaders/supported_loaders.py +7 -0
  77. cognee/modules/data/methods/create_authorized_dataset.py +9 -0
  78. cognee/modules/data/methods/get_authorized_dataset.py +1 -1
  79. cognee/modules/data/methods/get_authorized_dataset_by_name.py +11 -0
  80. cognee/modules/data/methods/get_deletion_counts.py +92 -0
  81. cognee/modules/graph/cognee_graph/CogneeGraph.py +1 -1
  82. cognee/modules/graph/utils/expand_with_nodes_and_edges.py +22 -8
  83. cognee/modules/graph/utils/retrieve_existing_edges.py +0 -2
  84. cognee/modules/ingestion/data_types/TextData.py +0 -1
  85. cognee/modules/observability/get_observe.py +14 -0
  86. cognee/modules/observability/observers.py +1 -0
  87. cognee/modules/ontology/base_ontology_resolver.py +42 -0
  88. cognee/modules/ontology/get_default_ontology_resolver.py +41 -0
  89. cognee/modules/ontology/matching_strategies.py +53 -0
  90. cognee/modules/ontology/models.py +20 -0
  91. cognee/modules/ontology/ontology_config.py +24 -0
  92. cognee/modules/ontology/ontology_env_config.py +45 -0
  93. cognee/modules/ontology/rdf_xml/{OntologyResolver.py → RDFLibOntologyResolver.py} +20 -28
  94. cognee/modules/pipelines/layers/resolve_authorized_user_dataset.py +21 -24
  95. cognee/modules/pipelines/layers/resolve_authorized_user_datasets.py +3 -3
  96. cognee/modules/retrieval/code_retriever.py +2 -1
  97. cognee/modules/retrieval/context_providers/TripletSearchContextProvider.py +1 -4
  98. cognee/modules/retrieval/graph_completion_cot_retriever.py +6 -5
  99. cognee/modules/retrieval/graph_completion_retriever.py +0 -3
  100. cognee/modules/retrieval/insights_retriever.py +1 -1
  101. cognee/modules/retrieval/jaccard_retrival.py +60 -0
  102. cognee/modules/retrieval/lexical_retriever.py +123 -0
  103. cognee/modules/retrieval/natural_language_retriever.py +2 -1
  104. cognee/modules/retrieval/temporal_retriever.py +3 -2
  105. cognee/modules/retrieval/utils/brute_force_triplet_search.py +2 -12
  106. cognee/modules/retrieval/utils/completion.py +4 -7
  107. cognee/modules/search/methods/get_search_type_tools.py +7 -0
  108. cognee/modules/search/methods/no_access_control_search.py +1 -1
  109. cognee/modules/search/methods/search.py +32 -13
  110. cognee/modules/search/types/SearchType.py +1 -0
  111. cognee/modules/users/permissions/methods/authorized_give_permission_on_datasets.py +12 -0
  112. cognee/modules/users/permissions/methods/check_permission_on_dataset.py +11 -0
  113. cognee/modules/users/permissions/methods/get_all_user_permission_datasets.py +10 -0
  114. cognee/modules/users/permissions/methods/get_document_ids_for_user.py +10 -0
  115. cognee/modules/users/permissions/methods/get_principal.py +9 -0
  116. cognee/modules/users/permissions/methods/get_principal_datasets.py +11 -0
  117. cognee/modules/users/permissions/methods/get_role.py +10 -0
  118. cognee/modules/users/permissions/methods/get_specific_user_permission_datasets.py +3 -3
  119. cognee/modules/users/permissions/methods/get_tenant.py +9 -0
  120. cognee/modules/users/permissions/methods/give_default_permission_to_role.py +9 -0
  121. cognee/modules/users/permissions/methods/give_default_permission_to_tenant.py +9 -0
  122. cognee/modules/users/permissions/methods/give_default_permission_to_user.py +9 -0
  123. cognee/modules/users/permissions/methods/give_permission_on_dataset.py +10 -0
  124. cognee/modules/users/roles/methods/add_user_to_role.py +11 -0
  125. cognee/modules/users/roles/methods/create_role.py +12 -1
  126. cognee/modules/users/tenants/methods/add_user_to_tenant.py +12 -0
  127. cognee/modules/users/tenants/methods/create_tenant.py +12 -1
  128. cognee/modules/visualization/cognee_network_visualization.py +13 -9
  129. cognee/shared/data_models.py +0 -1
  130. cognee/shared/utils.py +0 -32
  131. cognee/tasks/chunk_naive_llm_classifier/chunk_naive_llm_classifier.py +2 -2
  132. cognee/tasks/codingagents/coding_rule_associations.py +3 -2
  133. cognee/tasks/entity_completion/entity_extractors/llm_entity_extractor.py +3 -2
  134. cognee/tasks/graph/cascade_extract/utils/extract_content_nodes_and_relationship_names.py +3 -2
  135. cognee/tasks/graph/cascade_extract/utils/extract_edge_triplets.py +3 -2
  136. cognee/tasks/graph/cascade_extract/utils/extract_nodes.py +3 -2
  137. cognee/tasks/graph/extract_graph_from_code.py +2 -2
  138. cognee/tasks/graph/extract_graph_from_data.py +55 -12
  139. cognee/tasks/graph/extract_graph_from_data_v2.py +16 -4
  140. cognee/tasks/ingestion/migrate_relational_database.py +132 -41
  141. cognee/tasks/ingestion/resolve_data_directories.py +4 -1
  142. cognee/tasks/schema/ingest_database_schema.py +134 -0
  143. cognee/tasks/schema/models.py +40 -0
  144. cognee/tasks/storage/index_data_points.py +1 -1
  145. cognee/tasks/storage/index_graph_edges.py +3 -1
  146. cognee/tasks/summarization/summarize_code.py +2 -2
  147. cognee/tasks/summarization/summarize_text.py +2 -2
  148. cognee/tasks/temporal_graph/enrich_events.py +2 -2
  149. cognee/tasks/temporal_graph/extract_events_and_entities.py +2 -2
  150. cognee/tests/cli_tests/cli_unit_tests/test_cli_commands.py +13 -4
  151. cognee/tests/cli_tests/cli_unit_tests/test_cli_edge_cases.py +13 -3
  152. cognee/tests/test_advanced_pdf_loader.py +141 -0
  153. cognee/tests/test_chromadb.py +40 -0
  154. cognee/tests/test_cognee_server_start.py +6 -1
  155. cognee/tests/test_data/Quantum_computers.txt +9 -0
  156. cognee/tests/test_lancedb.py +211 -0
  157. cognee/tests/test_pgvector.py +40 -0
  158. cognee/tests/test_relational_db_migration.py +76 -0
  159. cognee/tests/unit/infrastructure/databases/test_index_graph_edges.py +2 -1
  160. cognee/tests/unit/modules/ontology/test_ontology_adapter.py +330 -13
  161. cognee/tests/unit/modules/retrieval/graph_completion_retriever_context_extension_test.py +0 -4
  162. cognee/tests/unit/modules/retrieval/graph_completion_retriever_cot_test.py +0 -4
  163. cognee/tests/unit/modules/retrieval/graph_completion_retriever_test.py +0 -4
  164. {cognee-0.3.4.dev4.dist-info → cognee-0.3.6.dist-info}/METADATA +92 -96
  165. {cognee-0.3.4.dev4.dist-info → cognee-0.3.6.dist-info}/RECORD +172 -160
  166. cognee/infrastructure/data/utils/extract_keywords.py +0 -48
  167. cognee/infrastructure/databases/hybrid/falkordb/FalkorDBAdapter.py +0 -1227
  168. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_categories.baml +0 -109
  169. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_content_graph.baml +0 -343
  170. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_categories.py +0 -0
  171. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_summary.py +0 -89
  172. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/__init__.py +0 -0
  173. cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/extract_content_graph.py +0 -44
  174. cognee/tasks/graph/infer_data_ontology.py +0 -309
  175. cognee/tests/test_falkordb.py +0 -174
  176. distributed/poetry.lock +0 -12238
  177. distributed/pyproject.toml +0 -186
  178. /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/__init__.py +0 -0
  179. /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/__init__.py +0 -0
  180. /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/texts.json +0 -0
  181. {cognee-0.3.4.dev4.dist-info → cognee-0.3.6.dist-info}/WHEEL +0 -0
  182. {cognee-0.3.4.dev4.dist-info → cognee-0.3.6.dist-info}/entry_points.txt +0 -0
  183. {cognee-0.3.4.dev4.dist-info → cognee-0.3.6.dist-info}/licenses/LICENSE +0 -0
  184. {cognee-0.3.4.dev4.dist-info → cognee-0.3.6.dist-info}/licenses/NOTICE.md +0 -0
@@ -44,6 +44,7 @@ class BamlAsyncClient:
44
44
  typing.Union[baml_py.baml_py.Collector, typing.List[baml_py.baml_py.Collector]]
45
45
  ] = None,
46
46
  env: typing.Optional[typing.Dict[str, typing.Optional[str]]] = None,
47
+ on_tick: typing.Optional[typing.Callable[[str, baml_py.baml_py.FunctionLog], None]] = None,
47
48
  ) -> "BamlAsyncClient":
48
49
  options: BamlCallOptions = {}
49
50
  if tb is not None:
@@ -54,6 +55,8 @@ class BamlAsyncClient:
54
55
  options["collector"] = collector
55
56
  if env is not None:
56
57
  options["env"] = env
58
+ if on_tick is not None:
59
+ options["on_tick"] = on_tick
57
60
  return BamlAsyncClient(self.__options.merge_options(options))
58
61
 
59
62
  @property
@@ -76,106 +79,31 @@ class BamlAsyncClient:
76
79
  def parse_stream(self):
77
80
  return self.__llm_stream_parser
78
81
 
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
- )
82
+ async def AcreateStructuredOutput(
83
+ self,
84
+ text_input: str,
85
+ system_prompt: str,
86
+ baml_options: BamlCallOptions = {},
87
+ ) -> types.ResponseModel:
88
+ # Check if on_tick is provided
89
+ if "on_tick" in baml_options:
90
+ # Use streaming internally when on_tick is provided
91
+ stream = self.stream.AcreateStructuredOutput(
92
+ text_input=text_input, system_prompt=system_prompt, baml_options=baml_options
93
+ )
94
+ return await stream.get_final_response()
95
+ else:
96
+ # Original non-streaming code
97
+ result = await self.__options.merge_options(baml_options).call_function_async(
98
+ function_name="AcreateStructuredOutput",
99
+ args={
100
+ "text_input": text_input,
101
+ "system_prompt": system_prompt,
102
+ },
103
+ )
104
+ return typing.cast(
105
+ types.ResponseModel, result.cast_to(types, types, stream_types, False, __runtime__)
106
+ )
179
107
 
180
108
 
181
109
  class BamlStreamClient:
@@ -184,145 +112,26 @@ class BamlStreamClient:
184
112
  def __init__(self, options: DoNotUseDirectlyCallManager):
185
113
  self.__options = options
186
114
 
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(
115
+ def AcreateStructuredOutput(
308
116
  self,
309
- content: str,
117
+ text_input: str,
118
+ system_prompt: str,
310
119
  baml_options: BamlCallOptions = {},
311
- ) -> baml_py.BamlStream[stream_types.SummarizedContent, types.SummarizedContent]:
120
+ ) -> baml_py.BamlStream[stream_types.ResponseModel, types.ResponseModel]:
312
121
  ctx, result = self.__options.merge_options(baml_options).create_async_stream(
313
- function_name="SummarizeContent",
122
+ function_name="AcreateStructuredOutput",
314
123
  args={
315
- "content": content,
124
+ "text_input": text_input,
125
+ "system_prompt": system_prompt,
316
126
  },
317
127
  )
318
- return baml_py.BamlStream[stream_types.SummarizedContent, types.SummarizedContent](
128
+ return baml_py.BamlStream[stream_types.ResponseModel, types.ResponseModel](
319
129
  result,
320
130
  lambda x: typing.cast(
321
- stream_types.SummarizedContent,
322
- x.cast_to(types, types, stream_types, True, __runtime__),
131
+ stream_types.ResponseModel, x.cast_to(types, types, stream_types, True, __runtime__)
323
132
  ),
324
133
  lambda x: typing.cast(
325
- types.SummarizedContent, x.cast_to(types, types, stream_types, False, __runtime__)
134
+ types.ResponseModel, x.cast_to(types, types, stream_types, False, __runtime__)
326
135
  ),
327
136
  ctx,
328
137
  )
@@ -334,95 +143,17 @@ class BamlHttpRequestClient:
334
143
  def __init__(self, options: DoNotUseDirectlyCallManager):
335
144
  self.__options = options
336
145
 
337
- async def ExtractCategories(
146
+ async def AcreateStructuredOutput(
338
147
  self,
339
- content: str,
148
+ text_input: str,
149
+ system_prompt: str,
340
150
  baml_options: BamlCallOptions = {},
341
151
  ) -> baml_py.baml_py.HTTPRequest:
342
152
  result = await self.__options.merge_options(baml_options).create_http_request_async(
343
- function_name="ExtractCategories",
153
+ function_name="AcreateStructuredOutput",
344
154
  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,
155
+ "text_input": text_input,
156
+ "system_prompt": system_prompt,
426
157
  },
427
158
  mode="request",
428
159
  )
@@ -435,95 +166,17 @@ class BamlHttpStreamRequestClient:
435
166
  def __init__(self, options: DoNotUseDirectlyCallManager):
436
167
  self.__options = options
437
168
 
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(
169
+ async def AcreateStructuredOutput(
519
170
  self,
520
- content: str,
171
+ text_input: str,
172
+ system_prompt: str,
521
173
  baml_options: BamlCallOptions = {},
522
174
  ) -> baml_py.baml_py.HTTPRequest:
523
175
  result = await self.__options.merge_options(baml_options).create_http_request_async(
524
- function_name="SummarizeContent",
176
+ function_name="AcreateStructuredOutput",
525
177
  args={
526
- "content": content,
178
+ "text_input": text_input,
179
+ "system_prompt": system_prompt,
527
180
  },
528
181
  mode="stream",
529
182
  )
@@ -11,9 +11,8 @@
11
11
  # baml-cli is available with the baml package.
12
12
 
13
13
  _file_map = {
14
- "extract_categories.baml": '// Content classification data models - matching shared/data_models.py\nclass TextContent {\n type string\n subclass string[]\n}\n\nclass AudioContent {\n type string\n subclass string[]\n}\n\nclass ImageContent {\n type string\n subclass string[]\n}\n\nclass VideoContent {\n type string\n subclass string[]\n}\n\nclass MultimediaContent {\n type string\n subclass string[]\n}\n\nclass Model3DContent {\n type string\n subclass string[]\n}\n\nclass ProceduralContent {\n type string\n subclass string[]\n}\n\nclass ContentLabel {\n content_type "text" | "audio" | "image" | "video" | "multimedia" | "3d_model" | "procedural"\n type string\n subclass string[]\n}\n\nclass DefaultContentPrediction {\n label ContentLabel\n}\n\n// Content classification prompt template\ntemplate_string ClassifyContentPrompt() #"\n You are a classification engine and should classify content. Make sure to use one of the existing classification options and not invent your own.\n\n Classify the content into one of these main categories and their relevant subclasses:\n\n **TEXT CONTENT** (content_type: "text"):\n - type: "TEXTUAL_DOCUMENTS_USED_FOR_GENERAL_PURPOSES"\n - subclass options: ["Articles, essays, and reports", "Books and manuscripts", "News stories and blog posts", "Research papers and academic publications", "Social media posts and comments", "Website content and product descriptions", "Personal narratives and stories", "Spreadsheets and tables", "Forms and surveys", "Databases and CSV files", "Source code in various programming languages", "Shell commands and scripts", "Markup languages (HTML, XML)", "Stylesheets (CSS) and configuration files (YAML, JSON, INI)", "Chat transcripts and messaging history", "Customer service logs and interactions", "Conversational AI training data", "Textbook content and lecture notes", "Exam questions and academic exercises", "E-learning course materials", "Poetry and prose", "Scripts for plays, movies, and television", "Song lyrics", "Manuals and user guides", "Technical specifications and API documentation", "Helpdesk articles and FAQs", "Contracts and agreements", "Laws, regulations, and legal case documents", "Policy documents and compliance materials", "Clinical trial reports", "Patient records and case notes", "Scientific journal articles", "Financial reports and statements", "Business plans and proposals", "Market research and analysis reports", "Ad copies and marketing slogans", "Product catalogs and brochures", "Press releases and promotional content", "Professional and formal correspondence", "Personal emails and letters", "Image and video captions", "Annotations and metadata for various media", "Vocabulary lists and grammar rules", "Language exercises and quizzes", "Other types of text data"]\n\n **AUDIO CONTENT** (content_type: "audio"):\n - type: "AUDIO_DOCUMENTS_USED_FOR_GENERAL_PURPOSES"\n - subclass options: ["Music tracks and albums", "Podcasts and radio broadcasts", "Audiobooks and audio guides", "Recorded interviews and speeches", "Sound effects and ambient sounds", "Other types of audio recordings"]\n\n **IMAGE CONTENT** (content_type: "image"):\n - type: "IMAGE_DOCUMENTS_USED_FOR_GENERAL_PURPOSES"\n - subclass options: ["Photographs and digital images", "Illustrations, diagrams, and charts", "Infographics and visual data representations", "Artwork and paintings", "Screenshots and graphical user interfaces", "Other types of images"]\n\n **VIDEO CONTENT** (content_type: "video"):\n - type: "VIDEO_DOCUMENTS_USED_FOR_GENERAL_PURPOSES"\n - subclass options: ["Movies and short films", "Documentaries and educational videos", "Video tutorials and how-to guides", "Animated features and cartoons", "Live event recordings and sports broadcasts", "Other types of video content"]\n\n **MULTIMEDIA CONTENT** (content_type: "multimedia"):\n - type: "MULTIMEDIA_DOCUMENTS_USED_FOR_GENERAL_PURPOSES"\n - subclass options: ["Interactive web content and games", "Virtual reality (VR) and augmented reality (AR) experiences", "Mixed media presentations and slide decks", "E-learning modules with integrated multimedia", "Digital exhibitions and virtual tours", "Other types of multimedia content"]\n\n **3D MODEL CONTENT** (content_type: "3d_model"):\n - type: "3D_MODEL_DOCUMENTS_USED_FOR_GENERAL_PURPOSES"\n - subclass options: ["Architectural renderings and building plans", "Product design models and prototypes", "3D animations and character models", "Scientific simulations and visualizations", "Virtual objects for AR/VR applications", "Other types of 3D models"]\n\n **PROCEDURAL CONTENT** (content_type: "procedural"):\n - type: "PROCEDURAL_DOCUMENTS_USED_FOR_GENERAL_PURPOSES"\n - subclass options: ["Tutorials and step-by-step guides", "Workflow and process descriptions", "Simulation and training exercises", "Recipes and crafting instructions", "Other types of procedural content"]\n\n Select the most appropriate content_type, type, and relevant subclasses.\n"#\n\n// OpenAI client defined once for all BAML files\n\n// Classification function\nfunction ExtractCategories(content: string) -> DefaultContentPrediction {\n client OpenAI\n\n prompt #"\n {{ ClassifyContentPrompt() }}\n\n {{ ctx.output_format(prefix="Answer in this schema:\\n") }}\n\n {{ _.role(\'user\') }}\n {{ content }}\n "#\n}\n\n// Test case for classification\ntest ExtractCategoriesExample {\n functions [ExtractCategories]\n args {\n content #"\n Natural language processing (NLP) is an interdisciplinary subfield of computer science and information retrieval.\n It deals with the interaction between computers and human language, in particular how to program computers to process and analyze large amounts of natural language data.\n "#\n }\n}\n',
15
- "extract_content_graph.baml": 'class Node {\n id string\n name string\n type string\n description string\n @@dynamic\n}\n\n/// doc string for edge\nclass Edge {\n /// doc string for source_node_id\n source_node_id string\n target_node_id string\n relationship_name string\n}\n\nclass KnowledgeGraph {\n nodes (Node @stream.done)[]\n edges Edge[]\n}\n\n// Summarization classes\nclass SummarizedContent {\n summary string\n description string\n}\n\nclass SummarizedFunction {\n name string\n description string\n inputs string[]?\n outputs string[]?\n decorators string[]?\n}\n\nclass SummarizedClass {\n name string\n description string\n methods SummarizedFunction[]?\n decorators string[]?\n}\n\nclass SummarizedCode {\n high_level_summary string\n key_features string[]\n imports string[]\n constants string[]\n classes SummarizedClass[]\n functions SummarizedFunction[]\n workflow_description string?\n}\n\nclass DynamicKnowledgeGraph {\n @@dynamic\n}\n\n\n// Simple template for basic extraction (fast, good quality)\ntemplate_string ExtractContentGraphPrompt() #"\n You are an advanced algorithm that extracts structured data into a knowledge graph.\n\n - **Nodes**: Entities/concepts (like Wikipedia articles).\n - **Edges**: Relationships (like Wikipedia links). Use snake_case (e.g., `acted_in`).\n\n **Rules:**\n\n 1. **Node Labeling & IDs**\n - Use basic types only (e.g., "Person", "Date", "Organization").\n - Avoid overly specific or generic terms (e.g., no "Mathematician" or "Entity").\n - Node IDs must be human-readable names from the text (no numbers).\n\n 2. **Dates & Numbers**\n - Label dates as **"Date"** in "YYYY-MM-DD" format (use available parts if incomplete).\n - Properties are key-value pairs; do not use escaped quotes.\n\n 3. **Coreference Resolution**\n - Use a single, complete identifier for each entity (e.g., always "John Doe" not "Joe" or "he").\n\n 4. **Relationship Labels**:\n - Use descriptive, lowercase, snake_case names for edges.\n - *Example*: born_in, married_to, invented_by.\n - Avoid vague or generic labels like isA, relatesTo, has.\n - Avoid duplicated relationships like produces, produced by.\n\n 5. **Strict Compliance**\n - Follow these rules exactly. Non-compliance results in termination.\n"#\n\n// Summarization prompt template\ntemplate_string SummarizeContentPrompt() #"\n You are a top-tier summarization engine. Your task is to summarize text and make it versatile.\n Be brief and concise, but keep the important information and the subject.\n Use synonym words where possible in order to change the wording but keep the meaning.\n"#\n\n// Code summarization prompt template\ntemplate_string SummarizeCodePrompt() #"\n You are an expert code analyst. Analyze the provided source code and extract key information:\n\n 1. Provide a high-level summary of what the code does\n 2. List key features and functionality\n 3. Identify imports and dependencies\n 4. List constants and global variables\n 5. Summarize classes with their methods\n 6. Summarize standalone functions\n 7. Describe the overall workflow if applicable\n\n Be precise and technical while remaining clear and concise.\n"#\n\n// Detailed template for complex extraction (slower, higher quality)\ntemplate_string DetailedExtractContentGraphPrompt() #"\n You are a top-tier algorithm designed for extracting information in structured formats to build a knowledge graph.\n **Nodes** represent entities and concepts. They\'re akin to Wikipedia nodes.\n **Edges** represent relationships between concepts. They\'re akin to Wikipedia links.\n\n The aim is to achieve simplicity and clarity in the knowledge graph.\n\n # 1. Labeling Nodes\n **Consistency**: Ensure you use basic or elementary types for node labels.\n - For example, when you identify an entity representing a person, always label it as **"Person"**.\n - Avoid using more specific terms like "Mathematician" or "Scientist", keep those as "profession" property.\n - Don\'t use too generic terms like "Entity".\n **Node IDs**: Never utilize integers as node IDs.\n - Node IDs should be names or human-readable identifiers found in the text.\n\n # 2. Handling Numerical Data and Dates\n - For example, when you identify an entity representing a date, make sure it has type **"Date"**.\n - Extract the date in the format "YYYY-MM-DD"\n - If not possible to extract the whole date, extract month or year, or both if available.\n - **Property Format**: Properties must be in a key-value format.\n - **Quotation Marks**: Never use escaped single or double quotes within property values.\n - **Naming Convention**: Use snake_case for relationship names, e.g., `acted_in`.\n\n # 3. Coreference Resolution\n - **Maintain Entity Consistency**: When extracting entities, it\'s vital to ensure consistency.\n If an entity, such as "John Doe", is mentioned multiple times in the text but is referred to by different names or pronouns (e.g., "Joe", "he"),\n always use the most complete identifier for that entity throughout the knowledge graph. In this example, use "John Doe" as the Person\'s ID.\n Remember, the knowledge graph should be coherent and easily understandable, so maintaining consistency in entity references is crucial.\n\n # 4. Strict Compliance\n Adhere to the rules strictly. Non-compliance will result in termination.\n"#\n\n// Guided template with step-by-step instructions\ntemplate_string GuidedExtractContentGraphPrompt() #"\n You are an advanced algorithm designed to extract structured information to build a clean, consistent, and human-readable knowledge graph.\n\n **Objective**:\n - Nodes represent entities and concepts, similar to Wikipedia articles.\n - Edges represent typed relationships between nodes, similar to Wikipedia hyperlinks.\n - The graph must be clear, minimal, consistent, and semantically precise.\n\n **Node Guidelines**:\n\n 1. **Label Consistency**:\n - Use consistent, basic types for all node labels.\n - Do not switch between granular or vague labels for the same kind of entity.\n - Pick one label for each category and apply it uniformly.\n - Each entity type should be in a singular form and in a case of multiple words separated by whitespaces\n\n 2. **Node Identifiers**:\n - Node IDs must be human-readable and derived directly from the text.\n - Prefer full names and canonical terms.\n - Never use integers or autogenerated IDs.\n - *Example*: Use "Marie Curie", "Theory of Evolution", "Google".\n\n 3. **Coreference Resolution**:\n - Maintain one consistent node ID for each real-world entity.\n - Resolve aliases, acronyms, and pronouns to the most complete form.\n - *Example*: Always use "John Doe" even if later referred to as "Doe" or "he".\n\n **Edge Guidelines**:\n\n 4. **Relationship Labels**:\n - Use descriptive, lowercase, snake_case names for edges.\n - *Example*: born_in, married_to, invented_by.\n - Avoid vague or generic labels like isA, relatesTo, has.\n\n 5. **Relationship Direction**:\n - Edges must be directional and logically consistent.\n - *Example*:\n - "Marie Curie" —[born_in]→ "Warsaw"\n - "Radioactivity" —[discovered_by]→ "Marie Curie"\n\n **Compliance**:\n Strict adherence to these guidelines is required. Any deviation will result in immediate termination of the task.\n"#\n\n// Strict template with zero-tolerance rules\ntemplate_string StrictExtractContentGraphPrompt() #"\n You are a top-tier algorithm for **extracting structured information** from unstructured text to build a **knowledge graph**.\n\n Your primary goal is to extract:\n - **Nodes**: Representing **entities** and **concepts** (like Wikipedia nodes).\n - **Edges**: Representing **relationships** between those concepts (like Wikipedia links).\n\n The resulting knowledge graph must be **simple, consistent, and human-readable**.\n\n ## 1. Node Labeling and Identification\n\n ### Node Types\n Use **basic atomic types** for node labels. Always prefer general types over specific roles or professions:\n - "Person" for any human.\n - "Organization" for companies, institutions, etc.\n - "Location" for geographic or place entities.\n - "Date" for any temporal expression.\n - "Event" for historical or scheduled occurrences.\n - "Work" for books, films, artworks, or research papers.\n - "Concept" for abstract notions or ideas.\n\n ### Node IDs\n - Always assign **human-readable and unambiguous identifiers**.\n - Never use numeric or autogenerated IDs.\n - Prioritize **most complete form** of entity names for consistency.\n\n ## 2. Relationship Handling\n - Use **snake_case** for all relationship (edge) types.\n - Keep relationship types semantically clear and consistent.\n - Avoid vague relation names like "related_to" unless no better alternative exists.\n\n ## 3. Strict Compliance\n Follow all rules exactly. Any deviation may lead to rejection or incorrect graph construction.\n"#\n\n// OpenAI client with environment model selection\nclient<llm> OpenAI {\n provider openai\n options {\n model client_registry.model\n api_key client_registry.api_key\n }\n}\n\n\n\n// Function that returns raw structured output (for custom objects - to be handled in Python)\nfunction ExtractContentGraphGeneric(\n content: string,\n mode: "simple" | "base" | "guided" | "strict" | "custom"?,\n custom_prompt_content: string?\n) -> KnowledgeGraph {\n client OpenAI\n\n prompt #"\n {% if mode == "base" %}\n {{ DetailedExtractContentGraphPrompt() }}\n {% elif mode == "guided" %}\n {{ GuidedExtractContentGraphPrompt() }}\n {% elif mode == "strict" %}\n {{ StrictExtractContentGraphPrompt() }}\n {% elif mode == "custom" and custom_prompt_content %}\n {{ custom_prompt_content }}\n {% else %}\n {{ ExtractContentGraphPrompt() }}\n {% endif %}\n\n {{ ctx.output_format(prefix="Answer in this schema:\\n") }}\n\n Before answering, briefly describe what you\'ll extract from the text, then provide the structured output.\n\n Example format:\n I\'ll extract the main entities and their relationships from this text...\n\n { ... }\n\n {{ _.role(\'user\') }}\n {{ content }}\n "#\n}\n\n// Backward-compatible function specifically for KnowledgeGraph\nfunction ExtractDynamicContentGraph(\n content: string,\n mode: "simple" | "base" | "guided" | "strict" | "custom"?,\n custom_prompt_content: string?\n) -> DynamicKnowledgeGraph {\n client OpenAI\n\n prompt #"\n {% if mode == "base" %}\n {{ DetailedExtractContentGraphPrompt() }}\n {% elif mode == "guided" %}\n {{ GuidedExtractContentGraphPrompt() }}\n {% elif mode == "strict" %}\n {{ StrictExtractContentGraphPrompt() }}\n {% elif mode == "custom" and custom_prompt_content %}\n {{ custom_prompt_content }}\n {% else %}\n {{ ExtractContentGraphPrompt() }}\n {% endif %}\n\n {{ ctx.output_format(prefix="Answer in this schema:\\n") }}\n\n Before answering, briefly describe what you\'ll extract from the text, then provide the structured output.\n\n Example format:\n I\'ll extract the main entities and their relationships from this text...\n\n { ... }\n\n {{ _.role(\'user\') }}\n {{ content }}\n "#\n}\n\n\n// Summarization functions\nfunction SummarizeContent(content: string) -> SummarizedContent {\n client OpenAI\n\n prompt #"\n {{ SummarizeContentPrompt() }}\n\n {{ ctx.output_format(prefix="Answer in this schema:\\n") }}\n\n {{ _.role(\'user\') }}\n {{ content }}\n "#\n}\n\nfunction SummarizeCode(content: string) -> SummarizedCode {\n client OpenAI\n\n prompt #"\n {{ SummarizeCodePrompt() }}\n\n {{ ctx.output_format(prefix="Answer in this schema:\\n") }}\n\n {{ _.role(\'user\') }}\n {{ content }}\n "#\n}\n\ntest ExtractStrictExample {\n functions [ExtractContentGraphGeneric]\n args {\n content #"\n The Python programming language was created by Guido van Rossum in 1991.\n "#\n mode "strict"\n }\n}',
16
- "generators.baml": '// This helps use auto generate libraries you can use in the language of\n// your choice. You can have multiple generators if you use multiple languages.\n// Just ensure that the output_dir is different for each generator.\ngenerator target {\n // Valid values: "python/pydantic", "typescript", "ruby/sorbet", "rest/openapi"\n output_type "python/pydantic"\n\n // Where the generated code will be saved (relative to baml_src/)\n output_dir "../baml/"\n\n // The version of the BAML package you have installed (e.g. same version as your baml-py or @boundaryml/baml).\n // The BAML VSCode extension version should also match this version.\n version "0.201.0"\n\n // Valid values: "sync", "async"\n // This controls what `b.FunctionName()` will be (sync or async).\n default_client_mode sync\n}\n',
14
+ "acreate_structured_output.baml": "class ResponseModel {\n @@dynamic\n}\n\n// OpenAI client with environment model selection\nclient<llm> OpenAI {\n provider openai\n options {\n model client_registry.model\n api_key client_registry.api_key\n }\n}\n\nfunction AcreateStructuredOutput(\n text_input: string,\n system_prompt: string,\n) -> ResponseModel {\n client OpenAI\n\n prompt #\"\n {{ system_prompt }}\n {{ ctx.output_format }}\n {{ _.role('user') }}\n {{ text_input }}\n \"#\n}\n",
15
+ "generators.baml": '// This helps use auto generate libraries you can use in the language of\n// your choice. You can have multiple generators if you use multiple languages.\n// Just ensure that the output_dir is different for each generator.\ngenerator target {\n // Valid values: "python/pydantic", "typescript", "ruby/sorbet", "rest/openapi"\n output_type "python/pydantic"\n\n // Where the generated code will be saved (relative to baml_src/)\n output_dir "../"\n\n // The version of the BAML package you have installed (e.g. same version as your baml-py or @boundaryml/baml).\n // The BAML VSCode extension version should also match this version.\n version "0.206.0"\n\n // Valid values: "sync", "async"\n // This controls what `b.FunctionName()` will be (sync or async).\n default_client_mode async\n}\n',
17
16
  }
18
17
 
19
18