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
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import typing as ta
|
|
3
|
+
|
|
4
|
+
from omlish import check
|
|
5
|
+
from omlish import inject as inj
|
|
6
|
+
from omlish import lang
|
|
7
|
+
|
|
8
|
+
from ..... import minichain as mc
|
|
9
|
+
from .injection import bind_tool_context_provider_to_key
|
|
10
|
+
from .injection import tool_catalog_entries
|
|
11
|
+
from .injection import tool_context_providers
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
with lang.auto_proxy_import(globals()):
|
|
15
|
+
from . import confirmation as _confirmation
|
|
16
|
+
from . import execution as _execution
|
|
17
|
+
from . import rendering as _rendering
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_TOOL_BINDERS: dict[str, ta.Callable[[], inj.Elements]] = {}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _tool_binder(name: str) -> ta.Callable[[ta.Callable[[], inj.Elements]], ta.Callable[[], inj.Elements]]:
|
|
27
|
+
def inner(fn):
|
|
28
|
+
check.not_in(name, _TOOL_BINDERS)
|
|
29
|
+
_TOOL_BINDERS[name] = fn
|
|
30
|
+
return fn
|
|
31
|
+
return inner
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@_tool_binder('weather')
|
|
38
|
+
def _bind_weather_tool() -> inj.Elements:
|
|
39
|
+
from .weather import WEATHER_TOOL
|
|
40
|
+
|
|
41
|
+
return inj.as_elements(
|
|
42
|
+
tool_catalog_entries().bind_item_consts(WEATHER_TOOL),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@_tool_binder('todo')
|
|
47
|
+
def _bind_todo_tools() -> inj.Elements:
|
|
48
|
+
from .....minichain.lib.todo.context import TodoContext
|
|
49
|
+
from .....minichain.lib.todo.tools.read import todo_read_tool
|
|
50
|
+
from .....minichain.lib.todo.tools.write import todo_write_tool
|
|
51
|
+
|
|
52
|
+
return inj.as_elements(
|
|
53
|
+
tool_catalog_entries().bind_item_consts(
|
|
54
|
+
todo_read_tool(),
|
|
55
|
+
todo_write_tool(),
|
|
56
|
+
),
|
|
57
|
+
|
|
58
|
+
inj.bind(TodoContext()),
|
|
59
|
+
bind_tool_context_provider_to_key(TodoContext),
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@_tool_binder('fs')
|
|
64
|
+
def _bind_fs_tools() -> inj.Elements:
|
|
65
|
+
from .....minichain.lib.fs.context import FsContext
|
|
66
|
+
from .....minichain.lib.fs.tools.ls import ls_tool
|
|
67
|
+
from .....minichain.lib.fs.tools.read import read_tool
|
|
68
|
+
|
|
69
|
+
return inj.as_elements(
|
|
70
|
+
tool_catalog_entries().bind_item_consts(
|
|
71
|
+
ls_tool(),
|
|
72
|
+
read_tool(),
|
|
73
|
+
),
|
|
74
|
+
|
|
75
|
+
inj.bind(FsContext(
|
|
76
|
+
root_dir=os.getcwd(),
|
|
77
|
+
)),
|
|
78
|
+
bind_tool_context_provider_to_key(FsContext),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# if tools_config.enable_unsafe_tools_do_not_use_lol:
|
|
83
|
+
# from ...minichain.lib.bash import bash_tool
|
|
84
|
+
# els.append(bind_tool(bash_tool()))
|
|
85
|
+
#
|
|
86
|
+
# from ...minichain.lib.fs.tools.edit import edit_tool
|
|
87
|
+
# els.append(bind_tool(edit_tool()))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
##
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def bind_tools(
|
|
94
|
+
*,
|
|
95
|
+
silent: bool = False,
|
|
96
|
+
dangerous_no_confirmation: bool = False,
|
|
97
|
+
enabled_tools: ta.Iterable[str] | None = None,
|
|
98
|
+
) -> inj.Elements:
|
|
99
|
+
els: list[inj.Elemental] = []
|
|
100
|
+
|
|
101
|
+
#
|
|
102
|
+
|
|
103
|
+
els.append(inj.bind(mc.ToolCatalog, singleton=True))
|
|
104
|
+
|
|
105
|
+
#
|
|
106
|
+
|
|
107
|
+
els.append(tool_catalog_entries().bind_items_provider(singleton=True))
|
|
108
|
+
|
|
109
|
+
for etn in check.not_isinstance(enabled_tools or [], str):
|
|
110
|
+
els.append(_TOOL_BINDERS[etn]())
|
|
111
|
+
|
|
112
|
+
#
|
|
113
|
+
|
|
114
|
+
exec_stack = inj.wrapper_binder_helper(_execution.ToolUseExecutor)
|
|
115
|
+
|
|
116
|
+
els.append(exec_stack.push_bind(to_ctor=_execution.ToolUseExecutorImpl, singleton=True))
|
|
117
|
+
|
|
118
|
+
if not silent:
|
|
119
|
+
els.append(exec_stack.push_bind(to_ctor=_rendering.ResultRenderingToolUseExecutor, singleton=True))
|
|
120
|
+
|
|
121
|
+
if dangerous_no_confirmation:
|
|
122
|
+
els.append(exec_stack.push_bind(to_ctor=_rendering.ArgsRenderingToolUseExecutor, singleton=True))
|
|
123
|
+
|
|
124
|
+
els.extend([
|
|
125
|
+
inj.bind(_execution.ToolUseExecutor, to_key=exec_stack.top),
|
|
126
|
+
])
|
|
127
|
+
|
|
128
|
+
#
|
|
129
|
+
|
|
130
|
+
if not dangerous_no_confirmation:
|
|
131
|
+
els.append(inj.bind(_confirmation.ToolExecutionConfirmation, to_ctor=_confirmation.InteractiveToolExecutionConfirmation, singleton=True)) # noqa
|
|
132
|
+
|
|
133
|
+
#
|
|
134
|
+
|
|
135
|
+
els.extend([
|
|
136
|
+
tool_context_providers().bind_items_provider(singleton=True),
|
|
137
|
+
|
|
138
|
+
inj.bind(_execution.ToolContextProvider, to_fn=lang.typed_lambda(tcps=_execution.ToolContextProviders)(
|
|
139
|
+
lambda tcps: _execution.ToolContextProvider(lambda: [tc for tcp in tcps for tc in tcp()]),
|
|
140
|
+
), singleton=True),
|
|
141
|
+
])
|
|
142
|
+
|
|
143
|
+
#
|
|
144
|
+
|
|
145
|
+
return inj.as_elements(*els)
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
|
|
8
|
+
|
|
9
|
+
with lang.auto_proxy_import(globals()):
|
|
10
|
+
from . import execution as _execution
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@lang.cached_function
|
|
16
|
+
def tool_catalog_entries() -> 'inj.ItemsBinderHelper[mc.ToolCatalogEntry]':
|
|
17
|
+
return inj.items_binder_helper[mc.ToolCatalogEntry](mc.ToolCatalogEntries)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@lang.cached_function
|
|
21
|
+
def tool_context_providers() -> 'inj.ItemsBinderHelper[_execution.ToolContextProvider]':
|
|
22
|
+
return inj.items_binder_helper[_execution.ToolContextProvider](_execution.ToolContextProviders)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def bind_tool_context_provider_to_key(key: ta.Any) -> inj.Elements:
|
|
26
|
+
return tool_context_providers().bind_item(to_fn=inj.KwargsTarget.of(
|
|
27
|
+
lambda v: _execution.ToolContextProvider(lambda: [v]),
|
|
28
|
+
v=key,
|
|
29
|
+
), singleton=True)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import typing as ta
|
|
2
|
+
|
|
3
|
+
from ..... import minichain as mc
|
|
4
|
+
from ..rendering.types import ContentRendering
|
|
5
|
+
from .execution import ToolUseExecutor
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ArgsRenderingToolUseExecutor(ToolUseExecutor):
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
*,
|
|
15
|
+
wrapped: ToolUseExecutor,
|
|
16
|
+
renderer: ContentRendering,
|
|
17
|
+
) -> None:
|
|
18
|
+
super().__init__()
|
|
19
|
+
|
|
20
|
+
self._wrapped = wrapped
|
|
21
|
+
self._renderer = renderer
|
|
22
|
+
|
|
23
|
+
async def execute_tool_use(
|
|
24
|
+
self,
|
|
25
|
+
use: 'mc.ToolUse',
|
|
26
|
+
*ctx_items: ta.Any,
|
|
27
|
+
) -> 'mc.ToolUseResultMessage':
|
|
28
|
+
await self._renderer.render_content(mc.JsonContent(dict(
|
|
29
|
+
id=use.id,
|
|
30
|
+
name=use.name,
|
|
31
|
+
args=use.args,
|
|
32
|
+
)))
|
|
33
|
+
|
|
34
|
+
return await self._wrapped.execute_tool_use(use, *ctx_items)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ResultRenderingToolUseExecutor(ToolUseExecutor):
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
*,
|
|
41
|
+
wrapped: ToolUseExecutor,
|
|
42
|
+
renderer: ContentRendering,
|
|
43
|
+
) -> None:
|
|
44
|
+
super().__init__()
|
|
45
|
+
|
|
46
|
+
self._wrapped = wrapped
|
|
47
|
+
self._renderer = renderer
|
|
48
|
+
|
|
49
|
+
async def execute_tool_use(
|
|
50
|
+
self,
|
|
51
|
+
use: 'mc.ToolUse',
|
|
52
|
+
*ctx_items: ta.Any,
|
|
53
|
+
) -> 'mc.ToolUseResultMessage':
|
|
54
|
+
out = await self._wrapped.execute_tool_use(use, *ctx_items)
|
|
55
|
+
|
|
56
|
+
await self._renderer.render_content(out.tur.c)
|
|
57
|
+
|
|
58
|
+
return out
|
ommlds/cli/sessions/inject.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
from omlish import inject as inj
|
|
2
2
|
|
|
3
3
|
from .base import Session
|
|
4
|
-
from .chat.
|
|
5
|
-
from .chat2.session import Chat2Session
|
|
4
|
+
from .chat.session import ChatSession
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
##
|
|
@@ -16,11 +15,7 @@ def bind_sessions(session_cfg: Session.Config) -> inj.Elements:
|
|
|
16
15
|
]
|
|
17
16
|
|
|
18
17
|
if isinstance(session_cfg, ChatSession.Config):
|
|
19
|
-
from .chat.inject import
|
|
20
|
-
els.append(bind_chat_session(session_cfg))
|
|
21
|
-
|
|
22
|
-
elif isinstance(session_cfg, Chat2Session.Config):
|
|
23
|
-
from .chat2.inject import bind_chat
|
|
18
|
+
from .chat.inject import bind_chat
|
|
24
19
|
els.append(bind_chat(session_cfg)) # noqa
|
|
25
20
|
|
|
26
21
|
return inj.as_elements(*els)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ommlds
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev464
|
|
4
4
|
Summary: ommlds
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -14,8 +14,8 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
14
14
|
Requires-Python: >=3.13
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: omdev==0.0.0.
|
|
18
|
-
Requires-Dist: omlish==0.0.0.
|
|
17
|
+
Requires-Dist: omdev==0.0.0.dev464
|
|
18
|
+
Requires-Dist: omlish==0.0.0.dev464
|
|
19
19
|
Provides-Extra: all
|
|
20
20
|
Requires-Dist: llama-cpp-python~=0.3; extra == "all"
|
|
21
21
|
Requires-Dist: mlx~=0.29; extra == "all"
|
|
@@ -77,65 +77,67 @@ ommlds/backends/torch/devices.py,sha256=KWkeyArPdUwVqckQTJPkN-4GQdv39cpOgCMv_Xfk
|
|
|
77
77
|
ommlds/backends/torch/purge.py,sha256=sp6XUxNLoVCepxIPKw3tevHn-cQqgorILvIQzixauiI,1834
|
|
78
78
|
ommlds/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
79
|
ommlds/cli/__main__.py,sha256=1ffCb0fcUOJMzxROJmJRXQ8PSOVYv7KrcuBtT95cf0c,140
|
|
80
|
-
ommlds/cli/inject.py,sha256=
|
|
81
|
-
ommlds/cli/main.py,sha256=
|
|
80
|
+
ommlds/cli/inject.py,sha256=QEuipqBPsET3rA0aO2c8hKCU77kgWwMfWktW8cGDkyw,1160
|
|
81
|
+
ommlds/cli/main.py,sha256=dCSmhu0Xk6thP6pu_nmo1kp-WiR4aC1RBOfG0Y8BKjI,5534
|
|
82
82
|
ommlds/cli/state.py,sha256=tRPmgCANRrw7A5Qr700OaH58F6S96O37I8Ivrbo7_gI,3001
|
|
83
83
|
ommlds/cli/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
84
84
|
ommlds/cli/backends/inject.py,sha256=OVstNsoeVnprM9PBL_zP0N46KkoDg3_Wz90BWcQ7km4,1734
|
|
85
85
|
ommlds/cli/backends/standard.py,sha256=HnammWyAXJHeqXJrAMBdarcT4Nyt2CxudZdD2fW_Y9M,631
|
|
86
86
|
ommlds/cli/sessions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
87
87
|
ommlds/cli/sessions/base.py,sha256=oTqsqZ9jhBWFblANpVWLLIzmRfP8HO9QYtPnZ-GZxS0,452
|
|
88
|
-
ommlds/cli/sessions/inject.py,sha256=
|
|
88
|
+
ommlds/cli/sessions/inject.py,sha256=oDiEuBkchaBKHVTJcd11v4P_pSurhrvwhbaAVCcUhOM,548
|
|
89
89
|
ommlds/cli/sessions/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
90
|
-
ommlds/cli/sessions/chat/
|
|
91
|
-
ommlds/cli/sessions/chat/
|
|
92
|
-
ommlds/cli/sessions/chat/inject.py,sha256=
|
|
93
|
-
ommlds/cli/sessions/chat/
|
|
94
|
-
ommlds/cli/sessions/chat/
|
|
95
|
-
ommlds/cli/sessions/chat/
|
|
96
|
-
ommlds/cli/sessions/chat/
|
|
97
|
-
ommlds/cli/sessions/chat/
|
|
98
|
-
ommlds/cli/sessions/
|
|
99
|
-
ommlds/cli/sessions/
|
|
100
|
-
ommlds/cli/sessions/
|
|
101
|
-
ommlds/cli/sessions/
|
|
102
|
-
ommlds/cli/sessions/
|
|
103
|
-
ommlds/cli/sessions/
|
|
104
|
-
ommlds/cli/sessions/
|
|
105
|
-
ommlds/cli/sessions/
|
|
106
|
-
ommlds/cli/sessions/
|
|
107
|
-
ommlds/cli/sessions/
|
|
108
|
-
ommlds/cli/sessions/
|
|
109
|
-
ommlds/cli/sessions/
|
|
110
|
-
ommlds/cli/sessions/
|
|
111
|
-
ommlds/cli/sessions/
|
|
112
|
-
ommlds/cli/sessions/
|
|
113
|
-
ommlds/cli/sessions/
|
|
114
|
-
ommlds/cli/sessions/
|
|
115
|
-
ommlds/cli/sessions/
|
|
116
|
-
ommlds/cli/sessions/
|
|
117
|
-
ommlds/cli/sessions/
|
|
118
|
-
ommlds/cli/sessions/
|
|
119
|
-
ommlds/cli/sessions/
|
|
120
|
-
ommlds/cli/sessions/
|
|
121
|
-
ommlds/cli/sessions/
|
|
122
|
-
ommlds/cli/sessions/
|
|
123
|
-
ommlds/cli/sessions/
|
|
124
|
-
ommlds/cli/sessions/
|
|
125
|
-
ommlds/cli/sessions/
|
|
126
|
-
ommlds/cli/sessions/
|
|
127
|
-
ommlds/cli/sessions/
|
|
128
|
-
ommlds/cli/sessions/
|
|
129
|
-
ommlds/cli/sessions/
|
|
130
|
-
ommlds/cli/sessions/
|
|
90
|
+
ommlds/cli/sessions/chat/configs.py,sha256=7NtpOaSyjABKLuJ1jAbp1lCT1tPjvPVJ_vakbzvuk8g,692
|
|
91
|
+
ommlds/cli/sessions/chat/driver.py,sha256=ddnCYTKqWiPxV8U4UbFwb7E3yi81ItjZ9j3AJd3a3Mk,1395
|
|
92
|
+
ommlds/cli/sessions/chat/inject.py,sha256=tlZ2kmS6PxLbGzgKhbtUyzUw2uyeZ9TpWt0QFdgmAOM,1656
|
|
93
|
+
ommlds/cli/sessions/chat/session.py,sha256=eqwelLE74JFC-fBpk_hdwMD2nP4pLv3ZPwUn99200B8,521
|
|
94
|
+
ommlds/cli/sessions/chat/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
95
|
+
ommlds/cli/sessions/chat/backends/catalog.py,sha256=GroogxBQf_zlrhEEwTSq18v13HWsuXOP276VcuphPic,1756
|
|
96
|
+
ommlds/cli/sessions/chat/backends/inject.py,sha256=VbZ-Fb679kTItRpAhIYCqSM8vXUFeRDQWssUfrFgGi8,882
|
|
97
|
+
ommlds/cli/sessions/chat/backends/injection.py,sha256=GCn5OvNIEowgB70kQVuU84z3i8lLA4vOVkTZlQG8s0o,327
|
|
98
|
+
ommlds/cli/sessions/chat/backends/types.py,sha256=5eImYHXLKqbC5MDrN443eMGamP9snCmV1n7LtAsqgPk,696
|
|
99
|
+
ommlds/cli/sessions/chat/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
100
|
+
ommlds/cli/sessions/chat/chat/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
101
|
+
ommlds/cli/sessions/chat/chat/ai/inject.py,sha256=Uq1zDpFj3cZqWns2gfMu1Oun4ssbfzVB1JfpUdwh8wc,2572
|
|
102
|
+
ommlds/cli/sessions/chat/chat/ai/injection.py,sha256=2O_ELMusxQsYaB2oqvzjYpZQzjshocJup7Z5unzoUIY,404
|
|
103
|
+
ommlds/cli/sessions/chat/chat/ai/rendering.py,sha256=cicA6NwkM9UJb1dgsakhkhIMWGzBsArPFvYoINBmuec,2285
|
|
104
|
+
ommlds/cli/sessions/chat/chat/ai/services.py,sha256=RNO3emXEFPr0M04wThRQo332x0n5R3n8aQFctcePCHQ,2629
|
|
105
|
+
ommlds/cli/sessions/chat/chat/ai/tools.py,sha256=en94LLM8y73N11xhQPlkSLfbzAmYVwKU-4nz2i0CK0E,1094
|
|
106
|
+
ommlds/cli/sessions/chat/chat/ai/types.py,sha256=QH6Cn6DrdxBi0Tnura7Fq-WtGUm0FdsazZSgki6nf0A,750
|
|
107
|
+
ommlds/cli/sessions/chat/chat/state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
108
|
+
ommlds/cli/sessions/chat/chat/state/inject.py,sha256=usHhiE1fKtttJvxgVN-LuwIsfyau_0n17-99bDuPNnw,1131
|
|
109
|
+
ommlds/cli/sessions/chat/chat/state/inmemory.py,sha256=2lSCWnNEH_vj9RJUVzM8huAHAXBJ6Go02og2nzew1hk,861
|
|
110
|
+
ommlds/cli/sessions/chat/chat/state/storage.py,sha256=IabpjwrD89kX7s_hcKjpumu0He0jMmK-uOig1RmAxIA,1428
|
|
111
|
+
ommlds/cli/sessions/chat/chat/state/types.py,sha256=iMovPXnRvZJ8ieM5gPnTBi1X7j-9GUtziiPBZJJf034,794
|
|
112
|
+
ommlds/cli/sessions/chat/chat/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
113
|
+
ommlds/cli/sessions/chat/chat/user/inject.py,sha256=x0DV0kMxEiHVTjQwsQlW4wKHfACu0Nlnhbsc4Uum_wI,2164
|
|
114
|
+
ommlds/cli/sessions/chat/chat/user/interactive.py,sha256=AZ8v5uGscnNk4KJdGisOA2LND8m7473fY5Whks7M_tI,688
|
|
115
|
+
ommlds/cli/sessions/chat/chat/user/oneshot.py,sha256=jPrZBBuf-olBfPF7CPTYK7-Dr7EvSriU7L0nORHfbv4,588
|
|
116
|
+
ommlds/cli/sessions/chat/chat/user/types.py,sha256=MNlhMxlLtxVod9rUZlSPvRaippPAXEdX_GHh73QLeSg,262
|
|
117
|
+
ommlds/cli/sessions/chat/content/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
118
|
+
ommlds/cli/sessions/chat/content/messages.py,sha256=DhGIBdPXXiQdKcQkPKFJPmhdL2CBHvyoVWhSKBRVMY0,939
|
|
119
|
+
ommlds/cli/sessions/chat/content/strings.py,sha256=PyaHeUnAAuhOyJr7F7G4xupUOQLs7_iOd74wFNHTkfg,1055
|
|
120
|
+
ommlds/cli/sessions/chat/phases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
121
|
+
ommlds/cli/sessions/chat/phases/inject.py,sha256=m9GcCVcp1GnNKN1qwDSgTkfp3e107wXgPeEHDLbfG8s,448
|
|
122
|
+
ommlds/cli/sessions/chat/phases/injection.py,sha256=ZUFRRLp3HNhKaPBW6aiw5XFEGNkqTj8WVSlXM0kg0y0,326
|
|
123
|
+
ommlds/cli/sessions/chat/phases/manager.py,sha256=_wfc0FfL5h_5L-6hnYb3U3kiRmkGDkJu7wGj5Cgz7_Y,727
|
|
124
|
+
ommlds/cli/sessions/chat/phases/types.py,sha256=w1pAEydJYaHzSzdlqygCwKxvVZnfo_R_xJqq8wBzZsQ,512
|
|
125
|
+
ommlds/cli/sessions/chat/rendering/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
126
|
+
ommlds/cli/sessions/chat/rendering/inject.py,sha256=Yo_BDxDNbTge8UtEp31uTKhsFdaeVf-4CFs3rdu8l0I,885
|
|
127
|
+
ommlds/cli/sessions/chat/rendering/markdown.py,sha256=C4z9Rs0ivVTrBmu7lFnybNOq1j9hEZb58Gc_R8rmcUI,1803
|
|
128
|
+
ommlds/cli/sessions/chat/rendering/raw.py,sha256=L7RIY77dycZRTspWJC4Vj4fP9I-vdqo_0qe_8bj-0QQ,2432
|
|
129
|
+
ommlds/cli/sessions/chat/rendering/types.py,sha256=6wzYeitDGVufrf0W-R2cuwcBscPf9yPl0HtiCd7am2Q,449
|
|
130
|
+
ommlds/cli/sessions/chat/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
131
|
+
ommlds/cli/sessions/chat/tools/confirmation.py,sha256=I_nYBIIoeprCShUaVpN4v01YOAdY6iJEM5-ybc0p8VA,1072
|
|
132
|
+
ommlds/cli/sessions/chat/tools/execution.py,sha256=4sRuZWZjNBo852hhLZjqTqEZpgu9KPXHEawiICIMUdc,1576
|
|
133
|
+
ommlds/cli/sessions/chat/tools/inject.py,sha256=iKBvMrgmFCkgjD0MWtIQFuoiijfRwmhfFW1l6q5Fnd0,3845
|
|
134
|
+
ommlds/cli/sessions/chat/tools/injection.py,sha256=xsVbJAKsDIP-2LbzDXZ3LBJgeY0FJ66UuCK0OYB1uw0,837
|
|
135
|
+
ommlds/cli/sessions/chat/tools/rendering.py,sha256=a9gIhxuGF9tfXGlkGXpdweSz4dacIsxoqJNKpRSvUN4,1402
|
|
136
|
+
ommlds/cli/sessions/chat/tools/weather.py,sha256=vZXOHdRGGlkDEXasW5foc58MyEMOc79bhIfIgrumRlo,302
|
|
131
137
|
ommlds/cli/sessions/completion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
132
138
|
ommlds/cli/sessions/completion/completion.py,sha256=2ZrzmHBCF3mG13ABcoiHva6OUzPpdF7qzByteaLNsxk,1077
|
|
133
139
|
ommlds/cli/sessions/embedding/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
140
|
ommlds/cli/sessions/embedding/embedding.py,sha256=9U5Maj-XI5nsrk7m-O3P2rZggey0z2p7onZn2QfQe38,1051
|
|
135
|
-
ommlds/cli/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
136
|
-
ommlds/cli/tools/config.py,sha256=aEssMUVNR0yy9v9yXJm3MOohb97Gx26jrOg2QHZuFbo,272
|
|
137
|
-
ommlds/cli/tools/inject.py,sha256=L30UvDCyXjt4gB1snatp7xx-VF4nlBiewS10Hnaq76c,1938
|
|
138
|
-
ommlds/cli/tools/weather.py,sha256=FUPxPF5KBbbyK3voBtcRUOkuMO2zK5GFZoFTJMaM6LQ,300
|
|
139
141
|
ommlds/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
140
142
|
ommlds/datasets/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
141
143
|
ommlds/datasets/lib/movies.py,sha256=LmdfoXsZU9XMM_r-sxCLv_s06BFzwWO4xUj6sc9XVcI,1961
|
|
@@ -358,9 +360,9 @@ ommlds/wiki/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
|
358
360
|
ommlds/wiki/utils/io.py,sha256=UKgDJGtmpnWvIqVd2mJc2QNPOqlToEY1GEveNp6_pMo,7088
|
|
359
361
|
ommlds/wiki/utils/progress.py,sha256=EhvKcMFYtsarCQhIahlO6f0SboyAKP3UwUyrnVnP-Vk,3222
|
|
360
362
|
ommlds/wiki/utils/xml.py,sha256=vVV8Ctn13aaRM9eYfs9Wd6rHn5WOCEUzQ44fIhOvJdg,3754
|
|
361
|
-
ommlds-0.0.0.
|
|
362
|
-
ommlds-0.0.0.
|
|
363
|
-
ommlds-0.0.0.
|
|
364
|
-
ommlds-0.0.0.
|
|
365
|
-
ommlds-0.0.0.
|
|
366
|
-
ommlds-0.0.0.
|
|
363
|
+
ommlds-0.0.0.dev464.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
364
|
+
ommlds-0.0.0.dev464.dist-info/METADATA,sha256=tgOdigb0BtGCCBTpaDgfW0Rog8sK9jpRUYW1jsIxMxo,3224
|
|
365
|
+
ommlds-0.0.0.dev464.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
366
|
+
ommlds-0.0.0.dev464.dist-info/entry_points.txt,sha256=Z5YWtX7ClfiCKdW-dd_CSVvM0h4yQpJPi-2G3q6gNFo,35
|
|
367
|
+
ommlds-0.0.0.dev464.dist-info/top_level.txt,sha256=Rbnk5d5wi58vnAXx13WFZqdQ4VX8hBCS2hEL3WeXOhY,7
|
|
368
|
+
ommlds-0.0.0.dev464.dist-info/RECORD,,
|
ommlds/cli/sessions/chat/base.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import dataclasses as dc
|
|
2
|
-
import typing as ta
|
|
3
|
-
|
|
4
|
-
from omlish import lang
|
|
5
|
-
|
|
6
|
-
from .... import minichain as mc
|
|
7
|
-
from ..base import Session
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
DEFAULT_CHAT_MODEL_BACKEND = 'openai'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
ChatOption: ta.TypeAlias = mc.ChatChoicesOptions
|
|
20
|
-
ChatOptions = ta.NewType('ChatOptions', ta.Sequence[ChatOption])
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ChatSessionConfigT = ta.TypeVar('ChatSessionConfigT', bound='ChatSession.Config')
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class ChatSession(Session[ChatSessionConfigT], lang.Abstract, ta.Generic[ChatSessionConfigT]):
|
|
30
|
-
@dc.dataclass(frozen=True)
|
|
31
|
-
class Config(Session.Config, lang.Abstract):
|
|
32
|
-
_: dc.KW_ONLY
|
|
33
|
-
|
|
34
|
-
markdown: bool = False
|
|
35
|
-
|
|
36
|
-
dangerous_no_tool_confirmation: bool = False
|
|
37
|
-
|
|
38
|
-
def __init__(
|
|
39
|
-
self,
|
|
40
|
-
config: ChatSessionConfigT,
|
|
41
|
-
) -> None:
|
|
42
|
-
super().__init__(config)
|
ommlds/cli/sessions/chat/code.py
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import dataclasses as dc
|
|
2
|
-
import itertools
|
|
3
|
-
import os.path
|
|
4
|
-
|
|
5
|
-
from omlish import check
|
|
6
|
-
from omlish import lang
|
|
7
|
-
|
|
8
|
-
from .... import minichain as mc
|
|
9
|
-
from ....minichain.lib.code.prompts import CODE_AGENT_SYSTEM_PROMPT
|
|
10
|
-
from ...tools.config import ToolsConfig
|
|
11
|
-
from .base import DEFAULT_CHAT_MODEL_BACKEND
|
|
12
|
-
from .base import ChatOptions
|
|
13
|
-
from .base import ChatSession
|
|
14
|
-
from .printing import ChatSessionPrinter
|
|
15
|
-
from .state import ChatStateManager
|
|
16
|
-
from .tools import ToolUseExecutor
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class CodeChatSession(ChatSession['CodeChatSession.Config']):
|
|
23
|
-
@dc.dataclass(frozen=True)
|
|
24
|
-
class Config(ChatSession.Config):
|
|
25
|
-
_: dc.KW_ONLY
|
|
26
|
-
|
|
27
|
-
new: bool = False
|
|
28
|
-
|
|
29
|
-
backend: str | None = None
|
|
30
|
-
model_name: str | None = None
|
|
31
|
-
|
|
32
|
-
initial_message: mc.Content | None = None
|
|
33
|
-
|
|
34
|
-
def __init__(
|
|
35
|
-
self,
|
|
36
|
-
config: Config,
|
|
37
|
-
*,
|
|
38
|
-
state_manager: ChatStateManager,
|
|
39
|
-
chat_options: ChatOptions | None = None,
|
|
40
|
-
printer: ChatSessionPrinter,
|
|
41
|
-
backend_catalog: mc.BackendCatalog,
|
|
42
|
-
tool_exec_request_executor: ToolUseExecutor,
|
|
43
|
-
tools_config: ToolsConfig | None = None,
|
|
44
|
-
) -> None:
|
|
45
|
-
super().__init__(config)
|
|
46
|
-
|
|
47
|
-
self._state_manager = state_manager
|
|
48
|
-
self._chat_options = chat_options
|
|
49
|
-
self._printer = printer
|
|
50
|
-
self._backend_catalog = backend_catalog
|
|
51
|
-
self._tool_exec_request_executor = tool_exec_request_executor
|
|
52
|
-
self._tools_config = tools_config
|
|
53
|
-
|
|
54
|
-
async def run(self) -> None:
|
|
55
|
-
if self._config.new:
|
|
56
|
-
self._state_manager.clear_state()
|
|
57
|
-
state = self._state_manager.extend_chat([
|
|
58
|
-
mc.SystemMessage(CODE_AGENT_SYSTEM_PROMPT),
|
|
59
|
-
])
|
|
60
|
-
|
|
61
|
-
else:
|
|
62
|
-
state = self._state_manager.get_state()
|
|
63
|
-
|
|
64
|
-
backend = self._config.backend
|
|
65
|
-
if backend is None:
|
|
66
|
-
backend = DEFAULT_CHAT_MODEL_BACKEND
|
|
67
|
-
|
|
68
|
-
# FIXME: lol
|
|
69
|
-
from ....minichain.lib.fs.context import FsContext
|
|
70
|
-
fs_tool_context = FsContext(
|
|
71
|
-
root_dir=os.getcwd(),
|
|
72
|
-
writes_permitted=self._tools_config is not None and self._tools_config.enable_unsafe_tools_do_not_use_lol,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
from ....minichain.lib.todo.context import TodoContext
|
|
76
|
-
todo_tool_context = TodoContext()
|
|
77
|
-
|
|
78
|
-
mdl: mc.ChatChoicesService
|
|
79
|
-
async with lang.async_maybe_managing(self._backend_catalog.get_backend(
|
|
80
|
-
mc.ChatChoicesService,
|
|
81
|
-
backend,
|
|
82
|
-
*([mc.ModelName(mn)] if (mn := self._config.model_name) is not None else []),
|
|
83
|
-
)) as mdl:
|
|
84
|
-
for i in itertools.count():
|
|
85
|
-
if not i and self._config.initial_message is not None:
|
|
86
|
-
req_msg = mc.UserMessage(self._config.initial_message)
|
|
87
|
-
else:
|
|
88
|
-
try:
|
|
89
|
-
prompt = input('> ') # FIXME: async lol
|
|
90
|
-
except EOFError:
|
|
91
|
-
break
|
|
92
|
-
req_msg = mc.UserMessage(prompt)
|
|
93
|
-
|
|
94
|
-
state = self._state_manager.extend_chat([req_msg])
|
|
95
|
-
|
|
96
|
-
while True:
|
|
97
|
-
response = await mdl.invoke(mc.ChatChoicesRequest(
|
|
98
|
-
state.chat,
|
|
99
|
-
(self._chat_options or []),
|
|
100
|
-
))
|
|
101
|
-
|
|
102
|
-
tool_resp_lst = []
|
|
103
|
-
for resp_msg in check.single(response.v).ms:
|
|
104
|
-
state = self._state_manager.extend_chat([resp_msg])
|
|
105
|
-
|
|
106
|
-
if isinstance(resp_msg, mc.AiMessage):
|
|
107
|
-
self._printer.print(resp_msg)
|
|
108
|
-
|
|
109
|
-
elif isinstance(resp_msg, mc.ToolUseMessage):
|
|
110
|
-
trm = await self._tool_exec_request_executor.execute_tool_use(
|
|
111
|
-
resp_msg.tu,
|
|
112
|
-
fs_tool_context,
|
|
113
|
-
todo_tool_context,
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
self._printer.print(trm.tur.c)
|
|
117
|
-
tool_resp_lst.append(trm)
|
|
118
|
-
|
|
119
|
-
else:
|
|
120
|
-
raise TypeError(resp_msg)
|
|
121
|
-
|
|
122
|
-
if not tool_resp_lst:
|
|
123
|
-
break
|
|
124
|
-
|
|
125
|
-
state = self._state_manager.extend_chat(tool_resp_lst)
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import dataclasses as dc
|
|
2
|
-
|
|
3
|
-
from omlish import check
|
|
4
|
-
from omlish import lang
|
|
5
|
-
|
|
6
|
-
from .... import minichain as mc
|
|
7
|
-
from .base import DEFAULT_CHAT_MODEL_BACKEND
|
|
8
|
-
from .base import ChatSession
|
|
9
|
-
from .printing import ChatSessionPrinter
|
|
10
|
-
from .state import ChatStateManager
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class InteractiveChatSession(ChatSession['InteractiveChatSession.Config']):
|
|
17
|
-
@dc.dataclass(frozen=True)
|
|
18
|
-
class Config(ChatSession.Config):
|
|
19
|
-
_: dc.KW_ONLY
|
|
20
|
-
|
|
21
|
-
new: bool = False
|
|
22
|
-
|
|
23
|
-
backend: str | None = None
|
|
24
|
-
model_name: str | None = None
|
|
25
|
-
|
|
26
|
-
def __init__(
|
|
27
|
-
self,
|
|
28
|
-
config: Config,
|
|
29
|
-
*,
|
|
30
|
-
state_manager: ChatStateManager,
|
|
31
|
-
printer: ChatSessionPrinter,
|
|
32
|
-
backend_catalog: mc.BackendCatalog,
|
|
33
|
-
) -> None:
|
|
34
|
-
super().__init__(config)
|
|
35
|
-
|
|
36
|
-
self._state_manager = state_manager
|
|
37
|
-
self._printer = printer
|
|
38
|
-
self._backend_catalog = backend_catalog
|
|
39
|
-
|
|
40
|
-
async def run(self) -> None:
|
|
41
|
-
if self._config.new:
|
|
42
|
-
state = self._state_manager.clear_state()
|
|
43
|
-
else:
|
|
44
|
-
state = self._state_manager.get_state()
|
|
45
|
-
|
|
46
|
-
backend = self._config.backend
|
|
47
|
-
if backend is None:
|
|
48
|
-
backend = DEFAULT_CHAT_MODEL_BACKEND
|
|
49
|
-
|
|
50
|
-
mdl: mc.ChatChoicesService
|
|
51
|
-
async with lang.async_maybe_managing(self._backend_catalog.get_backend(
|
|
52
|
-
mc.ChatChoicesService,
|
|
53
|
-
backend,
|
|
54
|
-
*([mc.ModelName(mn)] if (mn := self._config.model_name) is not None else []),
|
|
55
|
-
)) as mdl:
|
|
56
|
-
while True:
|
|
57
|
-
try:
|
|
58
|
-
prompt = input('> ') # FIXME: async lol
|
|
59
|
-
except EOFError:
|
|
60
|
-
break
|
|
61
|
-
|
|
62
|
-
req_msg = mc.UserMessage(prompt)
|
|
63
|
-
|
|
64
|
-
response = await mdl.invoke(mc.ChatChoicesRequest([*state.chat, req_msg]))
|
|
65
|
-
|
|
66
|
-
resp_msg = check.isinstance(check.single(response.v[0].ms), mc.AiMessage)
|
|
67
|
-
|
|
68
|
-
self._printer.print(resp_msg)
|
|
69
|
-
|
|
70
|
-
state = self._state_manager.extend_chat([req_msg, resp_msg])
|