cognee 0.3.4.dev4__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/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/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.dev4.dist-info → cognee-0.3.5.dist-info}/METADATA +92 -96
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/RECORD +173 -159
- 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.dev4.dist-info → cognee-0.3.5.dist-info}/WHEEL +0 -0
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/entry_points.txt +0 -0
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/licenses/LICENSE +0 -0
- {cognee-0.3.4.dev4.dist-info → cognee-0.3.5.dist-info}/licenses/NOTICE.md +0 -0
|
@@ -23,55 +23,15 @@ class LlmResponseParser:
|
|
|
23
23
|
def __init__(self, options: DoNotUseDirectlyCallManager):
|
|
24
24
|
self.__options = options
|
|
25
25
|
|
|
26
|
-
def
|
|
26
|
+
def AcreateStructuredOutput(
|
|
27
27
|
self,
|
|
28
28
|
llm_response: str,
|
|
29
29
|
baml_options: BamlCallOptions = {},
|
|
30
|
-
) -> types.
|
|
30
|
+
) -> types.ResponseModel:
|
|
31
31
|
result = self.__options.merge_options(baml_options).parse_response(
|
|
32
|
-
function_name="
|
|
32
|
+
function_name="AcreateStructuredOutput", llm_response=llm_response, mode="request"
|
|
33
33
|
)
|
|
34
|
-
return typing.cast(types.
|
|
35
|
-
|
|
36
|
-
def ExtractContentGraphGeneric(
|
|
37
|
-
self,
|
|
38
|
-
llm_response: str,
|
|
39
|
-
baml_options: BamlCallOptions = {},
|
|
40
|
-
) -> types.KnowledgeGraph:
|
|
41
|
-
result = self.__options.merge_options(baml_options).parse_response(
|
|
42
|
-
function_name="ExtractContentGraphGeneric", llm_response=llm_response, mode="request"
|
|
43
|
-
)
|
|
44
|
-
return typing.cast(types.KnowledgeGraph, result)
|
|
45
|
-
|
|
46
|
-
def ExtractDynamicContentGraph(
|
|
47
|
-
self,
|
|
48
|
-
llm_response: str,
|
|
49
|
-
baml_options: BamlCallOptions = {},
|
|
50
|
-
) -> types.DynamicKnowledgeGraph:
|
|
51
|
-
result = self.__options.merge_options(baml_options).parse_response(
|
|
52
|
-
function_name="ExtractDynamicContentGraph", llm_response=llm_response, mode="request"
|
|
53
|
-
)
|
|
54
|
-
return typing.cast(types.DynamicKnowledgeGraph, result)
|
|
55
|
-
|
|
56
|
-
def SummarizeCode(
|
|
57
|
-
self,
|
|
58
|
-
llm_response: str,
|
|
59
|
-
baml_options: BamlCallOptions = {},
|
|
60
|
-
) -> types.SummarizedCode:
|
|
61
|
-
result = self.__options.merge_options(baml_options).parse_response(
|
|
62
|
-
function_name="SummarizeCode", llm_response=llm_response, mode="request"
|
|
63
|
-
)
|
|
64
|
-
return typing.cast(types.SummarizedCode, result)
|
|
65
|
-
|
|
66
|
-
def SummarizeContent(
|
|
67
|
-
self,
|
|
68
|
-
llm_response: str,
|
|
69
|
-
baml_options: BamlCallOptions = {},
|
|
70
|
-
) -> types.SummarizedContent:
|
|
71
|
-
result = self.__options.merge_options(baml_options).parse_response(
|
|
72
|
-
function_name="SummarizeContent", llm_response=llm_response, mode="request"
|
|
73
|
-
)
|
|
74
|
-
return typing.cast(types.SummarizedContent, result)
|
|
34
|
+
return typing.cast(types.ResponseModel, result)
|
|
75
35
|
|
|
76
36
|
|
|
77
37
|
class LlmStreamParser:
|
|
@@ -80,52 +40,12 @@ class LlmStreamParser:
|
|
|
80
40
|
def __init__(self, options: DoNotUseDirectlyCallManager):
|
|
81
41
|
self.__options = options
|
|
82
42
|
|
|
83
|
-
def
|
|
84
|
-
self,
|
|
85
|
-
llm_response: str,
|
|
86
|
-
baml_options: BamlCallOptions = {},
|
|
87
|
-
) -> stream_types.DefaultContentPrediction:
|
|
88
|
-
result = self.__options.merge_options(baml_options).parse_response(
|
|
89
|
-
function_name="ExtractCategories", llm_response=llm_response, mode="stream"
|
|
90
|
-
)
|
|
91
|
-
return typing.cast(stream_types.DefaultContentPrediction, result)
|
|
92
|
-
|
|
93
|
-
def ExtractContentGraphGeneric(
|
|
94
|
-
self,
|
|
95
|
-
llm_response: str,
|
|
96
|
-
baml_options: BamlCallOptions = {},
|
|
97
|
-
) -> stream_types.KnowledgeGraph:
|
|
98
|
-
result = self.__options.merge_options(baml_options).parse_response(
|
|
99
|
-
function_name="ExtractContentGraphGeneric", llm_response=llm_response, mode="stream"
|
|
100
|
-
)
|
|
101
|
-
return typing.cast(stream_types.KnowledgeGraph, result)
|
|
102
|
-
|
|
103
|
-
def ExtractDynamicContentGraph(
|
|
104
|
-
self,
|
|
105
|
-
llm_response: str,
|
|
106
|
-
baml_options: BamlCallOptions = {},
|
|
107
|
-
) -> stream_types.DynamicKnowledgeGraph:
|
|
108
|
-
result = self.__options.merge_options(baml_options).parse_response(
|
|
109
|
-
function_name="ExtractDynamicContentGraph", llm_response=llm_response, mode="stream"
|
|
110
|
-
)
|
|
111
|
-
return typing.cast(stream_types.DynamicKnowledgeGraph, result)
|
|
112
|
-
|
|
113
|
-
def SummarizeCode(
|
|
114
|
-
self,
|
|
115
|
-
llm_response: str,
|
|
116
|
-
baml_options: BamlCallOptions = {},
|
|
117
|
-
) -> stream_types.SummarizedCode:
|
|
118
|
-
result = self.__options.merge_options(baml_options).parse_response(
|
|
119
|
-
function_name="SummarizeCode", llm_response=llm_response, mode="stream"
|
|
120
|
-
)
|
|
121
|
-
return typing.cast(stream_types.SummarizedCode, result)
|
|
122
|
-
|
|
123
|
-
def SummarizeContent(
|
|
43
|
+
def AcreateStructuredOutput(
|
|
124
44
|
self,
|
|
125
45
|
llm_response: str,
|
|
126
46
|
baml_options: BamlCallOptions = {},
|
|
127
|
-
) -> stream_types.
|
|
47
|
+
) -> stream_types.ResponseModel:
|
|
128
48
|
result = self.__options.merge_options(baml_options).parse_response(
|
|
129
|
-
function_name="
|
|
49
|
+
function_name="AcreateStructuredOutput", llm_response=llm_response, mode="stream"
|
|
130
50
|
)
|
|
131
|
-
return typing.cast(stream_types.
|
|
51
|
+
return typing.cast(stream_types.ResponseModel, result)
|
|
@@ -30,6 +30,10 @@ class BamlCallOptions(typing.TypedDict, total=False):
|
|
|
30
30
|
collector: typing_extensions.NotRequired[
|
|
31
31
|
typing.Union[baml_py.baml_py.Collector, typing.List[baml_py.baml_py.Collector]]
|
|
32
32
|
]
|
|
33
|
+
abort_controller: typing_extensions.NotRequired[baml_py.baml_py.AbortController]
|
|
34
|
+
on_tick: typing_extensions.NotRequired[
|
|
35
|
+
typing.Callable[[str, baml_py.baml_py.FunctionLog], None]
|
|
36
|
+
]
|
|
33
37
|
|
|
34
38
|
|
|
35
39
|
class _ResolvedBamlOptions:
|
|
@@ -37,6 +41,8 @@ class _ResolvedBamlOptions:
|
|
|
37
41
|
client_registry: typing.Optional[baml_py.baml_py.ClientRegistry]
|
|
38
42
|
collectors: typing.List[baml_py.baml_py.Collector]
|
|
39
43
|
env_vars: typing.Dict[str, str]
|
|
44
|
+
abort_controller: typing.Optional[baml_py.baml_py.AbortController]
|
|
45
|
+
on_tick: typing.Optional[typing.Callable[[], None]]
|
|
40
46
|
|
|
41
47
|
def __init__(
|
|
42
48
|
self,
|
|
@@ -44,11 +50,15 @@ class _ResolvedBamlOptions:
|
|
|
44
50
|
client_registry: typing.Optional[baml_py.baml_py.ClientRegistry],
|
|
45
51
|
collectors: typing.List[baml_py.baml_py.Collector],
|
|
46
52
|
env_vars: typing.Dict[str, str],
|
|
53
|
+
abort_controller: typing.Optional[baml_py.baml_py.AbortController],
|
|
54
|
+
on_tick: typing.Optional[typing.Callable[[], None]],
|
|
47
55
|
):
|
|
48
56
|
self.tb = tb
|
|
49
57
|
self.client_registry = client_registry
|
|
50
58
|
self.collectors = collectors
|
|
51
59
|
self.env_vars = env_vars
|
|
60
|
+
self.abort_controller = abort_controller
|
|
61
|
+
self.on_tick = on_tick
|
|
52
62
|
|
|
53
63
|
|
|
54
64
|
class DoNotUseDirectlyCallManager:
|
|
@@ -85,11 +95,27 @@ class DoNotUseDirectlyCallManager:
|
|
|
85
95
|
else:
|
|
86
96
|
env_vars.pop(k, None)
|
|
87
97
|
|
|
98
|
+
abort_controller = self.__baml_options.get("abort_controller")
|
|
99
|
+
|
|
100
|
+
on_tick = self.__baml_options.get("on_tick")
|
|
101
|
+
if on_tick is not None:
|
|
102
|
+
collector = baml_py.baml_py.Collector("on-tick-collector")
|
|
103
|
+
collectors_as_list.append(collector)
|
|
104
|
+
|
|
105
|
+
def on_tick_wrapper():
|
|
106
|
+
log = collector.last
|
|
107
|
+
if log is not None:
|
|
108
|
+
on_tick("Unknown", log)
|
|
109
|
+
else:
|
|
110
|
+
on_tick_wrapper = None
|
|
111
|
+
|
|
88
112
|
return _ResolvedBamlOptions(
|
|
89
113
|
baml_tb,
|
|
90
114
|
client_registry,
|
|
91
115
|
collectors_as_list,
|
|
92
116
|
env_vars,
|
|
117
|
+
abort_controller,
|
|
118
|
+
on_tick_wrapper,
|
|
93
119
|
)
|
|
94
120
|
|
|
95
121
|
def merge_options(self, options: BamlCallOptions) -> "DoNotUseDirectlyCallManager":
|
|
@@ -99,6 +125,14 @@ class DoNotUseDirectlyCallManager:
|
|
|
99
125
|
self, *, function_name: str, args: typing.Dict[str, typing.Any]
|
|
100
126
|
) -> baml_py.baml_py.FunctionResult:
|
|
101
127
|
resolved_options = self.__resolve()
|
|
128
|
+
|
|
129
|
+
# Check if already aborted
|
|
130
|
+
if (
|
|
131
|
+
resolved_options.abort_controller is not None
|
|
132
|
+
and resolved_options.abort_controller.aborted
|
|
133
|
+
):
|
|
134
|
+
raise Exception("BamlAbortError: Operation was aborted")
|
|
135
|
+
|
|
102
136
|
return await __runtime__.call_function(
|
|
103
137
|
function_name,
|
|
104
138
|
args,
|
|
@@ -112,12 +146,22 @@ class DoNotUseDirectlyCallManager:
|
|
|
112
146
|
resolved_options.collectors,
|
|
113
147
|
# env_vars
|
|
114
148
|
resolved_options.env_vars,
|
|
149
|
+
# abort_controller
|
|
150
|
+
resolved_options.abort_controller,
|
|
115
151
|
)
|
|
116
152
|
|
|
117
153
|
def call_function_sync(
|
|
118
154
|
self, *, function_name: str, args: typing.Dict[str, typing.Any]
|
|
119
155
|
) -> baml_py.baml_py.FunctionResult:
|
|
120
156
|
resolved_options = self.__resolve()
|
|
157
|
+
|
|
158
|
+
# Check if already aborted
|
|
159
|
+
if (
|
|
160
|
+
resolved_options.abort_controller is not None
|
|
161
|
+
and resolved_options.abort_controller.aborted
|
|
162
|
+
):
|
|
163
|
+
raise Exception("BamlAbortError: Operation was aborted")
|
|
164
|
+
|
|
121
165
|
ctx = __ctx__manager__.get()
|
|
122
166
|
return __runtime__.call_function_sync(
|
|
123
167
|
function_name,
|
|
@@ -132,6 +176,8 @@ class DoNotUseDirectlyCallManager:
|
|
|
132
176
|
resolved_options.collectors,
|
|
133
177
|
# env_vars
|
|
134
178
|
resolved_options.env_vars,
|
|
179
|
+
# abort_controller
|
|
180
|
+
resolved_options.abort_controller,
|
|
135
181
|
)
|
|
136
182
|
|
|
137
183
|
def create_async_stream(
|
|
@@ -158,6 +204,8 @@ class DoNotUseDirectlyCallManager:
|
|
|
158
204
|
resolved_options.collectors,
|
|
159
205
|
# env_vars
|
|
160
206
|
resolved_options.env_vars,
|
|
207
|
+
# on_tick
|
|
208
|
+
resolved_options.on_tick,
|
|
161
209
|
)
|
|
162
210
|
return ctx, result
|
|
163
211
|
|
|
@@ -170,6 +218,10 @@ class DoNotUseDirectlyCallManager:
|
|
|
170
218
|
baml_py.baml_py.RuntimeContextManager, baml_py.baml_py.SyncFunctionResultStream
|
|
171
219
|
]:
|
|
172
220
|
resolved_options = self.__resolve()
|
|
221
|
+
if resolved_options.on_tick is not None:
|
|
222
|
+
raise ValueError(
|
|
223
|
+
"on_tick is not supported for sync streams. Please use async streams instead."
|
|
224
|
+
)
|
|
173
225
|
ctx = __ctx__manager__.get()
|
|
174
226
|
result = __runtime__.stream_function_sync(
|
|
175
227
|
function_name,
|
|
@@ -187,6 +239,9 @@ class DoNotUseDirectlyCallManager:
|
|
|
187
239
|
resolved_options.collectors,
|
|
188
240
|
# env_vars
|
|
189
241
|
resolved_options.env_vars,
|
|
242
|
+
# on_tick
|
|
243
|
+
# always None! sync streams don't support on_tick
|
|
244
|
+
None,
|
|
190
245
|
)
|
|
191
246
|
return ctx, result
|
|
192
247
|
|
|
@@ -264,3 +319,26 @@ class DoNotUseDirectlyCallManager:
|
|
|
264
319
|
# env_vars
|
|
265
320
|
resolved_options.env_vars,
|
|
266
321
|
)
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def disassemble(function: typing.Callable) -> None:
|
|
325
|
+
import inspect
|
|
326
|
+
from . import b
|
|
327
|
+
|
|
328
|
+
if not callable(function):
|
|
329
|
+
print(f"disassemble: object {function} is not a Baml function")
|
|
330
|
+
return
|
|
331
|
+
|
|
332
|
+
is_client_method = False
|
|
333
|
+
|
|
334
|
+
for method_name, _ in inspect.getmembers(b, predicate=inspect.ismethod):
|
|
335
|
+
if method_name == function.__name__:
|
|
336
|
+
is_client_method = True
|
|
337
|
+
break
|
|
338
|
+
|
|
339
|
+
if not is_client_method:
|
|
340
|
+
print(f"disassemble: function {function.__name__} is not a Baml function")
|
|
341
|
+
return
|
|
342
|
+
|
|
343
|
+
print(f"----- function {function.__name__} -----")
|
|
344
|
+
__runtime__.disassemble(function.__name__)
|
|
@@ -27,109 +27,12 @@ class StreamState(BaseModel, typing.Generic[StreamStateValueT]):
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
# #########################################################################
|
|
30
|
-
# Generated classes (
|
|
30
|
+
# Generated classes (1)
|
|
31
31
|
# #########################################################################
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
class
|
|
35
|
-
type: typing.Optional[str] = None
|
|
36
|
-
subclass: typing.List[str]
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class ContentLabel(BaseModel):
|
|
40
|
-
content_type: typing.Optional[typing.Union[str, str, str, str, str, str, str]] = None
|
|
41
|
-
type: typing.Optional[str] = None
|
|
42
|
-
subclass: typing.List[str]
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class DefaultContentPrediction(BaseModel):
|
|
46
|
-
label: typing.Optional["ContentLabel"] = None
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class DynamicKnowledgeGraph(BaseModel):
|
|
50
|
-
model_config = ConfigDict(extra="allow")
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
class Edge(BaseModel):
|
|
54
|
-
# doc string for edge
|
|
55
|
-
# doc string for source_node_id
|
|
56
|
-
|
|
57
|
-
source_node_id: typing.Optional[str] = None
|
|
58
|
-
target_node_id: typing.Optional[str] = None
|
|
59
|
-
relationship_name: typing.Optional[str] = None
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
class ImageContent(BaseModel):
|
|
63
|
-
type: typing.Optional[str] = None
|
|
64
|
-
subclass: typing.List[str]
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
class KnowledgeGraph(BaseModel):
|
|
68
|
-
nodes: typing.List["types.Node"]
|
|
69
|
-
edges: typing.List["Edge"]
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
class Model3DContent(BaseModel):
|
|
73
|
-
type: typing.Optional[str] = None
|
|
74
|
-
subclass: typing.List[str]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
class MultimediaContent(BaseModel):
|
|
78
|
-
type: typing.Optional[str] = None
|
|
79
|
-
subclass: typing.List[str]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class Node(BaseModel):
|
|
34
|
+
class ResponseModel(BaseModel):
|
|
83
35
|
model_config = ConfigDict(extra="allow")
|
|
84
|
-
id: typing.Optional[str] = None
|
|
85
|
-
name: typing.Optional[str] = None
|
|
86
|
-
type: typing.Optional[str] = None
|
|
87
|
-
description: typing.Optional[str] = None
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
class ProceduralContent(BaseModel):
|
|
91
|
-
type: typing.Optional[str] = None
|
|
92
|
-
subclass: typing.List[str]
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
class SummarizedClass(BaseModel):
|
|
96
|
-
name: typing.Optional[str] = None
|
|
97
|
-
description: typing.Optional[str] = None
|
|
98
|
-
methods: typing.Optional[typing.List["SummarizedFunction"]] = None
|
|
99
|
-
decorators: typing.Optional[typing.List[str]] = None
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
class SummarizedCode(BaseModel):
|
|
103
|
-
high_level_summary: typing.Optional[str] = None
|
|
104
|
-
key_features: typing.List[str]
|
|
105
|
-
imports: typing.List[str]
|
|
106
|
-
constants: typing.List[str]
|
|
107
|
-
classes: typing.List["SummarizedClass"]
|
|
108
|
-
functions: typing.List["SummarizedFunction"]
|
|
109
|
-
workflow_description: typing.Optional[str] = None
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
class SummarizedContent(BaseModel):
|
|
113
|
-
summary: typing.Optional[str] = None
|
|
114
|
-
description: typing.Optional[str] = None
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
class SummarizedFunction(BaseModel):
|
|
118
|
-
name: typing.Optional[str] = None
|
|
119
|
-
description: typing.Optional[str] = None
|
|
120
|
-
inputs: typing.Optional[typing.List[str]] = None
|
|
121
|
-
outputs: typing.Optional[typing.List[str]] = None
|
|
122
|
-
decorators: typing.Optional[typing.List[str]] = None
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
class TextContent(BaseModel):
|
|
126
|
-
type: typing.Optional[str] = None
|
|
127
|
-
subclass: typing.List[str]
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
class VideoContent(BaseModel):
|
|
131
|
-
type: typing.Optional[str] = None
|
|
132
|
-
subclass: typing.List[str]
|
|
133
36
|
|
|
134
37
|
|
|
135
38
|
# #########################################################################
|