ommlds 0.0.0.dev489__py3-none-any.whl → 0.0.0.dev491__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.
- ommlds/.omlish-manifests.json +3 -3
- ommlds/README.md +11 -0
- ommlds/__about__.py +1 -1
- ommlds/backends/ollama/_dataclasses.py +53 -23
- ommlds/backends/ollama/protocol.py +3 -0
- ommlds/cli/_dataclasses.py +835 -356
- ommlds/cli/main.py +80 -41
- ommlds/cli/rendering/types.py +6 -0
- ommlds/cli/sessions/chat/configs.py +4 -12
- ommlds/cli/sessions/chat/{chat → drivers}/ai/configs.py +3 -1
- ommlds/cli/sessions/chat/drivers/ai/events.py +57 -0
- ommlds/cli/sessions/chat/{chat → drivers}/ai/inject.py +10 -3
- ommlds/cli/sessions/chat/{chat → drivers}/ai/rendering.py +1 -1
- ommlds/cli/sessions/chat/{chat → drivers}/ai/services.py +1 -1
- ommlds/cli/sessions/chat/{chat → drivers}/ai/tools.py +1 -1
- ommlds/cli/sessions/chat/{chat → drivers}/ai/types.py +9 -0
- ommlds/cli/sessions/chat/drivers/configs.py +25 -0
- ommlds/cli/sessions/chat/drivers/driver.py +49 -0
- ommlds/cli/sessions/chat/drivers/events/inject.py +27 -0
- ommlds/cli/sessions/chat/drivers/events/injection.py +14 -0
- ommlds/cli/sessions/chat/drivers/events/manager.py +16 -0
- ommlds/cli/sessions/chat/drivers/events/types.py +38 -0
- ommlds/cli/sessions/chat/drivers/inject.py +69 -0
- ommlds/cli/sessions/chat/{chat → drivers}/state/inject.py +3 -3
- ommlds/cli/sessions/chat/{chat → drivers}/state/types.py +1 -1
- ommlds/cli/sessions/chat/{tools → drivers/tools}/configs.py +2 -2
- ommlds/cli/sessions/chat/drivers/tools/confirmation.py +44 -0
- ommlds/cli/sessions/chat/{tools → drivers/tools}/execution.py +3 -4
- ommlds/cli/sessions/chat/{tools → drivers/tools}/fs/inject.py +3 -3
- ommlds/cli/sessions/chat/{tools → drivers/tools}/inject.py +4 -12
- ommlds/cli/sessions/chat/{tools → drivers/tools}/injection.py +1 -1
- ommlds/cli/sessions/chat/{tools → drivers/tools}/rendering.py +3 -3
- ommlds/cli/sessions/chat/{tools → drivers/tools}/todo/inject.py +3 -3
- ommlds/cli/sessions/chat/{tools → drivers/tools}/weather/tools.py +1 -1
- ommlds/cli/sessions/chat/drivers/types.py +10 -0
- ommlds/cli/sessions/chat/{chat → drivers}/user/configs.py +0 -2
- ommlds/cli/sessions/chat/drivers/user/inject.py +40 -0
- ommlds/cli/sessions/chat/inject.py +4 -32
- ommlds/cli/sessions/chat/interfaces/bare/inject.py +61 -0
- ommlds/cli/sessions/chat/interfaces/bare/interactive.py +41 -0
- ommlds/cli/sessions/chat/{interface/bare/interface.py → interfaces/bare/oneshot.py} +5 -3
- ommlds/cli/sessions/chat/{tools/confirmation.py → interfaces/bare/tools.py} +3 -22
- ommlds/cli/sessions/chat/{interface → interfaces}/bare/user.py +1 -1
- ommlds/cli/sessions/chat/{interface → interfaces}/configs.py +8 -0
- ommlds/cli/sessions/chat/interfaces/textual/__init__.py +0 -0
- ommlds/cli/sessions/chat/interfaces/textual/app.py +217 -0
- ommlds/cli/sessions/chat/interfaces/textual/inject.py +67 -0
- ommlds/cli/sessions/chat/{interface → interfaces}/textual/interface.py +0 -3
- ommlds/cli/sessions/chat/interfaces/textual/styles/__init__.py +29 -0
- ommlds/cli/sessions/chat/interfaces/textual/styles/input.tcss +51 -0
- ommlds/cli/sessions/chat/interfaces/textual/styles/markdown.tcss +7 -0
- ommlds/cli/sessions/chat/interfaces/textual/styles/messages.tcss +104 -0
- ommlds/cli/sessions/chat/interfaces/textual/widgets/__init__.py +0 -0
- ommlds/cli/sessions/chat/interfaces/textual/widgets/input.py +36 -0
- ommlds/cli/sessions/chat/interfaces/textual/widgets/messages.py +114 -0
- ommlds/cli/sessions/chat/session.py +1 -1
- ommlds/minichain/backends/impls/ollama/chat.py +24 -56
- ommlds/minichain/backends/impls/ollama/protocol.py +144 -0
- ommlds/nanochat/rustbpe/README.md +9 -0
- {ommlds-0.0.0.dev489.dist-info → ommlds-0.0.0.dev491.dist-info}/METADATA +6 -6
- {ommlds-0.0.0.dev489.dist-info → ommlds-0.0.0.dev491.dist-info}/RECORD +91 -73
- ommlds/cli/sessions/chat/chat/user/inject.py +0 -52
- ommlds/cli/sessions/chat/chat/user/oneshot.py +0 -25
- ommlds/cli/sessions/chat/chat/user/types.py +0 -15
- ommlds/cli/sessions/chat/driver.py +0 -43
- ommlds/cli/sessions/chat/interface/bare/inject.py +0 -32
- ommlds/cli/sessions/chat/interface/textual/app.py +0 -191
- ommlds/cli/sessions/chat/interface/textual/inject.py +0 -27
- ommlds/cli/sessions/chat/interface/textual/user.py +0 -20
- /ommlds/cli/sessions/chat/{chat → drivers}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat → drivers}/ai/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat → drivers}/ai/injection.py +0 -0
- /ommlds/cli/sessions/chat/{chat/state → drivers/events}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat/user → drivers/phases}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/phases}/inject.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/phases}/injection.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/phases}/manager.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/phases}/types.py +0 -0
- /ommlds/cli/sessions/chat/{interface → drivers/state}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{chat → drivers}/state/configs.py +0 -0
- /ommlds/cli/sessions/chat/{chat → drivers}/state/inmemory.py +0 -0
- /ommlds/cli/sessions/chat/{chat → drivers}/state/storage.py +0 -0
- /ommlds/cli/sessions/chat/{interface/bare → drivers/tools}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{interface/textual → drivers/tools/fs}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/fs/configs.py +0 -0
- /ommlds/cli/sessions/chat/{phases → drivers/tools/todo}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/todo/configs.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools/weather}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/weather/configs.py +0 -0
- /ommlds/cli/sessions/chat/{tools → drivers/tools}/weather/inject.py +0 -0
- /ommlds/cli/sessions/chat/{tools/fs → drivers/user}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools/todo → interfaces}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{tools/weather → interfaces/bare}/__init__.py +0 -0
- /ommlds/cli/sessions/chat/{interface → interfaces}/base.py +0 -0
- /ommlds/cli/sessions/chat/{interface → interfaces}/inject.py +0 -0
- {ommlds-0.0.0.dev489.dist-info → ommlds-0.0.0.dev491.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev489.dist-info → ommlds-0.0.0.dev491.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev489.dist-info → ommlds-0.0.0.dev491.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev489.dist-info → ommlds-0.0.0.dev491.dist-info}/top_level.txt +0 -0
|
@@ -16,20 +16,17 @@ from ....chat.choices.services import static_check_is_chat_choices_service
|
|
|
16
16
|
from ....chat.choices.stream.services import ChatChoicesStreamRequest
|
|
17
17
|
from ....chat.choices.stream.services import ChatChoicesStreamResponse
|
|
18
18
|
from ....chat.choices.stream.services import static_check_is_chat_choices_stream_service
|
|
19
|
-
from ....chat.choices.stream.types import AiChoiceDeltas
|
|
20
19
|
from ....chat.choices.stream.types import AiChoicesDeltas
|
|
21
|
-
from ....chat.
|
|
22
|
-
from ....chat.messages import AiMessage
|
|
23
|
-
from ....chat.messages import AnyAiMessage
|
|
24
|
-
from ....chat.messages import Message
|
|
25
|
-
from ....chat.messages import SystemMessage
|
|
26
|
-
from ....chat.messages import UserMessage
|
|
27
|
-
from ....chat.stream.types import ContentAiDelta
|
|
20
|
+
from ....chat.tools.types import Tool
|
|
28
21
|
from ....models.configs import ModelName
|
|
29
22
|
from ....resources import UseResources
|
|
30
23
|
from ....standard import ApiUrl
|
|
31
24
|
from ....stream.services import StreamResponseSink
|
|
32
25
|
from ....stream.services import new_stream_response
|
|
26
|
+
from .protocol import build_mc_ai_choice_deltas
|
|
27
|
+
from .protocol import build_mc_choices_response
|
|
28
|
+
from .protocol import build_ol_request_messages
|
|
29
|
+
from .protocol import build_ol_request_tool
|
|
33
30
|
|
|
34
31
|
|
|
35
32
|
##
|
|
@@ -64,31 +61,6 @@ class BaseOllamaChatChoicesService(lang.Abstract):
|
|
|
64
61
|
self._api_url = cc.pop(self.DEFAULT_API_URL)
|
|
65
62
|
self._model_name = cc.pop(self.DEFAULT_MODEL_NAME)
|
|
66
63
|
|
|
67
|
-
#
|
|
68
|
-
|
|
69
|
-
ROLE_MAP: ta.ClassVar[ta.Mapping[type[Message], pt.Role]] = { # noqa
|
|
70
|
-
SystemMessage: 'system',
|
|
71
|
-
UserMessage: 'user',
|
|
72
|
-
AiMessage: 'assistant',
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@classmethod
|
|
76
|
-
def _get_message_content(cls, m: Message) -> str | None:
|
|
77
|
-
if isinstance(m, (AiMessage, UserMessage, SystemMessage)):
|
|
78
|
-
return check.isinstance(m.c, str)
|
|
79
|
-
else:
|
|
80
|
-
raise TypeError(m)
|
|
81
|
-
|
|
82
|
-
@classmethod
|
|
83
|
-
def _build_request_messages(cls, mc_msgs: ta.Iterable[Message]) -> ta.Sequence[pt.Message]:
|
|
84
|
-
messages: list[pt.Message] = []
|
|
85
|
-
for m in mc_msgs:
|
|
86
|
-
messages.append(pt.Message(
|
|
87
|
-
role=cls.ROLE_MAP[type(m)],
|
|
88
|
-
content=cls._get_message_content(m),
|
|
89
|
-
))
|
|
90
|
-
return messages
|
|
91
|
-
|
|
92
64
|
|
|
93
65
|
##
|
|
94
66
|
|
|
@@ -103,12 +75,18 @@ class OllamaChatChoicesService(BaseOllamaChatChoicesService):
|
|
|
103
75
|
self,
|
|
104
76
|
request: ChatChoicesRequest,
|
|
105
77
|
) -> ChatChoicesResponse:
|
|
106
|
-
messages =
|
|
78
|
+
messages = build_ol_request_messages(request.v)
|
|
79
|
+
|
|
80
|
+
tools: list[pt.Tool] = []
|
|
81
|
+
with tv.TypedValues(*request.options).consume() as oc:
|
|
82
|
+
t: Tool
|
|
83
|
+
for t in oc.pop(Tool, []):
|
|
84
|
+
tools.append(build_ol_request_tool(t))
|
|
107
85
|
|
|
108
86
|
a_req = pt.ChatRequest(
|
|
109
87
|
model=self._model_name.v,
|
|
110
88
|
messages=messages,
|
|
111
|
-
|
|
89
|
+
tools=tools or None,
|
|
112
90
|
stream=False,
|
|
113
91
|
)
|
|
114
92
|
|
|
@@ -124,17 +102,7 @@ class OllamaChatChoicesService(BaseOllamaChatChoicesService):
|
|
|
124
102
|
|
|
125
103
|
resp = msh.unmarshal(json_response, pt.ChatResponse)
|
|
126
104
|
|
|
127
|
-
|
|
128
|
-
if resp.message.role == 'assistant':
|
|
129
|
-
out.append(AiMessage(
|
|
130
|
-
check.not_none(resp.message.content),
|
|
131
|
-
))
|
|
132
|
-
else:
|
|
133
|
-
raise TypeError(resp.message.role)
|
|
134
|
-
|
|
135
|
-
return ChatChoicesResponse([
|
|
136
|
-
AiChoice(out),
|
|
137
|
-
])
|
|
105
|
+
return build_mc_choices_response(resp)
|
|
138
106
|
|
|
139
107
|
|
|
140
108
|
##
|
|
@@ -152,12 +120,18 @@ class OllamaChatChoicesStreamService(BaseOllamaChatChoicesService):
|
|
|
152
120
|
self,
|
|
153
121
|
request: ChatChoicesStreamRequest,
|
|
154
122
|
) -> ChatChoicesStreamResponse:
|
|
155
|
-
messages =
|
|
123
|
+
messages = build_ol_request_messages(request.v)
|
|
124
|
+
|
|
125
|
+
tools: list[pt.Tool] = []
|
|
126
|
+
with tv.TypedValues(*request.options).consume() as oc:
|
|
127
|
+
t: Tool
|
|
128
|
+
for t in oc.pop(Tool, []):
|
|
129
|
+
tools.append(build_ol_request_tool(t))
|
|
156
130
|
|
|
157
131
|
a_req = pt.ChatRequest(
|
|
158
132
|
model=self._model_name.v,
|
|
159
133
|
messages=messages,
|
|
160
|
-
|
|
134
|
+
tools=tools or None,
|
|
161
135
|
stream=True,
|
|
162
136
|
)
|
|
163
137
|
|
|
@@ -184,14 +158,8 @@ class OllamaChatChoicesStreamService(BaseOllamaChatChoicesService):
|
|
|
184
158
|
lj = json.loads(l.decode('utf-8'))
|
|
185
159
|
lp: pt.ChatResponse = msh.unmarshal(lj, pt.ChatResponse)
|
|
186
160
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
check.state(not lp.message.tool_calls)
|
|
190
|
-
|
|
191
|
-
if (c := lp.message.content):
|
|
192
|
-
await sink.emit(AiChoicesDeltas([AiChoiceDeltas([ContentAiDelta(
|
|
193
|
-
c,
|
|
194
|
-
)])]))
|
|
161
|
+
if (ds := build_mc_ai_choice_deltas(lp)).deltas:
|
|
162
|
+
await sink.emit(AiChoicesDeltas([ds]))
|
|
195
163
|
|
|
196
164
|
if not b:
|
|
197
165
|
return []
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import itertools
|
|
2
|
+
|
|
3
|
+
from omlish import check
|
|
4
|
+
|
|
5
|
+
from .....backends.ollama import protocol as pt
|
|
6
|
+
from ....chat.choices.services import ChatChoicesResponse
|
|
7
|
+
from ....chat.choices.stream.types import AiChoiceDeltas
|
|
8
|
+
from ....chat.choices.types import AiChoice
|
|
9
|
+
from ....chat.messages import AiMessage
|
|
10
|
+
from ....chat.messages import AnyAiMessage
|
|
11
|
+
from ....chat.messages import Chat
|
|
12
|
+
from ....chat.messages import SystemMessage
|
|
13
|
+
from ....chat.messages import ToolUseMessage
|
|
14
|
+
from ....chat.messages import ToolUseResultMessage
|
|
15
|
+
from ....chat.messages import UserMessage
|
|
16
|
+
from ....chat.stream.types import AiDelta
|
|
17
|
+
from ....chat.stream.types import ContentAiDelta
|
|
18
|
+
from ....chat.stream.types import ToolUseAiDelta
|
|
19
|
+
from ....chat.tools.types import Tool
|
|
20
|
+
from ....content.prepare import prepare_content_str
|
|
21
|
+
from ....tools.jsonschema import build_tool_spec_params_json_schema
|
|
22
|
+
from ....tools.types import ToolUse
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
##
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def build_ol_request_messages(chat: Chat) -> list[pt.Message]:
|
|
29
|
+
ol_msgs: list[pt.Message] = []
|
|
30
|
+
|
|
31
|
+
for _, g in itertools.groupby(chat, lambda mc_m: isinstance(mc_m, AnyAiMessage)):
|
|
32
|
+
mc_msgs = list(g)
|
|
33
|
+
|
|
34
|
+
if isinstance(mc_msgs[0], AnyAiMessage):
|
|
35
|
+
tups: list[tuple[AiMessage | None, list[ToolUseMessage]]] = []
|
|
36
|
+
for mc_msg in mc_msgs:
|
|
37
|
+
if isinstance(mc_msg, AiMessage):
|
|
38
|
+
tups.append((mc_msg, []))
|
|
39
|
+
|
|
40
|
+
elif isinstance(mc_msg, ToolUseMessage):
|
|
41
|
+
if not tups:
|
|
42
|
+
tups.append((None, []))
|
|
43
|
+
tups[-1][1].append(mc_msg)
|
|
44
|
+
|
|
45
|
+
else:
|
|
46
|
+
raise TypeError(mc_msg)
|
|
47
|
+
|
|
48
|
+
for mc_ai_msg, mc_tu_msgs in tups:
|
|
49
|
+
ol_msgs.append(pt.Message(
|
|
50
|
+
role='assistant',
|
|
51
|
+
content=check.isinstance(mc_ai_msg.c, str) if mc_ai_msg is not None else None,
|
|
52
|
+
tool_calls=[
|
|
53
|
+
pt.Message.ToolCall(
|
|
54
|
+
function=pt.Message.ToolCall.Function(
|
|
55
|
+
name=mc_tu_msg.tu.name,
|
|
56
|
+
arguments=mc_tu_msg.tu.args,
|
|
57
|
+
),
|
|
58
|
+
id=check.not_none(mc_tu_msg.tu.id),
|
|
59
|
+
)
|
|
60
|
+
for mc_tu_msg in mc_tu_msgs
|
|
61
|
+
] if mc_tu_msgs else None,
|
|
62
|
+
))
|
|
63
|
+
|
|
64
|
+
else:
|
|
65
|
+
for mc_msg in mc_msgs:
|
|
66
|
+
if isinstance(mc_msg, SystemMessage):
|
|
67
|
+
ol_msgs.append(pt.Message(
|
|
68
|
+
role='system',
|
|
69
|
+
content=check.isinstance(mc_msg.c, str),
|
|
70
|
+
))
|
|
71
|
+
|
|
72
|
+
elif isinstance(mc_msg, UserMessage):
|
|
73
|
+
ol_msgs.append(pt.Message(
|
|
74
|
+
role='user',
|
|
75
|
+
content=check.isinstance(mc_msg.c, str),
|
|
76
|
+
))
|
|
77
|
+
|
|
78
|
+
elif isinstance(mc_msg, ToolUseResultMessage):
|
|
79
|
+
ol_msgs.append(pt.Message(
|
|
80
|
+
role='tool',
|
|
81
|
+
tool_name=mc_msg.tur.name,
|
|
82
|
+
content=check.isinstance(mc_msg.tur.c, str),
|
|
83
|
+
))
|
|
84
|
+
|
|
85
|
+
else:
|
|
86
|
+
raise TypeError(mc_msg)
|
|
87
|
+
|
|
88
|
+
return ol_msgs
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def build_ol_request_tool(t: Tool) -> pt.Tool:
|
|
92
|
+
return pt.Tool(
|
|
93
|
+
function=pt.Tool.Function(
|
|
94
|
+
name=check.not_none(t.spec.name),
|
|
95
|
+
description=prepare_content_str(t.spec.desc),
|
|
96
|
+
parameters=build_tool_spec_params_json_schema(t.spec),
|
|
97
|
+
),
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def build_mc_choices_response(ol_resp: pt.ChatResponse) -> ChatChoicesResponse:
|
|
102
|
+
ol_msg = ol_resp.message
|
|
103
|
+
|
|
104
|
+
lst: list[AnyAiMessage] = []
|
|
105
|
+
|
|
106
|
+
if ol_msg.role in (None, 'assistant'):
|
|
107
|
+
if ol_msg.content is not None:
|
|
108
|
+
lst.append(AiMessage(
|
|
109
|
+
check.isinstance(ol_msg.content, str),
|
|
110
|
+
))
|
|
111
|
+
|
|
112
|
+
for ol_tc in ol_msg.tool_calls or []:
|
|
113
|
+
lst.append(ToolUseMessage(ToolUse(
|
|
114
|
+
id=ol_tc.id,
|
|
115
|
+
name=ol_tc.function.name,
|
|
116
|
+
args=ol_tc.function.arguments,
|
|
117
|
+
)))
|
|
118
|
+
|
|
119
|
+
else:
|
|
120
|
+
raise ValueError(ol_msg)
|
|
121
|
+
|
|
122
|
+
return ChatChoicesResponse([AiChoice(lst)])
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def build_mc_ai_choice_deltas(ol_resp: pt.ChatResponse) -> AiChoiceDeltas:
|
|
126
|
+
ol_msg = ol_resp.message
|
|
127
|
+
|
|
128
|
+
if ol_msg.role in (None, 'assistant'):
|
|
129
|
+
lst: list[AiDelta] = []
|
|
130
|
+
|
|
131
|
+
if ol_msg.content is not None:
|
|
132
|
+
lst.append(ContentAiDelta(ol_msg.content))
|
|
133
|
+
|
|
134
|
+
for tc in ol_msg.tool_calls or []:
|
|
135
|
+
lst.append(ToolUseAiDelta(
|
|
136
|
+
id=tc.id,
|
|
137
|
+
name=check.not_none(tc.function.name),
|
|
138
|
+
args=tc.function.arguments,
|
|
139
|
+
))
|
|
140
|
+
|
|
141
|
+
return AiChoiceDeltas(lst)
|
|
142
|
+
|
|
143
|
+
else:
|
|
144
|
+
raise ValueError(ol_msg)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# https://github.com/karpathy/nanochat/tree/9467d83cf23dcc9a9b4ca6e35103142f48a55b27
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# rustbpe
|
|
6
|
+
|
|
7
|
+
> The missing tiktoken training code
|
|
8
|
+
|
|
9
|
+
A very lightweight Rust library for training a GPT tokenizer. The issue is that the inference library [tiktoken](https://github.com/openai/tiktoken) is great, but only does inference. Separately, the huggingface [tokenizers](https://github.com/huggingface/tokenizers) library does training, but it is rather bloated and really hard to navigate because it has to support all the different historical baggage of how people dealt with tokenizers over the years. More recently, I also wrote the [minbpe](https://github.com/karpathy/minbpe) library which does both training and inference, but only in inefficient Python. Basically what I really want is a non-fancy, super simple, but still relatively efficient training code for GPT tokenizer (more efficient than minbpe, much cleaner/simpler than tokenizers), and then export the trained vocab for inference with tiktoken. Does that make sense? So here we are. There are more opportunities for optimization here, I just stopped a bit early because unlike minbpe before it, rustbpe is now simple and fast enough, and not a significant bottleneck for nanochat.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ommlds
|
|
3
|
-
Version: 0.0.0.
|
|
3
|
+
Version: 0.0.0.dev491
|
|
4
4
|
Summary: ommlds
|
|
5
5
|
Author: wrmsr
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -14,12 +14,12 @@ 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: omlish==0.0.0.
|
|
17
|
+
Requires-Dist: omlish==0.0.0.dev491
|
|
18
18
|
Provides-Extra: all
|
|
19
|
-
Requires-Dist: omdev==0.0.0.
|
|
19
|
+
Requires-Dist: omdev==0.0.0.dev491; extra == "all"
|
|
20
20
|
Requires-Dist: llama-cpp-python~=0.3; extra == "all"
|
|
21
21
|
Requires-Dist: mlx~=0.30; sys_platform == "darwin" and extra == "all"
|
|
22
|
-
Requires-Dist: mlx-lm~=0.
|
|
22
|
+
Requires-Dist: mlx-lm~=0.29; sys_platform == "darwin" and extra == "all"
|
|
23
23
|
Requires-Dist: tiktoken~=0.12; extra == "all"
|
|
24
24
|
Requires-Dist: tinygrad~=0.11; extra == "all"
|
|
25
25
|
Requires-Dist: tokenizers~=0.22; extra == "all"
|
|
@@ -38,11 +38,11 @@ Requires-Dist: mwparserfromhell~=0.7; extra == "all"
|
|
|
38
38
|
Requires-Dist: wikitextparser~=0.56; extra == "all"
|
|
39
39
|
Requires-Dist: lxml>=5.3; python_version < "3.13" and extra == "all"
|
|
40
40
|
Provides-Extra: omdev
|
|
41
|
-
Requires-Dist: omdev==0.0.0.
|
|
41
|
+
Requires-Dist: omdev==0.0.0.dev491; extra == "omdev"
|
|
42
42
|
Provides-Extra: backends
|
|
43
43
|
Requires-Dist: llama-cpp-python~=0.3; extra == "backends"
|
|
44
44
|
Requires-Dist: mlx~=0.30; sys_platform == "darwin" and extra == "backends"
|
|
45
|
-
Requires-Dist: mlx-lm~=0.
|
|
45
|
+
Requires-Dist: mlx-lm~=0.29; sys_platform == "darwin" and extra == "backends"
|
|
46
46
|
Requires-Dist: tiktoken~=0.12; extra == "backends"
|
|
47
47
|
Requires-Dist: tinygrad~=0.11; extra == "backends"
|
|
48
48
|
Requires-Dist: tokenizers~=0.22; extra == "backends"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
ommlds/.omlish-manifests.json,sha256=
|
|
2
|
-
ommlds/
|
|
1
|
+
ommlds/.omlish-manifests.json,sha256=Xz1zqDGjmcuUgaWaK454DizBTKTg5Qj8eRN_vRP-nLw,27810
|
|
2
|
+
ommlds/README.md,sha256=xhbl2n19GznXrIzAGdlX8PAYJYsOo_Zu63I7G1UFRZE,398
|
|
3
|
+
ommlds/__about__.py,sha256=cRA9AUVZmvQaibdmACDEpd5T2VWWVWtJT_zpgt9I0Wg,1900
|
|
3
4
|
ommlds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
5
|
ommlds/_hacks/__init__.py,sha256=ajfw7dMKH8UuloeQ5MSxWwgAmdWf2v8gm-K3uLP9wtY,196
|
|
5
6
|
ommlds/_hacks/funcs.py,sha256=8XseIblP7yolDUD7WQSGn1LP90IQzByVejSzphAPDyM,2861
|
|
@@ -51,8 +52,8 @@ ommlds/backends/mlx/tokenization/detokenization/bpe.py,sha256=cIw6-r-cyXTfZdyfGR
|
|
|
51
52
|
ommlds/backends/mlx/tokenization/detokenization/naive.py,sha256=6L-SvphzP1z16cmVB4QC9VraF7khE8ZcvKqIwwFqN6U,1779
|
|
52
53
|
ommlds/backends/mlx/tokenization/detokenization/spm.py,sha256=IYSnEm-C0z_o5TKLJE_Rj6P0nNd-prT6psVPKsERWAE,1751
|
|
53
54
|
ommlds/backends/ollama/__init__.py,sha256=-RtLrdEGN2da1KCf7YNs32jN-kJhT_kNVrcOv4x_J-w,101
|
|
54
|
-
ommlds/backends/ollama/_dataclasses.py,sha256=
|
|
55
|
-
ommlds/backends/ollama/protocol.py,sha256=
|
|
55
|
+
ommlds/backends/ollama/_dataclasses.py,sha256=WRJ1eKO0PDKRGkE6ZciAHbZRtDUVok3fOuat_7msPW0,188008
|
|
56
|
+
ommlds/backends/ollama/protocol.py,sha256=Zq9MTvE8moUUVqtUcuhmn_DdDELPp9xb1r3dzwxm4MI,4505
|
|
56
57
|
ommlds/backends/openai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
58
|
ommlds/backends/openai/protocol/__init__.py,sha256=S-p81JfMaS0nwdII9jyhcmj0c5fJJD5sHwphnY45WdI,1862
|
|
58
59
|
ommlds/backends/openai/protocol/_common.py,sha256=r4EXmw1fBFHjU5vbWTDvlM_fsafdIVg3d3PNw4F9m-Q,313
|
|
@@ -100,10 +101,10 @@ ommlds/backends/transformers/filecache.py,sha256=ycfswt7f4qRrPSTFRhofXZaDBuDPpyp
|
|
|
100
101
|
ommlds/backends/transformers/streamers.py,sha256=Hu_9lp_kUilKjOfs7Ixqr2NoA5FuRn2eRh8JdvaBDYc,1688
|
|
101
102
|
ommlds/cli/__init__.py,sha256=-RtLrdEGN2da1KCf7YNs32jN-kJhT_kNVrcOv4x_J-w,101
|
|
102
103
|
ommlds/cli/__main__.py,sha256=1ffCb0fcUOJMzxROJmJRXQ8PSOVYv7KrcuBtT95cf0c,140
|
|
103
|
-
ommlds/cli/_dataclasses.py,sha256=
|
|
104
|
+
ommlds/cli/_dataclasses.py,sha256=z-bFKj4I8bBufNzSPexvqdfqEmDpr7CdgqtGC-si1qg,150661
|
|
104
105
|
ommlds/cli/asyncs.py,sha256=NAMzzaZq7ORjlbbBB_Y9vcM9qoBpGf4VJNtl_3p_8G4,629
|
|
105
106
|
ommlds/cli/inject.py,sha256=CdG-Zgq3T0pDWLhHRZSqlkR4W2mS7LlCOHD2uP1llf0,610
|
|
106
|
-
ommlds/cli/main.py,sha256=
|
|
107
|
+
ommlds/cli/main.py,sha256=PQoe6vCcQ5tuYYo5cgXtb7p38K1h7BzLdg415Y9fhyc,10813
|
|
107
108
|
ommlds/cli/secrets.py,sha256=8GHlewS3yeFDfFNekaYwRm4nG9l3nd-Mc8tKl9Ma_Uo,469
|
|
108
109
|
ommlds/cli/backends/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
109
110
|
ommlds/cli/backends/catalog.py,sha256=hLcBXBCiB7eKT_2yv8kyLD5f94LV7vCcOe144URuJxs,3225
|
|
@@ -122,70 +123,85 @@ ommlds/cli/rendering/configs.py,sha256=jWpLnD24eGgPfAg_4_0jY0KKP-1bT1TxvF5ih_poA
|
|
|
122
123
|
ommlds/cli/rendering/inject.py,sha256=2lkc6oRYhM3TIwjH2mzmnmHXsZYeyNhP3ax0EzFyWrk,923
|
|
123
124
|
ommlds/cli/rendering/markdown.py,sha256=f4WN1fUW4lqxW0da7m5LS8sm9MOXenVHZ2V8pPaBL84,1801
|
|
124
125
|
ommlds/cli/rendering/raw.py,sha256=02arQUZ_vsEeTG1qgwAFdf48xD_MjQA0MIBbr2aBt5Y,2430
|
|
125
|
-
ommlds/cli/rendering/types.py,sha256=
|
|
126
|
+
ommlds/cli/rendering/types.py,sha256=y7zYLyvc91CHO1KAtYbNHTzW-ddddOjF-weO9Gw8qok,509
|
|
126
127
|
ommlds/cli/sessions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
127
128
|
ommlds/cli/sessions/base.py,sha256=diwERBpapd73Cn2T2_ctEIfhzjzJ1DTzjcExxwxccqw,464
|
|
128
129
|
ommlds/cli/sessions/inject.py,sha256=9SrtsozIhqok3jZtepKTJwpOxHkU7FrqKw6pc78mEO4,926
|
|
129
130
|
ommlds/cli/sessions/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
130
|
-
ommlds/cli/sessions/chat/configs.py,sha256=
|
|
131
|
-
ommlds/cli/sessions/chat/
|
|
132
|
-
ommlds/cli/sessions/chat/
|
|
133
|
-
ommlds/cli/sessions/chat/
|
|
134
|
-
ommlds/cli/sessions/chat/
|
|
135
|
-
ommlds/cli/sessions/chat/
|
|
136
|
-
ommlds/cli/sessions/chat/
|
|
137
|
-
ommlds/cli/sessions/chat/
|
|
138
|
-
ommlds/cli/sessions/chat/
|
|
139
|
-
ommlds/cli/sessions/chat/
|
|
140
|
-
ommlds/cli/sessions/chat/
|
|
141
|
-
ommlds/cli/sessions/chat/
|
|
142
|
-
ommlds/cli/sessions/chat/
|
|
143
|
-
ommlds/cli/sessions/chat/
|
|
144
|
-
ommlds/cli/sessions/chat/
|
|
145
|
-
ommlds/cli/sessions/chat/
|
|
146
|
-
ommlds/cli/sessions/chat/
|
|
147
|
-
ommlds/cli/sessions/chat/
|
|
148
|
-
ommlds/cli/sessions/chat/
|
|
149
|
-
ommlds/cli/sessions/chat/
|
|
150
|
-
ommlds/cli/sessions/chat/
|
|
151
|
-
ommlds/cli/sessions/chat/
|
|
152
|
-
ommlds/cli/sessions/chat/
|
|
153
|
-
ommlds/cli/sessions/chat/
|
|
154
|
-
ommlds/cli/sessions/chat/
|
|
155
|
-
ommlds/cli/sessions/chat/
|
|
156
|
-
ommlds/cli/sessions/chat/
|
|
157
|
-
ommlds/cli/sessions/chat/
|
|
158
|
-
ommlds/cli/sessions/chat/
|
|
159
|
-
ommlds/cli/sessions/chat/
|
|
160
|
-
ommlds/cli/sessions/chat/
|
|
161
|
-
ommlds/cli/sessions/chat/
|
|
162
|
-
ommlds/cli/sessions/chat/
|
|
163
|
-
ommlds/cli/sessions/chat/
|
|
164
|
-
ommlds/cli/sessions/chat/
|
|
165
|
-
ommlds/cli/sessions/chat/
|
|
166
|
-
ommlds/cli/sessions/chat/
|
|
167
|
-
ommlds/cli/sessions/chat/
|
|
168
|
-
ommlds/cli/sessions/chat/
|
|
169
|
-
ommlds/cli/sessions/chat/
|
|
170
|
-
ommlds/cli/sessions/chat/
|
|
171
|
-
ommlds/cli/sessions/chat/
|
|
172
|
-
ommlds/cli/sessions/chat/tools/
|
|
173
|
-
ommlds/cli/sessions/chat/tools/
|
|
174
|
-
ommlds/cli/sessions/chat/tools/
|
|
175
|
-
ommlds/cli/sessions/chat/tools/
|
|
176
|
-
ommlds/cli/sessions/chat/tools/
|
|
177
|
-
ommlds/cli/sessions/chat/tools/
|
|
178
|
-
ommlds/cli/sessions/chat/tools/
|
|
179
|
-
ommlds/cli/sessions/chat/tools/
|
|
180
|
-
ommlds/cli/sessions/chat/
|
|
181
|
-
ommlds/cli/sessions/chat/
|
|
182
|
-
ommlds/cli/sessions/chat/
|
|
183
|
-
ommlds/cli/sessions/chat/
|
|
184
|
-
ommlds/cli/sessions/chat/
|
|
185
|
-
ommlds/cli/sessions/chat/
|
|
186
|
-
ommlds/cli/sessions/chat/
|
|
187
|
-
ommlds/cli/sessions/chat/
|
|
188
|
-
ommlds/cli/sessions/chat/
|
|
131
|
+
ommlds/cli/sessions/chat/configs.py,sha256=SOGE25ObWhR_a7F4_rJ-YJ-wJsL_XkxvcsXj5bJN5Kc,421
|
|
132
|
+
ommlds/cli/sessions/chat/inject.py,sha256=BTrORil0zpK6jhYpBmMqpZQODueGfu89mfUjXRNn05M,855
|
|
133
|
+
ommlds/cli/sessions/chat/session.py,sha256=gjwCDh8-fDuFD5OvZpJa3C8GShOhbRNZwQv5wreGHR4,801
|
|
134
|
+
ommlds/cli/sessions/chat/drivers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
135
|
+
ommlds/cli/sessions/chat/drivers/configs.py,sha256=eKJTI1y29L6PUnE5SXDkXdPfpBFeyHxMGTrOOIdYFFk,524
|
|
136
|
+
ommlds/cli/sessions/chat/drivers/driver.py,sha256=MJSLto_wk0J_EkAL404etP4DnccY8u55QAg4J_7ip7A,1521
|
|
137
|
+
ommlds/cli/sessions/chat/drivers/inject.py,sha256=KeQeaCPj7jfPcihAF9BSBIXWYGDth_FECEv2lAgVIVI,1332
|
|
138
|
+
ommlds/cli/sessions/chat/drivers/types.py,sha256=KNDkgdX6FdihIYty5S7HHzsGPE-zdAbqFmxwyZF8CZE,124
|
|
139
|
+
ommlds/cli/sessions/chat/drivers/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
140
|
+
ommlds/cli/sessions/chat/drivers/ai/configs.py,sha256=MjuJicX53mrSHCDTpBTHLUyrovXFkKGqrVguuYbrwNg,185
|
|
141
|
+
ommlds/cli/sessions/chat/drivers/ai/events.py,sha256=VLy1OBZWWS82avZhMVUZJrOMNE3muuG9oWZtQ7FK_Po,1593
|
|
142
|
+
ommlds/cli/sessions/chat/drivers/ai/inject.py,sha256=aipgnPRDwxFKkSBU__uMNc1RVzYfmgJvfTjhaw27LQo,2748
|
|
143
|
+
ommlds/cli/sessions/chat/drivers/ai/injection.py,sha256=2O_ELMusxQsYaB2oqvzjYpZQzjshocJup7Z5unzoUIY,404
|
|
144
|
+
ommlds/cli/sessions/chat/drivers/ai/rendering.py,sha256=srDRaepttzHSn8w4Cet07bDtGiSApUO4xyhiPbuMU0A,2277
|
|
145
|
+
ommlds/cli/sessions/chat/drivers/ai/services.py,sha256=PUySl7Fz4ttElW-V6poEnvF-RaRmbjU3cHULHun5rdk,2508
|
|
146
|
+
ommlds/cli/sessions/chat/drivers/ai/tools.py,sha256=XmF-HF7OiUiqXuIgT0QuePmqnHTmpjK-lLt5WocAiws,1093
|
|
147
|
+
ommlds/cli/sessions/chat/drivers/ai/types.py,sha256=_Ees5ia0fKMr-BvKpTeryY-KXWP0bAfWrOGg2JDFpuE,913
|
|
148
|
+
ommlds/cli/sessions/chat/drivers/events/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
149
|
+
ommlds/cli/sessions/chat/drivers/events/inject.py,sha256=quPbkuhPyJ_zFpFzh5hrkqWspwk9El0a8_82r1LphIY,449
|
|
150
|
+
ommlds/cli/sessions/chat/drivers/events/injection.py,sha256=Q32VFAww9EkzkqdqrbamKuuVcfzbGol6JojNYo61jG0,326
|
|
151
|
+
ommlds/cli/sessions/chat/drivers/events/manager.py,sha256=5NTDIFBtGXMT_86CiQgXoUSHqEweFENUDSDQ8d3ouiE,348
|
|
152
|
+
ommlds/cli/sessions/chat/drivers/events/types.py,sha256=cxTq5xEzg97zsqqnQCZ8FP3UM0wj3yuvqGB3teR2YGw,655
|
|
153
|
+
ommlds/cli/sessions/chat/drivers/phases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
154
|
+
ommlds/cli/sessions/chat/drivers/phases/inject.py,sha256=m9GcCVcp1GnNKN1qwDSgTkfp3e107wXgPeEHDLbfG8s,448
|
|
155
|
+
ommlds/cli/sessions/chat/drivers/phases/injection.py,sha256=ZUFRRLp3HNhKaPBW6aiw5XFEGNkqTj8WVSlXM0kg0y0,326
|
|
156
|
+
ommlds/cli/sessions/chat/drivers/phases/manager.py,sha256=_wfc0FfL5h_5L-6hnYb3U3kiRmkGDkJu7wGj5Cgz7_Y,727
|
|
157
|
+
ommlds/cli/sessions/chat/drivers/phases/types.py,sha256=w1pAEydJYaHzSzdlqygCwKxvVZnfo_R_xJqq8wBzZsQ,512
|
|
158
|
+
ommlds/cli/sessions/chat/drivers/state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
159
|
+
ommlds/cli/sessions/chat/drivers/state/configs.py,sha256=VMrqC-2dE8lXZmT1dBgUUReS0FDQWzD0U6thSyjOOZM,192
|
|
160
|
+
ommlds/cli/sessions/chat/drivers/state/inject.py,sha256=w4kwGfvuwrmLYC4BLi0ARzJTixwv-IPoDxA1SYDzf8g,1104
|
|
161
|
+
ommlds/cli/sessions/chat/drivers/state/inmemory.py,sha256=4wX-8NA8SUTytXeUaTMaI64KBqbXMPIe2TRuI2GO0_8,872
|
|
162
|
+
ommlds/cli/sessions/chat/drivers/state/storage.py,sha256=gKUNsNj3TtH67-FOuHXrQlDsESeIYDUHPhn7unTQCx8,1447
|
|
163
|
+
ommlds/cli/sessions/chat/drivers/state/types.py,sha256=PnOvGxaWvtVeawWRAiRqfGTs-COWfBdUT6vQCzZp-3w,808
|
|
164
|
+
ommlds/cli/sessions/chat/drivers/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
165
|
+
ommlds/cli/sessions/chat/drivers/tools/configs.py,sha256=GcrFj3FJQujy3FV3SJ5z_py-P9JrzqfVimx18DSTZNc,319
|
|
166
|
+
ommlds/cli/sessions/chat/drivers/tools/confirmation.py,sha256=nmTGAYL9VSBoMYT0dqu_Hb_-vqc_60ytjtMLqw2tyzs,948
|
|
167
|
+
ommlds/cli/sessions/chat/drivers/tools/execution.py,sha256=D1A6hWm35HMAWW8KJCjMRMRIM-NUFfVFkk8uUi97Bws,1516
|
|
168
|
+
ommlds/cli/sessions/chat/drivers/tools/inject.py,sha256=zu0ikMjRHtzO_NKdEg2Ms4dYMGneOa2ZsOliCStCKqw,2334
|
|
169
|
+
ommlds/cli/sessions/chat/drivers/tools/injection.py,sha256=tP2tsF2brfpNEBDcZSaMQ5hTEodC7ijOHKkp-qToit8,1162
|
|
170
|
+
ommlds/cli/sessions/chat/drivers/tools/rendering.py,sha256=Q8uXK_AC2Rp5_FSCyg15-bg__Wt9-mUFxI6odQoa9pM,1422
|
|
171
|
+
ommlds/cli/sessions/chat/drivers/tools/fs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
172
|
+
ommlds/cli/sessions/chat/drivers/tools/fs/configs.py,sha256=hwQ3WRP6hYxjIx-m8z_ZZZ-HwiREuIpa2gRKzeqkoHk,205
|
|
173
|
+
ommlds/cli/sessions/chat/drivers/tools/fs/inject.py,sha256=unLnYOBW6PooTsoO6UuS6BtD0GC-GexKitjca1yECes,809
|
|
174
|
+
ommlds/cli/sessions/chat/drivers/tools/todo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
175
|
+
ommlds/cli/sessions/chat/drivers/tools/todo/configs.py,sha256=pcdjTKsRB4J_iBET2tcOx-32EHqtecxLg4JtelMyh1o,207
|
|
176
|
+
ommlds/cli/sessions/chat/drivers/tools/todo/inject.py,sha256=6wzNlX97MaHVtaPbVmvSh4_zU7ukVgjFTVxubUaR16w,808
|
|
177
|
+
ommlds/cli/sessions/chat/drivers/tools/weather/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
178
|
+
ommlds/cli/sessions/chat/drivers/tools/weather/configs.py,sha256=VzamzIHkTOVVEKeH5pCq3oWZdREpT2O73v0CImCerDU,210
|
|
179
|
+
ommlds/cli/sessions/chat/drivers/tools/weather/inject.py,sha256=HSB6gCp23T2HME07FzBiiFpWnloErCIO7yTWcOu5DVk,456
|
|
180
|
+
ommlds/cli/sessions/chat/drivers/tools/weather/tools.py,sha256=tGkr97D-60Lgsnjs1nSqV5BEZrTNlcaU_TFCY4ZRQyE,304
|
|
181
|
+
ommlds/cli/sessions/chat/drivers/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
182
|
+
ommlds/cli/sessions/chat/drivers/user/configs.py,sha256=tBSP2j1Bynn0Qt_S0GNUuNniMWivVSCFad3H4UCS3qY,280
|
|
183
|
+
ommlds/cli/sessions/chat/drivers/user/inject.py,sha256=LYvB2vSpcBZZ1eM9z8Hxow4uBo_d-MkESVhnZNkLJII,1394
|
|
184
|
+
ommlds/cli/sessions/chat/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
185
|
+
ommlds/cli/sessions/chat/interfaces/base.py,sha256=3z7yI-ow7037_n6VanQYZjOgKL_iRZ8FB6JP553SY7M,198
|
|
186
|
+
ommlds/cli/sessions/chat/interfaces/configs.py,sha256=toI23cp2YVT_m-l-ICwg11xeD0_wkI-NLpBRkjRJyJI,473
|
|
187
|
+
ommlds/cli/sessions/chat/interfaces/inject.py,sha256=Ip-srA7ONGF-YgbLikwfTd3O1UoxeDTMI6CnPpc6A80,493
|
|
188
|
+
ommlds/cli/sessions/chat/interfaces/bare/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
189
|
+
ommlds/cli/sessions/chat/interfaces/bare/inject.py,sha256=y_iYbVlVn1YCWLUYT0iZ7p3z8Wzfn-RWQZMOkNLKoBQ,1866
|
|
190
|
+
ommlds/cli/sessions/chat/interfaces/bare/interactive.py,sha256=oIBHkRrfLVGhPiVH_7wg79WMwJeNr8cTht20PMNxlho,1096
|
|
191
|
+
ommlds/cli/sessions/chat/interfaces/bare/oneshot.py,sha256=1TNhTtg6KwzbG8GGxrT64tg9TDFakZ32qxrsT-djTwk,388
|
|
192
|
+
ommlds/cli/sessions/chat/interfaces/bare/tools.py,sha256=_UsuoXLIvfpFP_We5DBBlhm6rwB3_cFA3lmFvpG9b-A,824
|
|
193
|
+
ommlds/cli/sessions/chat/interfaces/bare/user.py,sha256=gZgfuQAnU_MH_Awb-Ut6sJE_Di4jvquKOkBT415NmR0,877
|
|
194
|
+
ommlds/cli/sessions/chat/interfaces/textual/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
195
|
+
ommlds/cli/sessions/chat/interfaces/textual/app.py,sha256=UKaPnLUNqb8_u1L4PigJyDBfDqgk00lNU4gUogsg_0M,6465
|
|
196
|
+
ommlds/cli/sessions/chat/interfaces/textual/inject.py,sha256=dI7ZeQNVegL5MCwKJ_uNf-ZpBuUim9G84etHSkTHWOI,1672
|
|
197
|
+
ommlds/cli/sessions/chat/interfaces/textual/interface.py,sha256=tvS8ORiunBxTIkTW2YmqRRyL7p46FrVpZEeix-ez9FA,322
|
|
198
|
+
ommlds/cli/sessions/chat/interfaces/textual/styles/__init__.py,sha256=7_U5oUjwegOymeWgt6nLpFfWfjGTrlWL8m4Au8MsaFE,542
|
|
199
|
+
ommlds/cli/sessions/chat/interfaces/textual/styles/input.tcss,sha256=6aYFNxZ-GmTLirWnJcxVNPeq8YqgjS4GJDuxwXbOBhI,601
|
|
200
|
+
ommlds/cli/sessions/chat/interfaces/textual/styles/markdown.tcss,sha256=KCKlgt_EEjHVZSTwP_w2YMrR6mURLYVryOwOziAFlTw,105
|
|
201
|
+
ommlds/cli/sessions/chat/interfaces/textual/styles/messages.tcss,sha256=PpBc7IfCJyhHdsFftDY1YHb4-ccVpTlpcYxg-6NGWW0,1171
|
|
202
|
+
ommlds/cli/sessions/chat/interfaces/textual/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
203
|
+
ommlds/cli/sessions/chat/interfaces/textual/widgets/input.py,sha256=7PrKv6ZqPoDOTOE2V-Pz2hru1n1Dwz_4Fxc1eBwqdr0,944
|
|
204
|
+
ommlds/cli/sessions/chat/interfaces/textual/widgets/messages.py,sha256=8h-pCaUOpEdimZUnyWmiQiHPAwARfqCi9SosskhR7Bk,2656
|
|
189
205
|
ommlds/cli/sessions/completion/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
190
206
|
ommlds/cli/sessions/completion/configs.py,sha256=ZibOyJxIMbclzKDK_mj8jVzFJxjkyVWmo1Tb9ZnQQ1M,240
|
|
191
207
|
ommlds/cli/sessions/completion/inject.py,sha256=vk3ewhXWGemKcOllr1iG_nMz5523qEu40MI62Dlx9AQ,933
|
|
@@ -259,7 +275,8 @@ ommlds/minichain/backends/impls/llamacpp/stream.py,sha256=XMKNMGzn5dFIZCqfEQdUvy
|
|
|
259
275
|
ommlds/minichain/backends/impls/mlx/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
260
276
|
ommlds/minichain/backends/impls/mlx/chat.py,sha256=tmZZAmVg-XcbxZYGNHrKC0hiJbxW88pgEHqIEC5D2Xc,7536
|
|
261
277
|
ommlds/minichain/backends/impls/ollama/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
262
|
-
ommlds/minichain/backends/impls/ollama/chat.py,sha256=
|
|
278
|
+
ommlds/minichain/backends/impls/ollama/chat.py,sha256=xggP89xsZZ73QQnlxw7vn5G7swN10JAhVCpW1OWFf6g,5604
|
|
279
|
+
ommlds/minichain/backends/impls/ollama/protocol.py,sha256=1G5B1dtLdfOQVI32fSgzMaqN0iPv_WZkn1p6KKVgUNM,4749
|
|
263
280
|
ommlds/minichain/backends/impls/openai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
264
281
|
ommlds/minichain/backends/impls/openai/chat.py,sha256=G1IK94PwB16rYCkRos9JEuiAu1GgCK4CnZFOIShhpig,2856
|
|
265
282
|
ommlds/minichain/backends/impls/openai/completion.py,sha256=4Mi4Zvrq5fCqUd0asL3WiCbCdmxOdo0NFkoZMfdsYXY,1939
|
|
@@ -423,6 +440,7 @@ ommlds/nanochat/LICENSE,sha256=QrsJ8zmor4uQ07SWm29uS6Sv87XGFBA7Ax_M33HI93I,1072
|
|
|
423
440
|
ommlds/nanochat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
424
441
|
ommlds/nanochat/tokenizers.py,sha256=DuDLJAawl_BuwTO1Jj8ANDkqwMFh6jkV9IPjj9DMhfA,17575
|
|
425
442
|
ommlds/nanochat/rustbpe/LICENSE,sha256=QrsJ8zmor4uQ07SWm29uS6Sv87XGFBA7Ax_M33HI93I,1072
|
|
443
|
+
ommlds/nanochat/rustbpe/README.md,sha256=JG_u4gU2Yb5e4vqdf_4SWUgj82RRCygomC1vh4bBFDY,1245
|
|
426
444
|
ommlds/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
427
445
|
ommlds/server/__main__.py,sha256=morlItVl-0_MDK6xk2VKhqOtA8oQk0SoWOWEqcgqXTw,155
|
|
428
446
|
ommlds/server/cli.py,sha256=gCN__45IXjCtk-tWwO2hr8vs5K-R0e1auNWdIc7d6_U,1825
|
|
@@ -449,9 +467,9 @@ ommlds/wiki/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
|
449
467
|
ommlds/wiki/utils/io.py,sha256=UKgDJGtmpnWvIqVd2mJc2QNPOqlToEY1GEveNp6_pMo,7088
|
|
450
468
|
ommlds/wiki/utils/progress.py,sha256=EhvKcMFYtsarCQhIahlO6f0SboyAKP3UwUyrnVnP-Vk,3222
|
|
451
469
|
ommlds/wiki/utils/xml.py,sha256=sNJNkZ9rT8B-kJMO6bRz8J1USy4fyPx0m2PwTX7vxYY,3846
|
|
452
|
-
ommlds-0.0.0.
|
|
453
|
-
ommlds-0.0.0.
|
|
454
|
-
ommlds-0.0.0.
|
|
455
|
-
ommlds-0.0.0.
|
|
456
|
-
ommlds-0.0.0.
|
|
457
|
-
ommlds-0.0.0.
|
|
470
|
+
ommlds-0.0.0.dev491.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
|
471
|
+
ommlds-0.0.0.dev491.dist-info/METADATA,sha256=5AhDRw276qD3ClTCg_Wh8x4iyQ-LhrVpZ8K3BRGAOhI,3493
|
|
472
|
+
ommlds-0.0.0.dev491.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
473
|
+
ommlds-0.0.0.dev491.dist-info/entry_points.txt,sha256=Z5YWtX7ClfiCKdW-dd_CSVvM0h4yQpJPi-2G3q6gNFo,35
|
|
474
|
+
ommlds-0.0.0.dev491.dist-info/top_level.txt,sha256=Rbnk5d5wi58vnAXx13WFZqdQ4VX8hBCS2hEL3WeXOhY,7
|
|
475
|
+
ommlds-0.0.0.dev491.dist-info/RECORD,,
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
from omlish import inject as inj
|
|
2
|
-
from omlish import lang
|
|
3
|
-
|
|
4
|
-
from ...... import minichain as mc
|
|
5
|
-
from ...phases.injection import phase_callbacks
|
|
6
|
-
from ...phases.types import ChatPhase
|
|
7
|
-
from ...phases.types import ChatPhaseCallback
|
|
8
|
-
from .configs import UserConfig
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
with lang.auto_proxy_import(globals()):
|
|
12
|
-
from ..state import types as _state
|
|
13
|
-
from . import oneshot as _oneshot
|
|
14
|
-
from . import types as _types
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def bind_user(cfg: UserConfig = UserConfig()) -> inj.Elements:
|
|
21
|
-
els: list[inj.Elemental] = []
|
|
22
|
-
|
|
23
|
-
# FIXME: barf
|
|
24
|
-
if cfg.initial_system_content is not None:
|
|
25
|
-
async def add_initial_system_content(cm: '_state.ChatStateManager') -> None:
|
|
26
|
-
await cm.extend_chat([mc.SystemMessage(cfg.initial_system_content)])
|
|
27
|
-
|
|
28
|
-
els.append(phase_callbacks().bind_item(to_fn=lang.typed_lambda(cm=_state.ChatStateManager)(
|
|
29
|
-
lambda cm: ChatPhaseCallback(ChatPhase.STARTED, lambda: add_initial_system_content(cm)),
|
|
30
|
-
)))
|
|
31
|
-
|
|
32
|
-
if cfg.interactive:
|
|
33
|
-
if cfg.initial_user_content is not None:
|
|
34
|
-
async def add_initial_user_content(cm: '_state.ChatStateManager') -> None:
|
|
35
|
-
await cm.extend_chat([mc.UserMessage(cfg.initial_user_content)])
|
|
36
|
-
|
|
37
|
-
els.append(phase_callbacks().bind_item(to_fn=lang.typed_lambda(cm=_state.ChatStateManager)(
|
|
38
|
-
lambda cm: ChatPhaseCallback(ChatPhase.STARTED, lambda: add_initial_user_content(cm)),
|
|
39
|
-
)))
|
|
40
|
-
|
|
41
|
-
raise NotImplementedError
|
|
42
|
-
|
|
43
|
-
else:
|
|
44
|
-
if cfg.initial_user_content is None:
|
|
45
|
-
raise ValueError('Initial user content is required for non-interactive chat')
|
|
46
|
-
|
|
47
|
-
els.extend([
|
|
48
|
-
inj.bind(_oneshot.OneshotUserChatInputInitialChat, to_const=[mc.UserMessage(cfg.initial_user_content)]),
|
|
49
|
-
inj.bind(_types.UserChatInput, to_ctor=_oneshot.OneshotUserChatInput, singleton=True),
|
|
50
|
-
])
|
|
51
|
-
|
|
52
|
-
return inj.as_elements(*els)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import typing as ta
|
|
2
|
-
|
|
3
|
-
from ...... import minichain as mc
|
|
4
|
-
from .types import UserChatInput
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
OneshotUserChatInputInitialChat = ta.NewType('OneshotUserChatInputInitialChat', mc.UserChat)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class OneshotUserChatInput(UserChatInput):
|
|
14
|
-
def __init__(
|
|
15
|
-
self,
|
|
16
|
-
initial_chat: OneshotUserChatInputInitialChat,
|
|
17
|
-
) -> None:
|
|
18
|
-
super().__init__()
|
|
19
|
-
|
|
20
|
-
self._pending_chat: mc.UserChat | None = initial_chat
|
|
21
|
-
|
|
22
|
-
async def get_next_user_messages(self) -> 'mc.UserChat':
|
|
23
|
-
ret = self._pending_chat
|
|
24
|
-
self._pending_chat = None
|
|
25
|
-
return ret or []
|