ommlds 0.0.0.dev440__py3-none-any.whl → 0.0.0.dev480__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 +332 -35
- ommlds/__about__.py +15 -9
- ommlds/_hacks/__init__.py +4 -0
- ommlds/_hacks/funcs.py +110 -0
- ommlds/_hacks/names.py +158 -0
- ommlds/_hacks/params.py +73 -0
- ommlds/_hacks/patches.py +0 -3
- ommlds/backends/anthropic/protocol/_marshal.py +2 -2
- ommlds/backends/anthropic/protocol/sse/_marshal.py +1 -1
- ommlds/backends/anthropic/protocol/sse/assemble.py +23 -7
- ommlds/backends/anthropic/protocol/sse/events.py +13 -0
- ommlds/backends/anthropic/protocol/types.py +30 -9
- ommlds/backends/google/protocol/__init__.py +3 -0
- ommlds/backends/google/protocol/_marshal.py +16 -0
- ommlds/backends/google/protocol/types.py +626 -0
- ommlds/backends/groq/_marshal.py +23 -0
- ommlds/backends/groq/protocol.py +249 -0
- ommlds/backends/mlx/generation.py +1 -1
- ommlds/backends/mlx/loading.py +58 -1
- ommlds/backends/ollama/__init__.py +0 -0
- ommlds/backends/ollama/protocol.py +170 -0
- ommlds/backends/openai/protocol/__init__.py +9 -28
- ommlds/backends/openai/protocol/_common.py +18 -0
- ommlds/backends/openai/protocol/_marshal.py +27 -0
- ommlds/backends/openai/protocol/chatcompletion/chunk.py +58 -31
- ommlds/backends/openai/protocol/chatcompletion/contentpart.py +49 -44
- ommlds/backends/openai/protocol/chatcompletion/message.py +55 -43
- ommlds/backends/openai/protocol/chatcompletion/request.py +114 -66
- ommlds/backends/openai/protocol/chatcompletion/response.py +71 -45
- ommlds/backends/openai/protocol/chatcompletion/responseformat.py +27 -20
- ommlds/backends/openai/protocol/chatcompletion/tokenlogprob.py +16 -7
- ommlds/backends/openai/protocol/completionusage.py +24 -15
- ommlds/backends/tavily/__init__.py +0 -0
- ommlds/backends/tavily/protocol.py +301 -0
- ommlds/backends/tinygrad/models/llama3/__init__.py +22 -14
- ommlds/backends/transformers/__init__.py +0 -0
- ommlds/backends/transformers/filecache.py +109 -0
- ommlds/backends/transformers/streamers.py +73 -0
- ommlds/cli/asyncs.py +30 -0
- ommlds/cli/backends/catalog.py +93 -0
- ommlds/cli/backends/configs.py +9 -0
- ommlds/cli/backends/inject.py +31 -36
- ommlds/cli/backends/injection.py +16 -0
- ommlds/cli/backends/types.py +46 -0
- ommlds/cli/content/__init__.py +0 -0
- ommlds/cli/content/messages.py +34 -0
- ommlds/cli/content/strings.py +42 -0
- ommlds/cli/inject.py +15 -32
- ommlds/cli/inputs/__init__.py +0 -0
- ommlds/cli/inputs/asyncs.py +32 -0
- ommlds/cli/inputs/sync.py +75 -0
- ommlds/cli/main.py +270 -110
- ommlds/cli/rendering/__init__.py +0 -0
- ommlds/cli/rendering/configs.py +9 -0
- ommlds/cli/rendering/inject.py +31 -0
- ommlds/cli/rendering/markdown.py +52 -0
- ommlds/cli/rendering/raw.py +73 -0
- ommlds/cli/rendering/types.py +21 -0
- ommlds/cli/secrets.py +21 -0
- ommlds/cli/sessions/base.py +1 -1
- ommlds/cli/sessions/chat/chat/__init__.py +0 -0
- ommlds/cli/sessions/chat/chat/ai/__init__.py +0 -0
- ommlds/cli/sessions/chat/chat/ai/configs.py +11 -0
- ommlds/cli/sessions/chat/chat/ai/inject.py +74 -0
- ommlds/cli/sessions/chat/chat/ai/injection.py +14 -0
- ommlds/cli/sessions/chat/chat/ai/rendering.py +70 -0
- ommlds/cli/sessions/chat/chat/ai/services.py +79 -0
- ommlds/cli/sessions/chat/chat/ai/tools.py +44 -0
- ommlds/cli/sessions/chat/chat/ai/types.py +28 -0
- ommlds/cli/sessions/chat/chat/state/__init__.py +0 -0
- ommlds/cli/sessions/chat/chat/state/configs.py +11 -0
- ommlds/cli/sessions/chat/chat/state/inject.py +36 -0
- ommlds/cli/sessions/chat/chat/state/inmemory.py +33 -0
- ommlds/cli/sessions/chat/chat/state/storage.py +52 -0
- ommlds/cli/sessions/chat/chat/state/types.py +38 -0
- ommlds/cli/sessions/chat/chat/user/__init__.py +0 -0
- ommlds/cli/sessions/chat/chat/user/configs.py +17 -0
- ommlds/cli/sessions/chat/chat/user/inject.py +62 -0
- ommlds/cli/sessions/chat/chat/user/interactive.py +31 -0
- ommlds/cli/sessions/chat/chat/user/oneshot.py +25 -0
- ommlds/cli/sessions/chat/chat/user/types.py +15 -0
- ommlds/cli/sessions/chat/configs.py +27 -0
- ommlds/cli/sessions/chat/driver.py +43 -0
- ommlds/cli/sessions/chat/inject.py +33 -65
- ommlds/cli/sessions/chat/phases/__init__.py +0 -0
- ommlds/cli/sessions/chat/phases/inject.py +27 -0
- ommlds/cli/sessions/chat/phases/injection.py +14 -0
- ommlds/cli/sessions/chat/phases/manager.py +29 -0
- ommlds/cli/sessions/chat/phases/types.py +29 -0
- ommlds/cli/sessions/chat/session.py +27 -0
- ommlds/cli/sessions/chat/tools/__init__.py +0 -0
- ommlds/cli/sessions/chat/tools/configs.py +22 -0
- ommlds/cli/sessions/chat/tools/confirmation.py +46 -0
- ommlds/cli/sessions/chat/tools/execution.py +66 -0
- ommlds/cli/sessions/chat/tools/fs/__init__.py +0 -0
- ommlds/cli/sessions/chat/tools/fs/configs.py +12 -0
- ommlds/cli/sessions/chat/tools/fs/inject.py +35 -0
- ommlds/cli/sessions/chat/tools/inject.py +88 -0
- ommlds/cli/sessions/chat/tools/injection.py +44 -0
- ommlds/cli/sessions/chat/tools/rendering.py +58 -0
- ommlds/cli/sessions/chat/tools/todo/__init__.py +0 -0
- ommlds/cli/sessions/chat/tools/todo/configs.py +12 -0
- ommlds/cli/sessions/chat/tools/todo/inject.py +31 -0
- ommlds/cli/sessions/chat/tools/weather/__init__.py +0 -0
- ommlds/cli/sessions/chat/tools/weather/configs.py +12 -0
- ommlds/cli/sessions/chat/tools/weather/inject.py +22 -0
- ommlds/cli/{tools/weather.py → sessions/chat/tools/weather/tools.py} +1 -1
- ommlds/cli/sessions/completion/configs.py +21 -0
- ommlds/cli/sessions/completion/inject.py +42 -0
- ommlds/cli/sessions/completion/session.py +35 -0
- ommlds/cli/sessions/embedding/configs.py +21 -0
- ommlds/cli/sessions/embedding/inject.py +42 -0
- ommlds/cli/sessions/embedding/session.py +33 -0
- ommlds/cli/sessions/inject.py +28 -11
- ommlds/cli/state/__init__.py +0 -0
- ommlds/cli/state/inject.py +28 -0
- ommlds/cli/{state.py → state/storage.py} +41 -24
- ommlds/minichain/__init__.py +84 -24
- ommlds/minichain/_marshal.py +49 -9
- ommlds/minichain/_typedvalues.py +2 -4
- ommlds/minichain/backends/catalogs/base.py +20 -1
- ommlds/minichain/backends/catalogs/simple.py +2 -2
- ommlds/minichain/backends/catalogs/strings.py +10 -8
- ommlds/minichain/backends/impls/anthropic/chat.py +65 -27
- ommlds/minichain/backends/impls/anthropic/names.py +10 -8
- ommlds/minichain/backends/impls/anthropic/protocol.py +109 -0
- ommlds/minichain/backends/impls/anthropic/stream.py +111 -43
- ommlds/minichain/backends/impls/duckduckgo/search.py +1 -1
- ommlds/minichain/backends/impls/dummy/__init__.py +0 -0
- ommlds/minichain/backends/impls/dummy/chat.py +69 -0
- ommlds/minichain/backends/impls/google/chat.py +114 -22
- ommlds/minichain/backends/impls/google/search.py +7 -2
- ommlds/minichain/backends/impls/google/stream.py +219 -0
- ommlds/minichain/backends/impls/google/tools.py +149 -0
- ommlds/minichain/backends/impls/groq/__init__.py +0 -0
- ommlds/minichain/backends/impls/groq/chat.py +75 -0
- ommlds/minichain/backends/impls/groq/names.py +48 -0
- ommlds/minichain/backends/impls/groq/protocol.py +143 -0
- ommlds/minichain/backends/impls/groq/stream.py +125 -0
- ommlds/minichain/backends/impls/llamacpp/chat.py +33 -18
- ommlds/minichain/backends/impls/llamacpp/completion.py +1 -1
- ommlds/minichain/backends/impls/llamacpp/format.py +4 -2
- ommlds/minichain/backends/impls/llamacpp/stream.py +37 -20
- ommlds/minichain/backends/impls/mistral.py +20 -5
- ommlds/minichain/backends/impls/mlx/chat.py +96 -22
- ommlds/minichain/backends/impls/ollama/__init__.py +0 -0
- ommlds/minichain/backends/impls/ollama/chat.py +199 -0
- ommlds/minichain/backends/impls/openai/chat.py +18 -8
- ommlds/minichain/backends/impls/openai/completion.py +10 -3
- ommlds/minichain/backends/impls/openai/embedding.py +10 -3
- ommlds/minichain/backends/impls/openai/format.py +131 -106
- ommlds/minichain/backends/impls/openai/names.py +31 -5
- ommlds/minichain/backends/impls/openai/stream.py +43 -25
- ommlds/minichain/backends/impls/tavily.py +66 -0
- ommlds/minichain/backends/impls/tinygrad/chat.py +23 -16
- ommlds/minichain/backends/impls/transformers/sentence.py +1 -1
- ommlds/minichain/backends/impls/transformers/tokens.py +1 -1
- ommlds/minichain/backends/impls/transformers/transformers.py +155 -34
- ommlds/minichain/backends/strings/parsing.py +1 -1
- ommlds/minichain/backends/strings/resolving.py +4 -1
- ommlds/minichain/chat/_marshal.py +16 -9
- ommlds/minichain/chat/choices/adapters.py +4 -4
- ommlds/minichain/chat/choices/services.py +1 -1
- ommlds/minichain/chat/choices/stream/__init__.py +0 -0
- ommlds/minichain/chat/choices/stream/adapters.py +35 -0
- ommlds/minichain/chat/choices/stream/joining.py +31 -0
- ommlds/minichain/chat/choices/stream/services.py +45 -0
- ommlds/minichain/chat/choices/stream/types.py +43 -0
- ommlds/minichain/chat/choices/types.py +2 -2
- ommlds/minichain/chat/history.py +3 -3
- ommlds/minichain/chat/messages.py +55 -19
- ommlds/minichain/chat/services.py +3 -3
- ommlds/minichain/chat/stream/_marshal.py +16 -0
- ommlds/minichain/chat/stream/joining.py +85 -0
- ommlds/minichain/chat/stream/services.py +15 -21
- ommlds/minichain/chat/stream/types.py +32 -19
- ommlds/minichain/chat/tools/execution.py +8 -7
- ommlds/minichain/chat/tools/ids.py +9 -15
- ommlds/minichain/chat/tools/parsing.py +17 -26
- ommlds/minichain/chat/transforms/base.py +29 -38
- ommlds/minichain/chat/transforms/metadata.py +30 -4
- ommlds/minichain/chat/transforms/services.py +9 -11
- ommlds/minichain/content/_marshal.py +44 -20
- ommlds/minichain/content/json.py +13 -0
- ommlds/minichain/content/materialize.py +14 -21
- ommlds/minichain/content/prepare.py +4 -0
- ommlds/minichain/content/transforms/interleave.py +1 -1
- ommlds/minichain/content/transforms/squeeze.py +1 -1
- ommlds/minichain/content/transforms/stringify.py +1 -1
- ommlds/minichain/json.py +20 -0
- ommlds/minichain/lib/code/__init__.py +0 -0
- ommlds/minichain/lib/code/prompts.py +6 -0
- ommlds/minichain/lib/fs/binfiles.py +108 -0
- ommlds/minichain/lib/fs/context.py +126 -0
- ommlds/minichain/lib/fs/errors.py +101 -0
- ommlds/minichain/lib/fs/suggestions.py +36 -0
- ommlds/minichain/lib/fs/tools/__init__.py +0 -0
- ommlds/minichain/lib/fs/tools/edit.py +104 -0
- ommlds/minichain/lib/fs/tools/ls.py +38 -0
- ommlds/minichain/lib/fs/tools/read.py +115 -0
- ommlds/minichain/lib/fs/tools/recursivels/__init__.py +0 -0
- ommlds/minichain/lib/fs/tools/recursivels/execution.py +40 -0
- ommlds/minichain/lib/todo/__init__.py +0 -0
- ommlds/minichain/lib/todo/context.py +54 -0
- ommlds/minichain/lib/todo/tools/__init__.py +0 -0
- ommlds/minichain/lib/todo/tools/read.py +44 -0
- ommlds/minichain/lib/todo/tools/write.py +335 -0
- ommlds/minichain/lib/todo/types.py +60 -0
- ommlds/minichain/llms/_marshal.py +25 -17
- ommlds/minichain/llms/types.py +4 -0
- ommlds/minichain/registries/globals.py +18 -4
- ommlds/minichain/resources.py +66 -43
- ommlds/minichain/search.py +1 -1
- ommlds/minichain/services/_marshal.py +46 -39
- ommlds/minichain/services/facades.py +3 -3
- ommlds/minichain/services/services.py +1 -1
- ommlds/minichain/standard.py +8 -0
- ommlds/minichain/stream/services.py +152 -38
- ommlds/minichain/stream/wrap.py +22 -24
- ommlds/minichain/tools/_marshal.py +1 -1
- ommlds/minichain/tools/execution/catalog.py +2 -1
- ommlds/minichain/tools/execution/context.py +34 -14
- ommlds/minichain/tools/execution/errors.py +15 -0
- ommlds/minichain/tools/execution/executors.py +8 -3
- ommlds/minichain/tools/execution/reflect.py +40 -5
- ommlds/minichain/tools/fns.py +46 -9
- ommlds/minichain/tools/jsonschema.py +14 -5
- ommlds/minichain/tools/reflect.py +54 -18
- ommlds/minichain/tools/types.py +33 -1
- ommlds/minichain/utils.py +27 -0
- ommlds/minichain/vectors/_marshal.py +11 -10
- ommlds/nanochat/LICENSE +21 -0
- ommlds/nanochat/__init__.py +0 -0
- ommlds/nanochat/rustbpe/LICENSE +21 -0
- ommlds/nanochat/tokenizers.py +406 -0
- ommlds/server/server.py +3 -3
- ommlds/specs/__init__.py +0 -0
- ommlds/specs/mcp/__init__.py +0 -0
- ommlds/specs/mcp/_marshal.py +23 -0
- ommlds/specs/mcp/protocol.py +266 -0
- ommlds/tools/git.py +27 -10
- ommlds/tools/ocr.py +8 -9
- ommlds/wiki/analyze.py +2 -2
- ommlds/wiki/text/mfh.py +1 -5
- ommlds/wiki/text/wtp.py +1 -3
- ommlds/wiki/utils/xml.py +5 -5
- {ommlds-0.0.0.dev440.dist-info → ommlds-0.0.0.dev480.dist-info}/METADATA +24 -21
- ommlds-0.0.0.dev480.dist-info/RECORD +427 -0
- ommlds/cli/backends/standard.py +0 -20
- ommlds/cli/sessions/chat/base.py +0 -42
- ommlds/cli/sessions/chat/interactive.py +0 -73
- ommlds/cli/sessions/chat/printing.py +0 -96
- ommlds/cli/sessions/chat/prompt.py +0 -143
- ommlds/cli/sessions/chat/state.py +0 -109
- ommlds/cli/sessions/chat/tools.py +0 -91
- ommlds/cli/sessions/completion/completion.py +0 -44
- ommlds/cli/sessions/embedding/embedding.py +0 -42
- ommlds/cli/tools/config.py +0 -13
- ommlds/cli/tools/inject.py +0 -64
- ommlds/minichain/chat/stream/adapters.py +0 -69
- ommlds/minichain/lib/fs/ls/execution.py +0 -32
- ommlds-0.0.0.dev440.dist-info/RECORD +0 -303
- /ommlds/{cli/tools → backends/google}/__init__.py +0 -0
- /ommlds/{minichain/lib/fs/ls → backends/groq}/__init__.py +0 -0
- /ommlds/{huggingface.py → backends/huggingface.py} +0 -0
- /ommlds/minichain/lib/fs/{ls → tools/recursivels}/rendering.py +0 -0
- /ommlds/minichain/lib/fs/{ls → tools/recursivels}/running.py +0 -0
- {ommlds-0.0.0.dev440.dist-info → ommlds-0.0.0.dev480.dist-info}/WHEEL +0 -0
- {ommlds-0.0.0.dev440.dist-info → ommlds-0.0.0.dev480.dist-info}/entry_points.txt +0 -0
- {ommlds-0.0.0.dev440.dist-info → ommlds-0.0.0.dev480.dist-info}/licenses/LICENSE +0 -0
- {ommlds-0.0.0.dev440.dist-info → ommlds-0.0.0.dev480.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import typing as ta
|
|
2
2
|
|
|
3
|
+
from omlish import dataclasses as dc
|
|
4
|
+
from omlish import lang
|
|
5
|
+
|
|
6
|
+
from .._common import _set_class_marshal_options
|
|
3
7
|
from ..completionusage import CompletionUsage
|
|
4
8
|
from .tokenlogprob import ChatCompletionTokenLogprob
|
|
5
9
|
|
|
@@ -7,84 +11,106 @@ from .tokenlogprob import ChatCompletionTokenLogprob
|
|
|
7
11
|
##
|
|
8
12
|
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
15
|
+
@_set_class_marshal_options
|
|
16
|
+
class ChatCompletionResponseMessage(lang.Final):
|
|
17
|
+
content: str | None = None
|
|
18
|
+
refusal: str | None = None
|
|
19
|
+
role: ta.Literal['assistant'] = dc.xfield('assistant', repr=False)
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
22
|
+
@_set_class_marshal_options
|
|
23
|
+
class Annotation(lang.Final):
|
|
24
|
+
type: ta.Literal['url_citation'] = dc.xfield('url_citation', repr=False)
|
|
20
25
|
|
|
26
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
27
|
+
@_set_class_marshal_options
|
|
28
|
+
class UrlCitation(lang.Final):
|
|
29
|
+
end_index: int
|
|
30
|
+
start_index: int
|
|
31
|
+
title: str
|
|
32
|
+
url: str
|
|
21
33
|
|
|
22
|
-
|
|
34
|
+
url_citation: UrlCitation
|
|
23
35
|
|
|
36
|
+
annotations: ta.Sequence[Annotation] | None = None
|
|
24
37
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
39
|
+
@_set_class_marshal_options
|
|
40
|
+
class Audio(lang.Final):
|
|
41
|
+
id: str
|
|
42
|
+
data: str
|
|
43
|
+
expires_at: int
|
|
44
|
+
transcript: str
|
|
30
45
|
|
|
46
|
+
audio: Audio | None = None
|
|
31
47
|
|
|
32
|
-
|
|
48
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
49
|
+
@_set_class_marshal_options
|
|
50
|
+
class ToolCall(lang.Final):
|
|
51
|
+
id: str
|
|
33
52
|
|
|
53
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
54
|
+
@_set_class_marshal_options
|
|
55
|
+
class Function(lang.Final):
|
|
56
|
+
arguments: str
|
|
57
|
+
name: str
|
|
34
58
|
|
|
35
|
-
|
|
36
|
-
arguments: str
|
|
37
|
-
name: str
|
|
59
|
+
function: Function
|
|
38
60
|
|
|
61
|
+
type: ta.Literal['function'] = dc.xfield('function', repr=False)
|
|
39
62
|
|
|
40
|
-
|
|
41
|
-
id: str
|
|
42
|
-
function: ChatCompletionResponseMessageToolCallFunction
|
|
43
|
-
type: ta.Literal['function']
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class ChatCompletionResponseMessage(ta.TypedDict, total=False):
|
|
47
|
-
content: str
|
|
48
|
-
refusal: str
|
|
49
|
-
role: ta.Required[ta.Literal['assistant']]
|
|
50
|
-
annotations: ta.Sequence[ChatCompletionResponseAnnotation]
|
|
51
|
-
audio: ChatCompletionResponseAudio
|
|
52
|
-
tool_calls: ta.Sequence[ChatCompletionResponseMessageToolCall]
|
|
63
|
+
tool_calls: ta.Sequence[ToolCall] | None = None
|
|
53
64
|
|
|
54
65
|
|
|
55
66
|
#
|
|
56
67
|
|
|
57
68
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class ChatCompletionResponseChoice(ta.TypedDict):
|
|
69
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
70
|
+
@_set_class_marshal_options
|
|
71
|
+
class ChatCompletionResponseChoice(lang.Final):
|
|
64
72
|
finish_reason: ta.Literal[
|
|
65
73
|
'stop',
|
|
66
74
|
'length',
|
|
67
75
|
'tool_calls',
|
|
68
76
|
'content_filter',
|
|
69
77
|
]
|
|
78
|
+
|
|
70
79
|
index: int
|
|
71
|
-
|
|
80
|
+
|
|
81
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
82
|
+
@_set_class_marshal_options
|
|
83
|
+
class Logprobs(lang.Final):
|
|
84
|
+
content: ta.Sequence[ChatCompletionTokenLogprob] | None = None
|
|
85
|
+
refusal: ta.Sequence[ChatCompletionTokenLogprob] | None = None
|
|
86
|
+
|
|
87
|
+
logprobs: Logprobs | None = None
|
|
88
|
+
|
|
72
89
|
message: ChatCompletionResponseMessage
|
|
73
90
|
|
|
74
91
|
|
|
75
92
|
#
|
|
76
93
|
|
|
77
94
|
|
|
78
|
-
|
|
95
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
96
|
+
@_set_class_marshal_options
|
|
97
|
+
class ChatCompletionResponse(lang.Final):
|
|
79
98
|
id: str
|
|
99
|
+
|
|
80
100
|
choices: ta.Sequence[ChatCompletionResponseChoice]
|
|
101
|
+
|
|
81
102
|
created: int
|
|
103
|
+
|
|
82
104
|
model: str
|
|
83
|
-
|
|
84
|
-
|
|
105
|
+
|
|
106
|
+
object: ta.Literal['chat.completion'] = dc.xfield('chat.completion', repr=False)
|
|
107
|
+
|
|
108
|
+
service_tier: ta.Literal[
|
|
85
109
|
'auto',
|
|
86
110
|
'default',
|
|
87
111
|
'flex',
|
|
88
|
-
]
|
|
89
|
-
|
|
90
|
-
|
|
112
|
+
] | None = None
|
|
113
|
+
|
|
114
|
+
system_fingerprint: str | None = None
|
|
115
|
+
|
|
116
|
+
usage: CompletionUsage | None = None
|
|
@@ -1,41 +1,48 @@
|
|
|
1
|
-
# ruff: noqa: UP007 UP045
|
|
2
1
|
import typing as ta
|
|
3
2
|
|
|
3
|
+
from omlish import dataclasses as dc
|
|
4
|
+
from omlish import lang
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
from .._common import _set_class_marshal_options
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
type: ta.Literal['text']
|
|
9
|
+
##
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
class ChatCompletionResponseFormat(lang.Abstract, lang.Sealed):
|
|
13
|
+
pass
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
name: ta.Required[str]
|
|
17
|
-
description: str
|
|
18
|
-
schema: ta.Mapping[str, ta.Any]
|
|
19
|
-
strict: bool
|
|
16
|
+
#
|
|
20
17
|
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
20
|
+
@_set_class_marshal_options
|
|
21
|
+
class TextChatCompletionResponseFormat(ChatCompletionResponseFormat, lang.Final):
|
|
22
|
+
pass
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
#
|
|
28
26
|
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
29
|
+
@_set_class_marshal_options
|
|
30
|
+
class JsonSchemaChatCompletionResponseFormat(ChatCompletionResponseFormat, lang.Final):
|
|
31
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
32
|
+
@_set_class_marshal_options
|
|
33
|
+
class JsonSchema(lang.Final):
|
|
34
|
+
name: str
|
|
35
|
+
description: str | None = None
|
|
36
|
+
schema: ta.Mapping[str, ta.Any] | None = None
|
|
37
|
+
strict: bool | None = None
|
|
38
|
+
|
|
39
|
+
json_schema: JsonSchema
|
|
32
40
|
|
|
33
41
|
|
|
34
42
|
#
|
|
35
43
|
|
|
36
44
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
]
|
|
45
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
46
|
+
@_set_class_marshal_options
|
|
47
|
+
class JsonObjectChatCompletionResponseFormat(ChatCompletionResponseFormat, lang.Final):
|
|
48
|
+
pass
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import typing as ta
|
|
2
2
|
|
|
3
|
+
from omlish import dataclasses as dc
|
|
4
|
+
from omlish import lang
|
|
5
|
+
|
|
6
|
+
from .._common import _set_class_marshal_options
|
|
7
|
+
|
|
3
8
|
|
|
4
9
|
##
|
|
5
10
|
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
13
|
+
@_set_class_marshal_options
|
|
14
|
+
class ChatCompletionTokenLogprob(lang.Final):
|
|
8
15
|
token: str
|
|
9
|
-
bytes: ta.
|
|
16
|
+
bytes: ta.Sequence[int] | None = None
|
|
10
17
|
logprob: float
|
|
11
18
|
|
|
19
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
20
|
+
@_set_class_marshal_options
|
|
21
|
+
class TopLogprob(lang.Final):
|
|
22
|
+
token: str
|
|
23
|
+
bytes: ta.Sequence[int] | None = None
|
|
24
|
+
logprob: float
|
|
12
25
|
|
|
13
|
-
|
|
14
|
-
token: str
|
|
15
|
-
bytes: ta.NotRequired[ta.Sequence[int]]
|
|
16
|
-
logprob: float
|
|
17
|
-
top_logprobs: ta.Sequence[ChatCompletionTokenLogprobTopLogprob]
|
|
26
|
+
top_logprobs: ta.Sequence[TopLogprob]
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
from omlish import dataclasses as dc
|
|
2
|
+
from omlish import lang
|
|
3
|
+
|
|
4
|
+
from ._common import _set_class_marshal_options
|
|
2
5
|
|
|
3
6
|
|
|
4
7
|
##
|
|
5
8
|
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
11
|
+
@_set_class_marshal_options
|
|
12
|
+
class CompletionUsage(lang.Final):
|
|
13
|
+
completion_tokens: int
|
|
14
|
+
prompt_tokens: int
|
|
15
|
+
total_tokens: int
|
|
12
16
|
|
|
17
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
18
|
+
@_set_class_marshal_options
|
|
19
|
+
class CompletionTokensDetails(lang.Final):
|
|
20
|
+
accepted_prediction_tokens: int | None = None
|
|
21
|
+
audio_tokens: int | None = None
|
|
22
|
+
reasoning_tokens: int | None = None
|
|
23
|
+
rejected_prediction_tokens: int | None = None
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
audio_tokens: int
|
|
16
|
-
cached_tokens: int
|
|
25
|
+
completion_tokens_details: CompletionTokensDetails | None = None
|
|
17
26
|
|
|
27
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
28
|
+
@_set_class_marshal_options
|
|
29
|
+
class PromptTokensDetails(lang.Final):
|
|
30
|
+
audio_tokens: int | None = None
|
|
31
|
+
cached_tokens: int | None = None
|
|
18
32
|
|
|
19
|
-
|
|
20
|
-
completion_tokens: int
|
|
21
|
-
prompt_tokens: int
|
|
22
|
-
total_tokens: int
|
|
23
|
-
completion_tokens_details: ta.NotRequired[CompletionUsageCompletionTokensDetails]
|
|
24
|
-
prompt_tokens_details: ta.NotRequired[CompletionUsagePromptTokensDetails]
|
|
33
|
+
prompt_tokens_details: PromptTokensDetails | None = None
|
|
File without changes
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"""
|
|
2
|
+
https://docs.tavily.com/documentation/api-reference/endpoint/search
|
|
3
|
+
"""
|
|
4
|
+
import typing as ta
|
|
5
|
+
|
|
6
|
+
from omlish import dataclasses as dc
|
|
7
|
+
from omlish import lang
|
|
8
|
+
from omlish import marshal as msh
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
##
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _set_class_marshal_options(cls):
|
|
15
|
+
msh.update_object_metadata(
|
|
16
|
+
cls,
|
|
17
|
+
field_defaults=msh.FieldMetadata(
|
|
18
|
+
options=msh.FieldOptions(
|
|
19
|
+
omit_if=lang.is_none,
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
return cls
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
KNOWN_COUNTRIES = frozenset([
|
|
31
|
+
'afghanistan',
|
|
32
|
+
'albania',
|
|
33
|
+
'algeria',
|
|
34
|
+
'andorra',
|
|
35
|
+
'angola',
|
|
36
|
+
'argentina',
|
|
37
|
+
'armenia',
|
|
38
|
+
'australia',
|
|
39
|
+
'austria',
|
|
40
|
+
'azerbaijan',
|
|
41
|
+
'bahamas',
|
|
42
|
+
'bahrain',
|
|
43
|
+
'bangladesh',
|
|
44
|
+
'barbados',
|
|
45
|
+
'belarus',
|
|
46
|
+
'belgium',
|
|
47
|
+
'belize',
|
|
48
|
+
'benin',
|
|
49
|
+
'bhutan',
|
|
50
|
+
'bolivia',
|
|
51
|
+
'bosnia and herzegovina',
|
|
52
|
+
'botswana',
|
|
53
|
+
'brazil',
|
|
54
|
+
'brunei',
|
|
55
|
+
'bulgaria',
|
|
56
|
+
'burkina faso',
|
|
57
|
+
'burundi',
|
|
58
|
+
'cambodia',
|
|
59
|
+
'cameroon',
|
|
60
|
+
'canada',
|
|
61
|
+
'cape verde',
|
|
62
|
+
'central african republic',
|
|
63
|
+
'chad',
|
|
64
|
+
'chile',
|
|
65
|
+
'china',
|
|
66
|
+
'colombia',
|
|
67
|
+
'comoros',
|
|
68
|
+
'congo',
|
|
69
|
+
'costa rica',
|
|
70
|
+
'croatia',
|
|
71
|
+
'cuba',
|
|
72
|
+
'cyprus',
|
|
73
|
+
'czech republic',
|
|
74
|
+
'denmark',
|
|
75
|
+
'djibouti',
|
|
76
|
+
'dominican republic',
|
|
77
|
+
'ecuador',
|
|
78
|
+
'egypt',
|
|
79
|
+
'el salvador',
|
|
80
|
+
'equatorial guinea',
|
|
81
|
+
'eritrea',
|
|
82
|
+
'estonia',
|
|
83
|
+
'ethiopia',
|
|
84
|
+
'fiji',
|
|
85
|
+
'finland',
|
|
86
|
+
'france',
|
|
87
|
+
'gabon',
|
|
88
|
+
'gambia',
|
|
89
|
+
'georgia',
|
|
90
|
+
'germany',
|
|
91
|
+
'ghana',
|
|
92
|
+
'greece',
|
|
93
|
+
'guatemala',
|
|
94
|
+
'guinea',
|
|
95
|
+
'haiti',
|
|
96
|
+
'honduras',
|
|
97
|
+
'hungary',
|
|
98
|
+
'iceland',
|
|
99
|
+
'india',
|
|
100
|
+
'indonesia',
|
|
101
|
+
'iran',
|
|
102
|
+
'iraq',
|
|
103
|
+
'ireland',
|
|
104
|
+
'israel',
|
|
105
|
+
'italy',
|
|
106
|
+
'jamaica',
|
|
107
|
+
'japan',
|
|
108
|
+
'jordan',
|
|
109
|
+
'kazakhstan',
|
|
110
|
+
'kenya',
|
|
111
|
+
'kuwait',
|
|
112
|
+
'kyrgyzstan',
|
|
113
|
+
'latvia',
|
|
114
|
+
'lebanon',
|
|
115
|
+
'lesotho',
|
|
116
|
+
'liberia',
|
|
117
|
+
'libya',
|
|
118
|
+
'liechtenstein',
|
|
119
|
+
'lithuania',
|
|
120
|
+
'luxembourg',
|
|
121
|
+
'madagascar',
|
|
122
|
+
'malawi',
|
|
123
|
+
'malaysia',
|
|
124
|
+
'maldives',
|
|
125
|
+
'mali',
|
|
126
|
+
'malta',
|
|
127
|
+
'mauritania',
|
|
128
|
+
'mauritius',
|
|
129
|
+
'mexico',
|
|
130
|
+
'moldova',
|
|
131
|
+
'monaco',
|
|
132
|
+
'mongolia',
|
|
133
|
+
'montenegro',
|
|
134
|
+
'morocco',
|
|
135
|
+
'mozambique',
|
|
136
|
+
'myanmar',
|
|
137
|
+
'namibia',
|
|
138
|
+
'nepal',
|
|
139
|
+
'netherlands',
|
|
140
|
+
'new zealand',
|
|
141
|
+
'nicaragua',
|
|
142
|
+
'niger',
|
|
143
|
+
'nigeria',
|
|
144
|
+
'north korea',
|
|
145
|
+
'north macedonia',
|
|
146
|
+
'norway',
|
|
147
|
+
'oman',
|
|
148
|
+
'pakistan',
|
|
149
|
+
'panama',
|
|
150
|
+
'papua new guinea',
|
|
151
|
+
'paraguay',
|
|
152
|
+
'peru',
|
|
153
|
+
'philippines',
|
|
154
|
+
'poland',
|
|
155
|
+
'portugal',
|
|
156
|
+
'qatar',
|
|
157
|
+
'romania',
|
|
158
|
+
'russia',
|
|
159
|
+
'rwanda',
|
|
160
|
+
'saudi arabia',
|
|
161
|
+
'senegal',
|
|
162
|
+
'serbia',
|
|
163
|
+
'singapore',
|
|
164
|
+
'slovakia',
|
|
165
|
+
'slovenia',
|
|
166
|
+
'somalia',
|
|
167
|
+
'south africa',
|
|
168
|
+
'south korea',
|
|
169
|
+
'south sudan',
|
|
170
|
+
'spain',
|
|
171
|
+
'sri lanka',
|
|
172
|
+
'sudan',
|
|
173
|
+
'sweden',
|
|
174
|
+
'switzerland',
|
|
175
|
+
'syria',
|
|
176
|
+
'taiwan',
|
|
177
|
+
'tajikistan',
|
|
178
|
+
'tanzania',
|
|
179
|
+
'thailand',
|
|
180
|
+
'togo',
|
|
181
|
+
'trinidad and tobago',
|
|
182
|
+
'tunisia',
|
|
183
|
+
'turkey',
|
|
184
|
+
'turkmenistan',
|
|
185
|
+
'uganda',
|
|
186
|
+
'ukraine',
|
|
187
|
+
'united arab emirates',
|
|
188
|
+
'united kingdom',
|
|
189
|
+
'united states',
|
|
190
|
+
'uruguay',
|
|
191
|
+
'uzbekistan',
|
|
192
|
+
'venezuela',
|
|
193
|
+
'vietnam',
|
|
194
|
+
'yemen',
|
|
195
|
+
'zambia',
|
|
196
|
+
'zimbabwe',
|
|
197
|
+
])
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
##
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
204
|
+
@_set_class_marshal_options
|
|
205
|
+
class SearchRequest:
|
|
206
|
+
query: str
|
|
207
|
+
|
|
208
|
+
# optional
|
|
209
|
+
auto_parameters: bool | None = None
|
|
210
|
+
|
|
211
|
+
topic: ta.Literal['general', 'news', 'finance'] | None = None
|
|
212
|
+
search_depth: ta.Literal['basic', 'advanced'] | None = None
|
|
213
|
+
|
|
214
|
+
chunks_per_source: int | None = None
|
|
215
|
+
max_results: int | None = None
|
|
216
|
+
|
|
217
|
+
time_range: ta.Literal['day', 'week', 'month', 'year', 'd', 'w', 'm', 'y'] | None = None
|
|
218
|
+
start_date: str | None = None # YYYY-MM-DD
|
|
219
|
+
end_date: str | None = None # YYYY-MM-DD
|
|
220
|
+
|
|
221
|
+
# Booleans with extra enum-like modes per docs
|
|
222
|
+
include_answer: bool | ta.Literal['basic', 'advanced'] | None = None
|
|
223
|
+
include_raw_content: bool | ta.Literal['markdown', 'text'] | None = None
|
|
224
|
+
|
|
225
|
+
include_images: bool | None = None
|
|
226
|
+
include_image_descriptions: bool | None = None
|
|
227
|
+
include_favicon: bool | None = None
|
|
228
|
+
|
|
229
|
+
include_domains: ta.Sequence[str] | None = None
|
|
230
|
+
exclude_domains: ta.Sequence[str] | None = None
|
|
231
|
+
|
|
232
|
+
country: str | None = None
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
236
|
+
@_set_class_marshal_options
|
|
237
|
+
class SearchResponse:
|
|
238
|
+
query: str
|
|
239
|
+
answer: str
|
|
240
|
+
|
|
241
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
242
|
+
@_set_class_marshal_options
|
|
243
|
+
class Image:
|
|
244
|
+
url: str | None = None
|
|
245
|
+
description: str | None = None
|
|
246
|
+
|
|
247
|
+
images: ta.Sequence[Image] | None = None
|
|
248
|
+
|
|
249
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
250
|
+
@_set_class_marshal_options
|
|
251
|
+
class Result:
|
|
252
|
+
title: str | None = None
|
|
253
|
+
url: str | None = None
|
|
254
|
+
content: str | None = None
|
|
255
|
+
score: float | None = None
|
|
256
|
+
raw_content: str | None = None
|
|
257
|
+
favicon: str | None = None
|
|
258
|
+
|
|
259
|
+
results: ta.Sequence[Result] | None = None
|
|
260
|
+
|
|
261
|
+
follow_up_questions: ta.Sequence[str] | None = None
|
|
262
|
+
|
|
263
|
+
auto_parameters: ta.Mapping[str, ta.Any] | None = None
|
|
264
|
+
|
|
265
|
+
response_time: str | None = None # seconds
|
|
266
|
+
request_id: str | None = None
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
##
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
273
|
+
class ExtractRequest:
|
|
274
|
+
urls: str | ta.Sequence[str]
|
|
275
|
+
include_images: bool | None = None
|
|
276
|
+
include_favicon: bool | None = None
|
|
277
|
+
extract_depth: ta.Literal['basic', 'advanced'] | None = None
|
|
278
|
+
format: ta.Literal['markdown', 'text'] | None = None
|
|
279
|
+
timeout: str | None = None # seconds
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
283
|
+
class ExtractResponse:
|
|
284
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
285
|
+
class Result:
|
|
286
|
+
url: str
|
|
287
|
+
raw_content: str
|
|
288
|
+
images: ta.Sequence[str] | None = None
|
|
289
|
+
favicon: str | None = None
|
|
290
|
+
|
|
291
|
+
results: ta.Sequence[Result]
|
|
292
|
+
|
|
293
|
+
@dc.dataclass(frozen=True, kw_only=True)
|
|
294
|
+
class FailedResult:
|
|
295
|
+
url: str
|
|
296
|
+
error: str
|
|
297
|
+
|
|
298
|
+
failed_results: ta.Sequence[FailedResult] | None = None
|
|
299
|
+
|
|
300
|
+
response_time: str | None = None
|
|
301
|
+
request_id: str | None = None
|
|
@@ -4,17 +4,25 @@
|
|
|
4
4
|
# https://github.com/tinygrad/tinygrad/blob/ef17af85c6d3f84d1e1cc084d6dee8ced3d1a33e/extra/models/llama.py
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
7
|
+
from omlish import lang as _lang
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
with _lang.auto_proxy_init(globals()):
|
|
11
|
+
from .fetch import ( # noqa
|
|
12
|
+
fetch_model,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from .llm import ( # noqa
|
|
16
|
+
Llama3Llm,
|
|
17
|
+
run_llm,
|
|
18
|
+
run_llm_to_stop,
|
|
19
|
+
RunLlmToStopResult,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
from .tokenization import ( # noqa
|
|
23
|
+
Tokenizer,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
from .transformer import ( # noqa
|
|
27
|
+
Transformer,
|
|
28
|
+
)
|
|
File without changes
|