cognee 0.3.4.dev3__py3-none-any.whl → 0.3.5__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.
- cognee/api/client.py +16 -7
- cognee/api/health.py +5 -9
- cognee/api/v1/add/add.py +3 -1
- cognee/api/v1/cognify/cognify.py +44 -7
- cognee/api/v1/permissions/routers/get_permissions_router.py +8 -4
- cognee/api/v1/search/search.py +3 -0
- cognee/api/v1/ui/__init__.py +1 -1
- cognee/api/v1/ui/ui.py +215 -150
- cognee/api/v1/update/__init__.py +1 -0
- cognee/api/v1/update/routers/__init__.py +1 -0
- cognee/api/v1/update/routers/get_update_router.py +90 -0
- cognee/api/v1/update/update.py +100 -0
- cognee/base_config.py +5 -2
- cognee/cli/_cognee.py +28 -10
- cognee/cli/commands/delete_command.py +34 -2
- cognee/eval_framework/corpus_builder/task_getters/get_default_tasks_by_indices.py +2 -2
- cognee/eval_framework/evaluation/direct_llm_eval_adapter.py +3 -2
- cognee/eval_framework/modal_eval_dashboard.py +9 -1
- cognee/infrastructure/databases/graph/config.py +9 -9
- cognee/infrastructure/databases/graph/get_graph_engine.py +4 -21
- cognee/infrastructure/databases/graph/kuzu/adapter.py +60 -9
- cognee/infrastructure/databases/hybrid/neptune_analytics/NeptuneAnalyticsAdapter.py +3 -3
- cognee/infrastructure/databases/relational/config.py +4 -4
- cognee/infrastructure/databases/relational/create_relational_engine.py +11 -3
- cognee/infrastructure/databases/vector/chromadb/ChromaDBAdapter.py +7 -3
- cognee/infrastructure/databases/vector/config.py +7 -7
- cognee/infrastructure/databases/vector/create_vector_engine.py +7 -15
- cognee/infrastructure/databases/vector/embeddings/EmbeddingEngine.py +9 -0
- cognee/infrastructure/databases/vector/embeddings/FastembedEmbeddingEngine.py +11 -0
- cognee/infrastructure/databases/vector/embeddings/LiteLLMEmbeddingEngine.py +19 -2
- cognee/infrastructure/databases/vector/embeddings/OllamaEmbeddingEngine.py +11 -0
- cognee/infrastructure/databases/vector/embeddings/config.py +8 -0
- cognee/infrastructure/databases/vector/embeddings/get_embedding_engine.py +5 -0
- cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py +11 -10
- cognee/infrastructure/databases/vector/pgvector/PGVectorAdapter.py +48 -38
- cognee/infrastructure/databases/vector/vector_db_interface.py +8 -4
- cognee/infrastructure/files/storage/S3FileStorage.py +15 -5
- cognee/infrastructure/files/storage/s3_config.py +1 -0
- cognee/infrastructure/files/utils/open_data_file.py +7 -14
- cognee/infrastructure/llm/LLMGateway.py +19 -117
- cognee/infrastructure/llm/config.py +28 -13
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_categories.py +2 -1
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_event_entities.py +3 -2
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/extract_summary.py +3 -2
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/extract_content_graph.py +2 -1
- cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/extract_event_graph.py +3 -2
- cognee/infrastructure/llm/prompts/read_query_prompt.py +3 -2
- cognee/infrastructure/llm/prompts/show_prompt.py +35 -0
- cognee/infrastructure/llm/prompts/test.txt +1 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/__init__.py +2 -2
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/async_client.py +50 -397
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/inlinedbaml.py +2 -3
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/parser.py +8 -88
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/runtime.py +78 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/stream_types.py +2 -99
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/sync_client.py +49 -401
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_builder.py +19 -882
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/type_map.py +2 -34
- cognee/infrastructure/llm/structured_output_framework/baml/baml_client/types.py +2 -107
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/acreate_structured_output.baml +26 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/__init__.py +1 -2
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/acreate_structured_output.py +76 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/create_dynamic_baml_type.py +122 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/generators.baml +3 -3
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/anthropic/adapter.py +0 -32
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/gemini/adapter.py +107 -98
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/generic_llm_api/adapter.py +5 -6
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/get_llm_client.py +5 -6
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/llm_interface.py +0 -26
- cognee/infrastructure/llm/structured_output_framework/litellm_instructor/llm/openai/adapter.py +17 -67
- cognee/infrastructure/llm/tokenizer/Gemini/adapter.py +8 -7
- cognee/infrastructure/llm/utils.py +4 -4
- cognee/infrastructure/loaders/LoaderEngine.py +5 -2
- cognee/infrastructure/loaders/external/__init__.py +7 -0
- cognee/infrastructure/loaders/external/advanced_pdf_loader.py +244 -0
- cognee/infrastructure/loaders/supported_loaders.py +7 -0
- cognee/modules/data/methods/create_authorized_dataset.py +9 -0
- cognee/modules/data/methods/get_authorized_dataset.py +1 -1
- cognee/modules/data/methods/get_authorized_dataset_by_name.py +11 -0
- cognee/modules/data/methods/get_deletion_counts.py +92 -0
- cognee/modules/graph/cognee_graph/CogneeGraph.py +1 -1
- cognee/modules/graph/utils/expand_with_nodes_and_edges.py +22 -8
- cognee/modules/graph/utils/retrieve_existing_edges.py +0 -2
- cognee/modules/ingestion/data_types/TextData.py +0 -1
- cognee/modules/notebooks/methods/create_notebook.py +3 -1
- cognee/modules/notebooks/methods/get_notebooks.py +27 -1
- cognee/modules/observability/get_observe.py +14 -0
- cognee/modules/observability/observers.py +1 -0
- cognee/modules/ontology/base_ontology_resolver.py +42 -0
- cognee/modules/ontology/get_default_ontology_resolver.py +41 -0
- cognee/modules/ontology/matching_strategies.py +53 -0
- cognee/modules/ontology/models.py +20 -0
- cognee/modules/ontology/ontology_config.py +24 -0
- cognee/modules/ontology/ontology_env_config.py +45 -0
- cognee/modules/ontology/rdf_xml/{OntologyResolver.py → RDFLibOntologyResolver.py} +20 -28
- cognee/modules/pipelines/layers/resolve_authorized_user_dataset.py +21 -24
- cognee/modules/pipelines/layers/resolve_authorized_user_datasets.py +3 -3
- cognee/modules/retrieval/code_retriever.py +2 -1
- cognee/modules/retrieval/context_providers/TripletSearchContextProvider.py +1 -4
- cognee/modules/retrieval/graph_completion_cot_retriever.py +6 -5
- cognee/modules/retrieval/graph_completion_retriever.py +0 -3
- cognee/modules/retrieval/insights_retriever.py +1 -1
- cognee/modules/retrieval/jaccard_retrival.py +60 -0
- cognee/modules/retrieval/lexical_retriever.py +123 -0
- cognee/modules/retrieval/natural_language_retriever.py +2 -1
- cognee/modules/retrieval/temporal_retriever.py +3 -2
- cognee/modules/retrieval/utils/brute_force_triplet_search.py +2 -12
- cognee/modules/retrieval/utils/completion.py +4 -7
- cognee/modules/search/methods/get_search_type_tools.py +7 -0
- cognee/modules/search/methods/no_access_control_search.py +1 -1
- cognee/modules/search/methods/search.py +32 -13
- cognee/modules/search/types/SearchType.py +1 -0
- cognee/modules/users/methods/create_user.py +0 -2
- cognee/modules/users/permissions/methods/authorized_give_permission_on_datasets.py +12 -0
- cognee/modules/users/permissions/methods/check_permission_on_dataset.py +11 -0
- cognee/modules/users/permissions/methods/get_all_user_permission_datasets.py +10 -0
- cognee/modules/users/permissions/methods/get_document_ids_for_user.py +10 -0
- cognee/modules/users/permissions/methods/get_principal.py +9 -0
- cognee/modules/users/permissions/methods/get_principal_datasets.py +11 -0
- cognee/modules/users/permissions/methods/get_role.py +10 -0
- cognee/modules/users/permissions/methods/get_specific_user_permission_datasets.py +3 -3
- cognee/modules/users/permissions/methods/get_tenant.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_role.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_tenant.py +9 -0
- cognee/modules/users/permissions/methods/give_default_permission_to_user.py +9 -0
- cognee/modules/users/permissions/methods/give_permission_on_dataset.py +10 -0
- cognee/modules/users/roles/methods/add_user_to_role.py +11 -0
- cognee/modules/users/roles/methods/create_role.py +12 -1
- cognee/modules/users/tenants/methods/add_user_to_tenant.py +12 -0
- cognee/modules/users/tenants/methods/create_tenant.py +12 -1
- cognee/modules/visualization/cognee_network_visualization.py +13 -9
- cognee/shared/data_models.py +0 -1
- cognee/shared/utils.py +0 -32
- cognee/tasks/chunk_naive_llm_classifier/chunk_naive_llm_classifier.py +2 -2
- cognee/tasks/codingagents/coding_rule_associations.py +3 -2
- cognee/tasks/entity_completion/entity_extractors/llm_entity_extractor.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_content_nodes_and_relationship_names.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_edge_triplets.py +3 -2
- cognee/tasks/graph/cascade_extract/utils/extract_nodes.py +3 -2
- cognee/tasks/graph/extract_graph_from_code.py +2 -2
- cognee/tasks/graph/extract_graph_from_data.py +55 -12
- cognee/tasks/graph/extract_graph_from_data_v2.py +16 -4
- cognee/tasks/ingestion/migrate_relational_database.py +132 -41
- cognee/tasks/ingestion/resolve_data_directories.py +4 -1
- cognee/tasks/schema/ingest_database_schema.py +134 -0
- cognee/tasks/schema/models.py +40 -0
- cognee/tasks/storage/index_data_points.py +1 -1
- cognee/tasks/storage/index_graph_edges.py +3 -1
- cognee/tasks/summarization/summarize_code.py +2 -2
- cognee/tasks/summarization/summarize_text.py +2 -2
- cognee/tasks/temporal_graph/enrich_events.py +2 -2
- cognee/tasks/temporal_graph/extract_events_and_entities.py +2 -2
- cognee/tests/cli_tests/cli_unit_tests/test_cli_commands.py +13 -4
- cognee/tests/cli_tests/cli_unit_tests/test_cli_edge_cases.py +13 -3
- cognee/tests/test_advanced_pdf_loader.py +141 -0
- cognee/tests/test_chromadb.py +40 -0
- cognee/tests/test_cognee_server_start.py +6 -1
- cognee/tests/test_data/Quantum_computers.txt +9 -0
- cognee/tests/test_lancedb.py +211 -0
- cognee/tests/test_pgvector.py +40 -0
- cognee/tests/test_relational_db_migration.py +76 -0
- cognee/tests/unit/infrastructure/databases/test_index_graph_edges.py +2 -1
- cognee/tests/unit/modules/ontology/test_ontology_adapter.py +330 -13
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_context_extension_test.py +0 -4
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_cot_test.py +0 -4
- cognee/tests/unit/modules/retrieval/graph_completion_retriever_test.py +0 -4
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/METADATA +92 -96
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/RECORD +176 -162
- distributed/pyproject.toml +0 -1
- cognee/infrastructure/data/utils/extract_keywords.py +0 -48
- cognee/infrastructure/databases/hybrid/falkordb/FalkorDBAdapter.py +0 -1227
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_categories.baml +0 -109
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extract_content_graph.baml +0 -343
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_categories.py +0 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/extract_summary.py +0 -89
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/__init__.py +0 -0
- cognee/infrastructure/llm/structured_output_framework/baml/baml_src/extraction/knowledge_graph/extract_content_graph.py +0 -44
- cognee/tasks/graph/infer_data_ontology.py +0 -309
- cognee/tests/test_falkordb.py +0 -174
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/__init__.py +0 -0
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/knowledge_graph/__init__.py +0 -0
- /cognee/infrastructure/llm/{structured_output_framework/litellm_instructor/extraction → extraction}/texts.json +0 -0
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/WHEEL +0 -0
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/entry_points.txt +0 -0
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.dist-info}/licenses/LICENSE +0 -0
- {cognee-0.3.4.dev3.dist-info → cognee-0.3.5.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
|
|
80
|
-
self,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
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
|
-
|
|
117
|
+
text_input: str,
|
|
118
|
+
system_prompt: str,
|
|
310
119
|
baml_options: BamlCallOptions = {},
|
|
311
|
-
) -> baml_py.BamlStream[stream_types.
|
|
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="
|
|
122
|
+
function_name="AcreateStructuredOutput",
|
|
314
123
|
args={
|
|
315
|
-
"
|
|
124
|
+
"text_input": text_input,
|
|
125
|
+
"system_prompt": system_prompt,
|
|
316
126
|
},
|
|
317
127
|
)
|
|
318
|
-
return baml_py.BamlStream[stream_types.
|
|
128
|
+
return baml_py.BamlStream[stream_types.ResponseModel, types.ResponseModel](
|
|
319
129
|
result,
|
|
320
130
|
lambda x: typing.cast(
|
|
321
|
-
stream_types.
|
|
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.
|
|
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
|
|
146
|
+
async def AcreateStructuredOutput(
|
|
338
147
|
self,
|
|
339
|
-
|
|
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="
|
|
153
|
+
function_name="AcreateStructuredOutput",
|
|
344
154
|
args={
|
|
345
|
-
"
|
|
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
|
|
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
|
-
|
|
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="
|
|
176
|
+
function_name="AcreateStructuredOutput",
|
|
525
177
|
args={
|
|
526
|
-
"
|
|
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
|
-
"
|
|
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
|
|