dasein-core 0.2.20__tar.gz → 0.2.21__tar.gz
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.
- {dasein_core-0.2.20/src/dasein_core.egg-info → dasein_core-0.2.21}/PKG-INFO +1 -1
- {dasein_core-0.2.20 → dasein_core-0.2.21}/pyproject.toml +1 -1
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/api.py +179 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21/src/dasein_core.egg-info}/PKG-INFO +1 -1
- {dasein_core-0.2.20 → dasein_core-0.2.21}/LICENSE +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/MANIFEST.in +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/README.md +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/examples/dasein_examples.ipynb +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/setup.cfg +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/setup.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/__init__.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/advice_format.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/capture.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/config.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/events.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/extractors.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/injection_strategies.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/injector.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/microturn.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/__init__.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/LICENSE +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/LICENSES_SOURCES +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/README.md +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/accuracy.json +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/attribute_ruler/patterns +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/config.cfg +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/lemmatizer/lookups/lookups.bin +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/meta.json +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/ner/cfg +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/ner/model +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/ner/moves +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/parser/cfg +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/parser/model +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/parser/moves +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/senter/cfg +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/senter/model +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tagger/cfg +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tagger/model +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tok2vec/cfg +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tok2vec/model +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/tokenizer +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/key2row +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/lookups.bin +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/strings.json +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/vectors +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/en_core_web_sm-3.7.1/vocab/vectors.cfg +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/meta.json +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/LICENSE +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/LICENSES_SOURCES +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/METADATA +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/RECORD +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/WHEEL +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/entry_points.txt +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/top_level.txt +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/pipecleaner.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/__init__.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/post_run_client.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/pre_run_client.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/service_adapter.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/services/service_config.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/trace_buffer.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/types.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/wrappers.py +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein_core.egg-info/SOURCES.txt +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein_core.egg-info/dependency_links.txt +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein_core.egg-info/requires.txt +0 -0
- {dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein_core.egg-info/top_level.txt +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "dasein-core"
|
7
|
-
version = "0.2.
|
7
|
+
version = "0.2.21"
|
8
8
|
description = "Universal memory for agentic AI. Attach a brain to any LangChain/LangGraph agent in a single line."
|
9
9
|
readme = "README.md"
|
10
10
|
requires-python = ">=3.8"
|
@@ -2804,6 +2804,157 @@ Follow these rules when planning your actions."""
|
|
2804
2804
|
|
2805
2805
|
return result
|
2806
2806
|
|
2807
|
+
def _create_synthetic_tool_messages(self, selected_rules):
|
2808
|
+
"""
|
2809
|
+
Convert selected rules into synthetic ToolMessage objects.
|
2810
|
+
|
2811
|
+
Each rule becomes a tool call/response pair from Dasein, making rules
|
2812
|
+
appear as data already retrieved from the environment rather than instructions.
|
2813
|
+
|
2814
|
+
Args:
|
2815
|
+
selected_rules: List of rule objects or (rule, metadata) tuples
|
2816
|
+
|
2817
|
+
Returns:
|
2818
|
+
List of ToolMessage objects
|
2819
|
+
"""
|
2820
|
+
try:
|
2821
|
+
from langchain_core.messages import ToolMessage
|
2822
|
+
import uuid
|
2823
|
+
|
2824
|
+
tool_messages = []
|
2825
|
+
|
2826
|
+
for i, rule_meta in enumerate(selected_rules):
|
2827
|
+
# Unwrap tuple format if present
|
2828
|
+
if isinstance(rule_meta, tuple) and len(rule_meta) == 2:
|
2829
|
+
rule, metadata = rule_meta
|
2830
|
+
else:
|
2831
|
+
rule = rule_meta
|
2832
|
+
metadata = {}
|
2833
|
+
|
2834
|
+
# Extract rule ID and advice text
|
2835
|
+
if isinstance(rule, dict):
|
2836
|
+
rule_id = rule.get('id', rule.get('rule_id', f'rule_{i}'))
|
2837
|
+
advice_text = rule.get('advice_text', rule.get('advice', ''))
|
2838
|
+
else:
|
2839
|
+
rule_id = getattr(rule, 'id', getattr(rule, 'rule_id', f'rule_{i}'))
|
2840
|
+
advice_text = getattr(rule, 'advice_text', getattr(rule, 'advice', ''))
|
2841
|
+
|
2842
|
+
# Skip if no advice text
|
2843
|
+
if not advice_text:
|
2844
|
+
continue
|
2845
|
+
|
2846
|
+
# Create ToolMessage with rule content
|
2847
|
+
# Note: tool_call_id is required for ToolMessage
|
2848
|
+
tool_msg = ToolMessage(
|
2849
|
+
content=advice_text, # Rule advice as tool output
|
2850
|
+
tool_call_id=f"dasein_{rule_id}",
|
2851
|
+
name="Dasein"
|
2852
|
+
)
|
2853
|
+
|
2854
|
+
tool_messages.append(tool_msg)
|
2855
|
+
|
2856
|
+
if tool_messages:
|
2857
|
+
self._vprint(f"[DASEIN][TOOL_MSG] Created {len(tool_messages)} synthetic tool messages from rules")
|
2858
|
+
|
2859
|
+
return tool_messages
|
2860
|
+
|
2861
|
+
except Exception as e:
|
2862
|
+
print(f"[DASEIN][TOOL_MSG] ERROR creating synthetic tool messages: {e}")
|
2863
|
+
import traceback
|
2864
|
+
traceback.print_exc()
|
2865
|
+
return []
|
2866
|
+
|
2867
|
+
def _inject_tool_messages_into_input(self, args, tool_messages):
|
2868
|
+
"""
|
2869
|
+
Inject synthetic tool messages into agent input at step -1.
|
2870
|
+
|
2871
|
+
Handles both LangChain (dict with 'input' field) and LangGraph
|
2872
|
+
(dict with 'messages' field) input formats.
|
2873
|
+
|
2874
|
+
Args:
|
2875
|
+
args: Original args tuple passed to agent.invoke()
|
2876
|
+
tool_messages: List of ToolMessage objects to inject
|
2877
|
+
|
2878
|
+
Returns:
|
2879
|
+
Modified args tuple with tool messages injected
|
2880
|
+
"""
|
2881
|
+
if not tool_messages or not args:
|
2882
|
+
return args
|
2883
|
+
|
2884
|
+
try:
|
2885
|
+
original_input = args[0]
|
2886
|
+
|
2887
|
+
# LangGraph format: {"messages": [...]}
|
2888
|
+
if isinstance(original_input, dict) and "messages" in original_input:
|
2889
|
+
self._vprint(f"[DASEIN][TOOL_MSG] Detected LangGraph input format")
|
2890
|
+
modified_input = original_input.copy()
|
2891
|
+
existing_messages = modified_input.get("messages", [])
|
2892
|
+
|
2893
|
+
# Prepend tool messages BEFORE user message
|
2894
|
+
modified_input["messages"] = tool_messages + list(existing_messages)
|
2895
|
+
|
2896
|
+
self._vprint(f"[DASEIN][TOOL_MSG] Injected {len(tool_messages)} tool messages before {len(existing_messages)} existing messages")
|
2897
|
+
|
2898
|
+
# Return modified args
|
2899
|
+
modified_args = list(args)
|
2900
|
+
modified_args[0] = modified_input
|
2901
|
+
return tuple(modified_args)
|
2902
|
+
|
2903
|
+
# LangChain format: {"input": "query"} or just "query"
|
2904
|
+
else:
|
2905
|
+
self._vprint(f"[DASEIN][TOOL_MSG] Detected LangChain input format")
|
2906
|
+
|
2907
|
+
# For LangChain, we need to convert to message format
|
2908
|
+
# LangChain expects {"input": str}, so we wrap in messages format
|
2909
|
+
from langchain_core.messages import HumanMessage
|
2910
|
+
|
2911
|
+
if isinstance(original_input, dict) and "input" in original_input:
|
2912
|
+
# Dict with input field
|
2913
|
+
user_message = HumanMessage(content=original_input["input"])
|
2914
|
+
elif isinstance(original_input, str):
|
2915
|
+
# String input
|
2916
|
+
user_message = HumanMessage(content=original_input)
|
2917
|
+
else:
|
2918
|
+
# Unknown format, skip injection
|
2919
|
+
self._vprint(f"[DASEIN][TOOL_MSG] Unknown input format, skipping injection")
|
2920
|
+
return args
|
2921
|
+
|
2922
|
+
# Create new input with messages
|
2923
|
+
# CRITICAL: For LangChain SQL agents, we need to preserve the {"input": ...} format
|
2924
|
+
# but some agents can handle {"messages": [...]} format
|
2925
|
+
# Let's try both approaches based on agent type
|
2926
|
+
|
2927
|
+
if self._is_langgraph:
|
2928
|
+
# LangGraph always uses messages format
|
2929
|
+
modified_input = {
|
2930
|
+
"messages": tool_messages + [user_message]
|
2931
|
+
}
|
2932
|
+
else:
|
2933
|
+
# LangChain: Keep original format but add messages field
|
2934
|
+
# Some agents support both input and messages
|
2935
|
+
if isinstance(original_input, dict):
|
2936
|
+
modified_input = original_input.copy()
|
2937
|
+
modified_input["messages"] = tool_messages + [user_message]
|
2938
|
+
else:
|
2939
|
+
# String input: convert to messages format
|
2940
|
+
modified_input = {
|
2941
|
+
"input": original_input,
|
2942
|
+
"messages": tool_messages + [user_message]
|
2943
|
+
}
|
2944
|
+
|
2945
|
+
self._vprint(f"[DASEIN][TOOL_MSG] Injected {len(tool_messages)} tool messages into LangChain input")
|
2946
|
+
|
2947
|
+
# Return modified args
|
2948
|
+
modified_args = list(args)
|
2949
|
+
modified_args[0] = modified_input
|
2950
|
+
return tuple(modified_args)
|
2951
|
+
|
2952
|
+
except Exception as e:
|
2953
|
+
print(f"[DASEIN][TOOL_MSG] ERROR injecting tool messages: {e}")
|
2954
|
+
import traceback
|
2955
|
+
traceback.print_exc()
|
2956
|
+
return args
|
2957
|
+
|
2807
2958
|
def invoke(self, *args, **kwargs):
|
2808
2959
|
"""
|
2809
2960
|
Invoke the agent with complete Dasein pipeline.
|
@@ -2877,6 +3028,13 @@ Follow these rules when planning your actions."""
|
|
2877
3028
|
kwargs['callbacks'] = callbacks
|
2878
3029
|
self._vprint(f"[DASEIN][CALLBACK] Attached callback handler to agent with {len(callbacks)} callbacks")
|
2879
3030
|
|
3031
|
+
# STEP -1: Inject synthetic tool messages BEFORE agent execution
|
3032
|
+
# Convert rules to tool messages so they appear as data already retrieved
|
3033
|
+
tool_messages = self._create_synthetic_tool_messages(selected_rules)
|
3034
|
+
if tool_messages:
|
3035
|
+
args = self._inject_tool_messages_into_input(args, tool_messages)
|
3036
|
+
print(f"[DASEIN] 💬 Injected {len(tool_messages)} rule(s) as synthetic tool messages (step -1)")
|
3037
|
+
|
2880
3038
|
# Run the agent
|
2881
3039
|
result = self._agent.invoke(*args, **kwargs)
|
2882
3040
|
|
@@ -2959,6 +3117,13 @@ Follow these rules when planning your actions."""
|
|
2959
3117
|
kwargs['callbacks'] = callbacks
|
2960
3118
|
self._vprint(f"[DASEIN][CALLBACK] Attached callback handler to agent with {len(callbacks)} callbacks")
|
2961
3119
|
|
3120
|
+
# STEP -1: Inject synthetic tool messages BEFORE agent execution
|
3121
|
+
# Convert rules to tool messages so they appear as data already retrieved
|
3122
|
+
tool_messages = self._create_synthetic_tool_messages(selected_rules)
|
3123
|
+
if tool_messages:
|
3124
|
+
args = self._inject_tool_messages_into_input(args, tool_messages)
|
3125
|
+
print(f"[DASEIN] 💬 Injected {len(tool_messages)} rule(s) as synthetic tool messages (step -1)")
|
3126
|
+
|
2962
3127
|
# Run the agent asynchronously
|
2963
3128
|
result = await self._agent.ainvoke(*args, **kwargs)
|
2964
3129
|
|
@@ -3173,6 +3338,13 @@ Follow these rules when planning your actions."""
|
|
3173
3338
|
kwargs['callbacks'] = callbacks
|
3174
3339
|
self._vprint(f"[DASEIN][CALLBACK] Attached callback handler to agent with {len(callbacks)} callbacks")
|
3175
3340
|
|
3341
|
+
# STEP -1: Inject synthetic tool messages BEFORE agent execution
|
3342
|
+
# Convert rules to tool messages so they appear as data already retrieved
|
3343
|
+
tool_messages = self._create_synthetic_tool_messages(selected_rules)
|
3344
|
+
if tool_messages:
|
3345
|
+
args = self._inject_tool_messages_into_input(args, tool_messages)
|
3346
|
+
print(f"[DASEIN] 💬 Injected {len(tool_messages)} rule(s) as synthetic tool messages (step -1)")
|
3347
|
+
|
3176
3348
|
# Run the agent
|
3177
3349
|
result = self._agent.invoke(*args, **kwargs)
|
3178
3350
|
|
@@ -3246,6 +3418,13 @@ Follow these rules when planning your actions."""
|
|
3246
3418
|
kwargs['callbacks'] = callbacks
|
3247
3419
|
self._vprint(f"[DASEIN][CALLBACK] Attached callback handler to agent with {len(callbacks)} callbacks")
|
3248
3420
|
|
3421
|
+
# STEP -1: Inject synthetic tool messages BEFORE agent execution
|
3422
|
+
# Convert rules to tool messages so they appear as data already retrieved
|
3423
|
+
tool_messages = self._create_synthetic_tool_messages(selected_rules)
|
3424
|
+
if tool_messages:
|
3425
|
+
args = self._inject_tool_messages_into_input(args, tool_messages)
|
3426
|
+
print(f"[DASEIN] 💬 Injected {len(tool_messages)} rule(s) as synthetic tool messages (step -1)")
|
3427
|
+
|
3249
3428
|
# Run the agent asynchronously
|
3250
3429
|
result = await self._agent.ainvoke(*args, **kwargs)
|
3251
3430
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{dasein_core-0.2.20 → dasein_core-0.2.21}/src/dasein/models/en_core_web_sm/en_core_web_sm/meta.json
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|