ommlds 0.0.0.dev463__py3-none-any.whl → 0.0.0.dev464__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.
Potentially problematic release.
This version of ommlds might be problematic. Click here for more details.
- ommlds/cli/inject.py +0 -5
- ommlds/cli/main.py +26 -54
- ommlds/cli/sessions/{chat2 → chat}/backends/catalog.py +5 -5
- ommlds/cli/sessions/chat/backends/inject.py +37 -0
- ommlds/cli/sessions/chat/backends/injection.py +16 -0
- ommlds/cli/sessions/{chat2 → chat}/backends/types.py +3 -3
- ommlds/cli/sessions/chat/chat/ai/inject.py +81 -0
- ommlds/cli/sessions/chat/chat/ai/injection.py +14 -0
- ommlds/cli/sessions/{chat2 → chat}/chat/ai/rendering.py +13 -10
- ommlds/cli/sessions/chat/chat/ai/services.py +81 -0
- ommlds/cli/sessions/chat/chat/ai/tools.py +44 -0
- ommlds/cli/sessions/{chat2 → chat}/chat/ai/types.py +5 -5
- ommlds/cli/sessions/chat/chat/state/inject.py +40 -0
- ommlds/cli/sessions/{chat2 → chat}/chat/state/inmemory.py +1 -1
- ommlds/cli/sessions/{chat2 → chat}/chat/state/storage.py +1 -1
- ommlds/cli/sessions/{chat2 → chat}/chat/state/types.py +1 -1
- ommlds/cli/sessions/chat/chat/user/inject.py +61 -0
- ommlds/cli/sessions/{chat2 → chat}/chat/user/interactive.py +1 -1
- ommlds/cli/sessions/{chat2 → chat}/chat/user/oneshot.py +1 -1
- ommlds/cli/sessions/{chat2 → chat}/chat/user/types.py +1 -1
- ommlds/cli/sessions/{chat2 → chat}/configs.py +4 -1
- ommlds/cli/sessions/{chat2 → chat}/content/messages.py +6 -2
- ommlds/cli/sessions/{chat2 → chat}/content/strings.py +2 -2
- ommlds/cli/sessions/{chat2 → chat}/driver.py +2 -2
- ommlds/cli/sessions/chat/inject.py +40 -66
- ommlds/cli/sessions/chat/phases/inject.py +27 -0
- ommlds/cli/sessions/chat/phases/injection.py +14 -0
- ommlds/cli/sessions/{chat2/phases.py → chat/phases/manager.py} +2 -28
- ommlds/cli/sessions/chat/phases/types.py +29 -0
- ommlds/cli/sessions/chat/rendering/inject.py +32 -0
- ommlds/cli/sessions/{chat2 → chat}/rendering/markdown.py +2 -2
- ommlds/cli/sessions/{chat2 → chat}/rendering/raw.py +6 -6
- ommlds/cli/sessions/{chat2 → chat}/rendering/types.py +1 -1
- ommlds/cli/sessions/{chat2 → chat}/session.py +1 -1
- ommlds/cli/sessions/{chat2 → chat}/tools/confirmation.py +4 -4
- ommlds/cli/sessions/{chat2 → chat}/tools/execution.py +18 -5
- ommlds/cli/sessions/chat/tools/inject.py +145 -0
- ommlds/cli/sessions/chat/tools/injection.py +29 -0
- ommlds/cli/sessions/chat/tools/rendering.py +58 -0
- ommlds/cli/{tools → sessions/chat/tools}/weather.py +1 -1
- ommlds/cli/sessions/inject.py +2 -7
- {ommlds-0.0.0.dev463.dist-info → ommlds-0.0.0.dev464.dist-info}/METADATA +3 -3
- {ommlds-0.0.0.dev463.dist-info → ommlds-0.0.0.dev464.dist-info}/RECORD +56 -54
- ommlds/cli/sessions/chat/base.py +0 -42
- ommlds/cli/sessions/chat/code.py +0 -125
- ommlds/cli/sessions/chat/interactive.py +0 -70
- ommlds/cli/sessions/chat/printing.py +0 -126
- ommlds/cli/sessions/chat/prompt.py +0 -161
- ommlds/cli/sessions/chat/state.py +0 -110
- ommlds/cli/sessions/chat/tools.py +0 -97
- ommlds/cli/sessions/chat2/_inject.py +0 -105
- ommlds/cli/sessions/chat2/chat/ai/services.py +0 -70
- ommlds/cli/sessions/chat2/inject.py +0 -143
- ommlds/cli/tools/__init__.py +0 -0
- ommlds/cli/tools/config.py +0 -14
- ommlds/cli/tools/inject.py +0 -75
- /ommlds/cli/sessions/{chat2 → chat/backends}/__init__.py +0 -0
- /ommlds/cli/sessions/{chat2/backends → chat/chat}/__init__.py +0 -0
- /ommlds/cli/sessions/{chat2/chat → chat/chat/ai}/__init__.py +0 -0
- /ommlds/cli/sessions/{chat2/chat/ai → chat/chat/state}/__init__.py +0 -0
- /ommlds/cli/sessions/{chat2/chat/state → chat/chat/user}/__init__.py +0 -0
- /ommlds/cli/sessions/{chat2/chat/user → chat/content}/__init__.py +0 -0
- /ommlds/cli/sessions/{chat2/content → chat/phases}/__init__.py +0 -0
- /ommlds/cli/sessions/{chat2 → chat}/rendering/__init__.py +0 -0
- /ommlds/cli/sessions/{chat2 → chat}/tools/__init__.py +0 -0
- {ommlds-0.0.0.dev463.dist-info → ommlds-0.0.0.dev464.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev463.dist-info → ommlds-0.0.0.dev464.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev463.dist-info → ommlds-0.0.0.dev464.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev463.dist-info → ommlds-0.0.0.dev464.dist-info}/top_level.txt +0 -0
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import typing as ta
|
|
2
|
-
|
|
3
|
-
from omlish import inject as inj
|
|
4
|
-
from omlish import lang
|
|
5
|
-
|
|
6
|
-
from .... import minichain as mc
|
|
7
|
-
from . import _inject as _inj
|
|
8
|
-
from .configs import DEFAULT_CHAT_MODEL_BACKEND
|
|
9
|
-
from .configs import ChatConfig
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ItemT = ta.TypeVar('ItemT')
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
CHAT_OPTIONS = inj.items_binder_helper[mc.ChatChoicesOption](_inj.ChatChoicesServiceOptions)
|
|
19
|
-
BACKEND_CONFIGS = inj.items_binder_helper[mc.Config](_inj.BackendConfigs)
|
|
20
|
-
PHASE_CALLBACKS = inj.items_binder_helper[_inj.ChatPhaseCallback](_inj.ChatPhaseCallbacks)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def bind_chat(cfg: ChatConfig) -> inj.Elements:
|
|
27
|
-
els: list[inj.Elemental] = []
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
els.extend([
|
|
32
|
-
CHAT_OPTIONS.bind_items_provider(singleton=True),
|
|
33
|
-
BACKEND_CONFIGS.bind_items_provider(singleton=True),
|
|
34
|
-
PHASE_CALLBACKS.bind_items_provider(singleton=True),
|
|
35
|
-
])
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
if cfg.state in ('continue', 'new'):
|
|
40
|
-
els.extend([
|
|
41
|
-
inj.bind(_inj.StateStorageChatStateManager, singleton=True),
|
|
42
|
-
inj.bind(_inj.ChatStateManager, to_key=_inj.StateStorageChatStateManager),
|
|
43
|
-
])
|
|
44
|
-
|
|
45
|
-
if cfg.state == 'new':
|
|
46
|
-
els.append(PHASE_CALLBACKS.bind_item(to_fn=lang.typed_lambda(cm=_inj.ChatStateManager)(
|
|
47
|
-
lambda cm: _inj.ChatPhaseCallback(_inj.ChatPhase.STARTING, cm.clear_state),
|
|
48
|
-
)))
|
|
49
|
-
|
|
50
|
-
elif cfg.state == 'ephemeral':
|
|
51
|
-
els.extend([
|
|
52
|
-
inj.bind(_inj.InMemoryChatStateManager, singleton=True),
|
|
53
|
-
inj.bind(_inj.ChatStateManager, to_key=_inj.InMemoryChatStateManager),
|
|
54
|
-
])
|
|
55
|
-
|
|
56
|
-
else:
|
|
57
|
-
raise TypeError(cfg.state)
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
|
|
61
|
-
if cfg.interactive:
|
|
62
|
-
if cfg.initial_content is not None:
|
|
63
|
-
async def add_initial_content(cm: '_inj.ChatStateManager') -> None:
|
|
64
|
-
await cm.extend_chat([mc.UserMessage(cfg.initial_content)])
|
|
65
|
-
|
|
66
|
-
els.append(PHASE_CALLBACKS.bind_item(to_fn=lang.typed_lambda(cm=_inj.ChatStateManager)(
|
|
67
|
-
lambda cm: _inj.ChatPhaseCallback(_inj.ChatPhase.STARTED, lambda: add_initial_content(cm)),
|
|
68
|
-
)))
|
|
69
|
-
|
|
70
|
-
raise NotImplementedError
|
|
71
|
-
|
|
72
|
-
els.extend([
|
|
73
|
-
inj.bind(_inj.InteractiveUserChatInput, singleton=True),
|
|
74
|
-
inj.bind(_inj.UserChatInput, to_key=_inj.InteractiveUserChatInput),
|
|
75
|
-
])
|
|
76
|
-
|
|
77
|
-
else:
|
|
78
|
-
if cfg.initial_content is None:
|
|
79
|
-
raise ValueError('Initial content is required for non-interactive chat')
|
|
80
|
-
|
|
81
|
-
els.extend([
|
|
82
|
-
inj.bind(_inj.OneshotUserChatInputInitialChat, to_const=[mc.UserMessage(cfg.initial_content)]),
|
|
83
|
-
inj.bind(_inj.OneshotUserChatInput, singleton=True),
|
|
84
|
-
inj.bind(_inj.UserChatInput, to_key=_inj.OneshotUserChatInput),
|
|
85
|
-
])
|
|
86
|
-
|
|
87
|
-
#
|
|
88
|
-
|
|
89
|
-
if cfg.stream:
|
|
90
|
-
raise NotImplementedError
|
|
91
|
-
|
|
92
|
-
else:
|
|
93
|
-
ai_stack = inj.wrapper_binder_helper(_inj.AiChatGenerator)
|
|
94
|
-
|
|
95
|
-
els.append(ai_stack.push_bind(to_ctor=_inj.ChatChoicesServiceAiChatGenerator, singleton=True))
|
|
96
|
-
|
|
97
|
-
if not cfg.silent:
|
|
98
|
-
if cfg.markdown:
|
|
99
|
-
els.extend([
|
|
100
|
-
inj.bind(_inj.MarkdownContentRendering, singleton=True),
|
|
101
|
-
inj.bind(_inj.ContentRendering, to_key=_inj.MarkdownContentRendering),
|
|
102
|
-
])
|
|
103
|
-
else:
|
|
104
|
-
els.extend([
|
|
105
|
-
inj.bind(_inj.RawContentRendering, singleton=True),
|
|
106
|
-
inj.bind(_inj.ContentRendering, to_key=_inj.RawContentRendering),
|
|
107
|
-
])
|
|
108
|
-
|
|
109
|
-
els.append(ai_stack.push_bind(to_ctor=_inj.RenderingAiChatGenerator, singleton=True))
|
|
110
|
-
|
|
111
|
-
els.append(inj.bind(_inj.AiChatGenerator, to_key=ai_stack.top))
|
|
112
|
-
|
|
113
|
-
#
|
|
114
|
-
|
|
115
|
-
els.append(inj.bind(_inj.BackendName, to_const=cfg.backend or DEFAULT_CHAT_MODEL_BACKEND))
|
|
116
|
-
|
|
117
|
-
els.extend([
|
|
118
|
-
inj.bind(_inj.CatalogChatChoicesServiceBackendProvider),
|
|
119
|
-
inj.bind(_inj.ChatChoicesServiceBackendProvider, to_key=_inj.CatalogChatChoicesServiceBackendProvider),
|
|
120
|
-
])
|
|
121
|
-
|
|
122
|
-
#
|
|
123
|
-
|
|
124
|
-
els.extend([
|
|
125
|
-
inj.bind(_inj.ToolUseExecutorImpl, singleton=True),
|
|
126
|
-
inj.bind(_inj.ToolUseExecutor, to_key=_inj.ToolUseExecutorImpl),
|
|
127
|
-
])
|
|
128
|
-
|
|
129
|
-
#
|
|
130
|
-
|
|
131
|
-
els.extend([
|
|
132
|
-
inj.bind(_inj.ChatPhaseManager, singleton=True),
|
|
133
|
-
])
|
|
134
|
-
|
|
135
|
-
#
|
|
136
|
-
|
|
137
|
-
els.extend([
|
|
138
|
-
inj.bind(_inj.ChatDriver, singleton=True),
|
|
139
|
-
])
|
|
140
|
-
|
|
141
|
-
#
|
|
142
|
-
|
|
143
|
-
return inj.as_elements(*els)
|
ommlds/cli/tools/__init__.py
DELETED
|
File without changes
|
ommlds/cli/tools/config.py
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
from omlish import dataclasses as dc
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@dc.dataclass(frozen=True, kw_only=True)
|
|
8
|
-
class ToolsConfig:
|
|
9
|
-
enable_fs_tools: bool = False
|
|
10
|
-
enable_todo_tools: bool = False
|
|
11
|
-
|
|
12
|
-
enable_unsafe_tools_do_not_use_lol: bool = False
|
|
13
|
-
|
|
14
|
-
enable_test_weather_tool: bool = False
|
ommlds/cli/tools/inject.py
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import dataclasses as dc
|
|
2
|
-
import typing as ta
|
|
3
|
-
|
|
4
|
-
from omlish import inject as inj
|
|
5
|
-
from omlish import lang
|
|
6
|
-
|
|
7
|
-
from ... import minichain as mc
|
|
8
|
-
from ..sessions.chat.inject import bind_chat_options
|
|
9
|
-
from .config import ToolsConfig
|
|
10
|
-
from .weather import WEATHER_TOOL
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@dc.dataclass(frozen=True, eq=False)
|
|
17
|
-
class _InjectedTool:
|
|
18
|
-
tce: mc.ToolCatalogEntry
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def bind_tool(tce: mc.ToolCatalogEntry) -> inj.Element | inj.Elements:
|
|
22
|
-
return inj.as_elements(
|
|
23
|
-
inj.bind_set_entry_const(ta.AbstractSet[_InjectedTool], _InjectedTool(tce)),
|
|
24
|
-
|
|
25
|
-
bind_chat_options(mc.Tool(tce.spec)),
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def bind_tools(tools_config: ToolsConfig) -> inj.Elements:
|
|
33
|
-
els: list[inj.Elemental] = [
|
|
34
|
-
inj.bind(tools_config),
|
|
35
|
-
|
|
36
|
-
inj.bind(mc.ToolCatalog, singleton=True),
|
|
37
|
-
|
|
38
|
-
inj.set_binder[_InjectedTool](),
|
|
39
|
-
inj.bind(
|
|
40
|
-
lang.typed_lambda(mc.ToolCatalogEntries, s=ta.AbstractSet[_InjectedTool])(
|
|
41
|
-
lambda s: [it.tce for it in s],
|
|
42
|
-
),
|
|
43
|
-
singleton=True,
|
|
44
|
-
),
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
#
|
|
48
|
-
|
|
49
|
-
if tools_config.enable_fs_tools:
|
|
50
|
-
from ...minichain.lib.fs.tools.ls import ls_tool
|
|
51
|
-
els.append(bind_tool(ls_tool()))
|
|
52
|
-
|
|
53
|
-
from ...minichain.lib.fs.tools.read import read_tool
|
|
54
|
-
els.append(bind_tool(read_tool()))
|
|
55
|
-
|
|
56
|
-
if tools_config.enable_todo_tools:
|
|
57
|
-
from ...minichain.lib.todo.tools.read import todo_read_tool
|
|
58
|
-
els.append(bind_tool(todo_read_tool()))
|
|
59
|
-
|
|
60
|
-
from ...minichain.lib.todo.tools.write import todo_write_tool
|
|
61
|
-
els.append(bind_tool(todo_write_tool()))
|
|
62
|
-
|
|
63
|
-
if tools_config.enable_unsafe_tools_do_not_use_lol:
|
|
64
|
-
from ...minichain.lib.bash import bash_tool
|
|
65
|
-
els.append(bind_tool(bash_tool()))
|
|
66
|
-
|
|
67
|
-
from ...minichain.lib.fs.tools.edit import edit_tool
|
|
68
|
-
els.append(bind_tool(edit_tool()))
|
|
69
|
-
|
|
70
|
-
if tools_config.enable_test_weather_tool:
|
|
71
|
-
els.append(bind_tool(WEATHER_TOOL))
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
return inj.as_elements(*els)
|
|
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
|