thoughtflow 0.0.1__py3-none-any.whl → 0.0.3__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.
- thoughtflow/__init__.py +97 -5
- thoughtflow/_util.py +752 -0
- thoughtflow/action.py +357 -0
- thoughtflow/agent.py +66 -0
- thoughtflow/eval/__init__.py +34 -0
- thoughtflow/eval/harness.py +200 -0
- thoughtflow/eval/replay.py +137 -0
- thoughtflow/llm.py +250 -0
- thoughtflow/memory/__init__.py +32 -0
- thoughtflow/memory/base.py +1658 -0
- thoughtflow/message.py +140 -0
- thoughtflow/py.typed +2 -0
- thoughtflow/thought.py +1102 -0
- thoughtflow/thoughtflow6.py +4180 -0
- thoughtflow/tools/__init__.py +27 -0
- thoughtflow/tools/base.py +145 -0
- thoughtflow/tools/registry.py +122 -0
- thoughtflow/trace/__init__.py +34 -0
- thoughtflow/trace/events.py +183 -0
- thoughtflow/trace/schema.py +111 -0
- thoughtflow/trace/session.py +141 -0
- thoughtflow-0.0.3.dist-info/METADATA +215 -0
- thoughtflow-0.0.3.dist-info/RECORD +25 -0
- {thoughtflow-0.0.1.dist-info → thoughtflow-0.0.3.dist-info}/WHEEL +1 -2
- {thoughtflow-0.0.1.dist-info → thoughtflow-0.0.3.dist-info/licenses}/LICENSE +1 -1
- thoughtflow/jtools1.py +0 -25
- thoughtflow/jtools2.py +0 -27
- thoughtflow-0.0.1.dist-info/METADATA +0 -17
- thoughtflow-0.0.1.dist-info/RECORD +0 -8
- thoughtflow-0.0.1.dist-info/top_level.txt +0 -1
thoughtflow/__init__.py
CHANGED
|
@@ -1,7 +1,99 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ThoughtFlow: A minimal, explicit, Pythonic substrate for LLM and agent systems.
|
|
1
3
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
Core Philosophy:
|
|
5
|
+
- Tiny surface area: Few powerful primitives over many specialized classes
|
|
6
|
+
- Explicit state: All state is visible, serializable, and replayable
|
|
7
|
+
- Portability: Works across OpenAI, Anthropic, local models, serverless
|
|
8
|
+
- Deterministic testing: Record/replay workflows, stable sessions
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
Core Primitives:
|
|
11
|
+
- LLM: Multi-provider interface for language model calls
|
|
12
|
+
- MEMORY: Event-sourced state container (messages, logs, reflections, variables)
|
|
13
|
+
- THOUGHT: Unit of cognition (Prompt + Context + LLM + Parsing + Validation)
|
|
14
|
+
- ACTION: External operation wrapper with consistent logging
|
|
15
|
+
|
|
16
|
+
Basic Usage:
|
|
17
|
+
>>> from thoughtflow import LLM, MEMORY, THOUGHT
|
|
18
|
+
>>>
|
|
19
|
+
>>> llm = LLM("openai:gpt-4o", key="your-api-key")
|
|
20
|
+
>>> memory = MEMORY()
|
|
21
|
+
>>> memory.add_msg("user", "Hello!")
|
|
22
|
+
>>>
|
|
23
|
+
>>> thought = THOUGHT(
|
|
24
|
+
... name="respond",
|
|
25
|
+
... llm=llm,
|
|
26
|
+
... prompt="Respond to the user message: {last_user_msg}"
|
|
27
|
+
... )
|
|
28
|
+
>>> memory = thought(memory)
|
|
29
|
+
>>> result = memory.get_var("respond_result")
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
from __future__ import annotations
|
|
33
|
+
|
|
34
|
+
# Core primitives
|
|
35
|
+
from thoughtflow.llm import LLM
|
|
36
|
+
from thoughtflow.memory.base import MEMORY
|
|
37
|
+
from thoughtflow.thought import THOUGHT
|
|
38
|
+
from thoughtflow.action import ACTION
|
|
39
|
+
|
|
40
|
+
# Utilities
|
|
41
|
+
from thoughtflow._util import (
|
|
42
|
+
EventStamp,
|
|
43
|
+
event_stamp,
|
|
44
|
+
hashify,
|
|
45
|
+
construct_prompt,
|
|
46
|
+
construct_msgs,
|
|
47
|
+
valid_extract,
|
|
48
|
+
ValidExtractError,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Deprecated (for backward compatibility)
|
|
52
|
+
from thoughtflow.agent import Agent, TracedAgent
|
|
53
|
+
|
|
54
|
+
# Keep message types for potential utility
|
|
55
|
+
from thoughtflow.message import Message, MessageList
|
|
56
|
+
|
|
57
|
+
# Submodule access (keep tools, trace, eval for advanced usage)
|
|
58
|
+
from thoughtflow import tools
|
|
59
|
+
from thoughtflow import memory
|
|
60
|
+
from thoughtflow import trace
|
|
61
|
+
from thoughtflow import eval
|
|
62
|
+
|
|
63
|
+
# Version
|
|
64
|
+
try:
|
|
65
|
+
from importlib.metadata import version as _get_version
|
|
66
|
+
|
|
67
|
+
__version__ = _get_version("thoughtflow")
|
|
68
|
+
except Exception:
|
|
69
|
+
__version__ = "0.0.0"
|
|
70
|
+
|
|
71
|
+
# Public API
|
|
72
|
+
__all__ = [
|
|
73
|
+
# Core Primitives
|
|
74
|
+
"LLM",
|
|
75
|
+
"MEMORY",
|
|
76
|
+
"THOUGHT",
|
|
77
|
+
"ACTION",
|
|
78
|
+
# Utilities
|
|
79
|
+
"EventStamp",
|
|
80
|
+
"event_stamp",
|
|
81
|
+
"hashify",
|
|
82
|
+
"construct_prompt",
|
|
83
|
+
"construct_msgs",
|
|
84
|
+
"valid_extract",
|
|
85
|
+
"ValidExtractError",
|
|
86
|
+
# Types
|
|
87
|
+
"Message",
|
|
88
|
+
"MessageList",
|
|
89
|
+
# Deprecated
|
|
90
|
+
"Agent",
|
|
91
|
+
"TracedAgent",
|
|
92
|
+
# Submodules
|
|
93
|
+
"tools",
|
|
94
|
+
"memory",
|
|
95
|
+
"trace",
|
|
96
|
+
"eval",
|
|
97
|
+
# Metadata
|
|
98
|
+
"__version__",
|
|
99
|
+
]
|