llm.rb 12.2.0 → 12.3.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +187 -0
- data/README.md +51 -10
- data/data/openai.json +422 -0
- data/lib/llm/active_record/acts_as_agent.rb +11 -0
- data/lib/llm/agent.rb +14 -6
- data/lib/llm/compactor.rb +2 -2
- data/lib/llm/context.rb +16 -24
- data/lib/llm/object.rb +13 -0
- data/lib/llm/provider.rb +10 -7
- data/lib/llm/providers/anthropic.rb +2 -3
- data/lib/llm/providers/bedrock.rb +4 -5
- data/lib/llm/providers/google.rb +4 -2
- data/lib/llm/providers/mistral.rb +49 -0
- data/lib/llm/providers/ollama/response_adapter/completion.rb +39 -0
- data/lib/llm/providers/ollama.rb +2 -3
- data/lib/llm/providers/openai/responses.rb +6 -3
- data/lib/llm/providers/openai.rb +2 -3
- data/lib/llm/repl/bar.rb +52 -0
- data/lib/llm/repl/input.rb +143 -30
- data/lib/llm/repl/markdown.rb +85 -0
- data/lib/llm/repl/status.rb +16 -5
- data/lib/llm/repl/stream.rb +15 -5
- data/lib/llm/repl/transcript.rb +107 -18
- data/lib/llm/repl/window.rb +49 -18
- data/lib/llm/repl.rb +99 -18
- data/lib/llm/sequel/agent.rb +11 -0
- data/lib/llm/skill.rb +1 -1
- data/lib/llm/stream/disabled.rb +23 -0
- data/lib/llm/stream/io.rb +43 -0
- data/lib/llm/stream.rb +34 -0
- data/lib/llm/tools/git.rb +2 -3
- data/lib/llm/tools/pwd.rb +0 -1
- data/lib/llm/tools/rg.rb +2 -1
- data/lib/llm/tools/swap_text.rb +6 -0
- data/lib/llm/transport/execution.rb +1 -0
- data/lib/llm/version.rb +1 -1
- data/lib/llm.rb +10 -0
- data/llm.gemspec +7 -3
- data/resources/deepdive.md +170 -50
- metadata +10 -3
data/resources/deepdive.md
CHANGED
|
@@ -25,44 +25,126 @@ features that didn't make it into the homepage documentation.
|
|
|
25
25
|
|
|
26
26
|
## Table of contents
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
- [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
28
|
+
**Overview**
|
|
29
|
+
|
|
30
|
+
- [Welcome](#welcome)
|
|
31
|
+
|
|
32
|
+
**Core**
|
|
33
|
+
|
|
34
|
+
<details>
|
|
35
|
+
<summary>Agents</summary>
|
|
36
|
+
|
|
37
|
+
- [As a subclass](#as-a-subclass)
|
|
38
|
+
- [As an object](#as-an-object)
|
|
39
|
+
</details>
|
|
40
|
+
|
|
41
|
+
<details>
|
|
42
|
+
<summary>Tools</summary>
|
|
43
|
+
|
|
44
|
+
- [LLM::Tool](#llmtool)
|
|
45
|
+
- [Errors](#errors)
|
|
46
|
+
</details>
|
|
47
|
+
|
|
48
|
+
<details>
|
|
49
|
+
<summary>Skills</summary>
|
|
50
|
+
|
|
51
|
+
- [SKILL.md](#skillmd)
|
|
52
|
+
- [Run it](#run-it)
|
|
53
|
+
</details>
|
|
54
|
+
|
|
55
|
+
<details>
|
|
56
|
+
<summary>Schema</summary>
|
|
57
|
+
|
|
58
|
+
- [Estimation](#estimation)
|
|
59
|
+
</details>
|
|
60
|
+
|
|
61
|
+
**Runtime**
|
|
62
|
+
|
|
63
|
+
<details>
|
|
64
|
+
<summary>Stream</summary>
|
|
65
|
+
|
|
66
|
+
- [IO-like object](#io-like-object)
|
|
67
|
+
- [LLM::Stream](#llmstream)
|
|
68
|
+
</details>
|
|
69
|
+
|
|
70
|
+
<details>
|
|
71
|
+
<summary>Cancellation</summary>
|
|
72
|
+
|
|
73
|
+
- [Cancel a request](#cancel-a-request)
|
|
74
|
+
</details>
|
|
75
|
+
|
|
76
|
+
<details>
|
|
77
|
+
<summary>Transports</summary>
|
|
78
|
+
|
|
79
|
+
- [net/http](#nethttp)
|
|
80
|
+
- [net/http/persistent](#nethttppersistent)
|
|
81
|
+
- [curb](#curb)
|
|
82
|
+
</details>
|
|
83
|
+
|
|
84
|
+
<details>
|
|
85
|
+
<summary>Tracer</summary>
|
|
86
|
+
|
|
87
|
+
- [Provider-wide tracer](#provider-wide-tracer)
|
|
88
|
+
- [Agent-local tracer](#agent-local-tracer)
|
|
89
|
+
</details>
|
|
90
|
+
|
|
91
|
+
<details>
|
|
92
|
+
<summary>REPL</summary>
|
|
93
|
+
|
|
94
|
+
- [LLM::Agent](#llmagent)
|
|
95
|
+
- [Tools](#tools)
|
|
96
|
+
- [Skills](#skills-1)
|
|
97
|
+
- [Tracer](#tracer-1)
|
|
98
|
+
</details>
|
|
99
|
+
|
|
100
|
+
**Persistence**
|
|
101
|
+
|
|
102
|
+
<details>
|
|
103
|
+
<summary>Serialization</summary>
|
|
104
|
+
|
|
105
|
+
- [Save to disk](#save-to-disk)
|
|
106
|
+
</details>
|
|
107
|
+
|
|
108
|
+
<details>
|
|
109
|
+
<summary>ORM</summary>
|
|
110
|
+
|
|
111
|
+
- [ActiveRecord](#activerecord)
|
|
112
|
+
- [Sequel](#sequel)
|
|
113
|
+
</details>
|
|
114
|
+
|
|
115
|
+
**Media**
|
|
116
|
+
|
|
117
|
+
<details>
|
|
118
|
+
<summary>Images</summary>
|
|
119
|
+
|
|
120
|
+
- [Generation](#generation)
|
|
121
|
+
- [Edits](#edits)
|
|
122
|
+
- [DeepSeek](#deepseek)
|
|
123
|
+
</details>
|
|
124
|
+
|
|
125
|
+
<details>
|
|
126
|
+
<summary>Audio</summary>
|
|
127
|
+
|
|
128
|
+
- [text-to-speech](#text-to-speech)
|
|
129
|
+
- [speech-to-text](#speech-to-text)
|
|
130
|
+
- [translation](#translation)
|
|
131
|
+
</details>
|
|
132
|
+
|
|
133
|
+
**Protocols**
|
|
134
|
+
|
|
135
|
+
<details>
|
|
136
|
+
<summary>MCP</summary>
|
|
137
|
+
|
|
138
|
+
- [stdio](#stdio)
|
|
139
|
+
- [http](#http)
|
|
140
|
+
</details>
|
|
141
|
+
|
|
142
|
+
<details>
|
|
143
|
+
<summary>A2A</summary>
|
|
144
|
+
|
|
145
|
+
- [rest](#rest)
|
|
146
|
+
- [jsonrpc](#jsonrpc)
|
|
147
|
+
</details>
|
|
66
148
|
|
|
67
149
|
## Agents
|
|
68
150
|
|
|
@@ -808,21 +890,22 @@ agent = LLM::Agent.new(llm, tracer: LLM::Tracer::Logger.new(llm, path: "deepseek
|
|
|
808
890
|
|
|
809
891
|
During the development and operation of agents it can often
|
|
810
892
|
be helpful to drop into a read-eval-print loop. This gives
|
|
811
|
-
you a
|
|
812
|
-
anything that went wrong
|
|
813
|
-
|
|
814
|
-
decision-making process and make improvements for future runs.
|
|
815
|
-
It can also be used to ask the agent to correct any errors
|
|
816
|
-
that might have made.
|
|
893
|
+
you a way to confirm the work was successful, inspect
|
|
894
|
+
anything that went wrong, and keep talking to the same
|
|
895
|
+
agent while its state is still intact.
|
|
817
896
|
|
|
818
|
-
|
|
897
|
+
#### LLM::Agent
|
|
819
898
|
|
|
820
899
|
The [LLM::Agent#repl](https://r.uby.dev/api-docs/llm.rb/LLM/Agent.html#repl-instance_method)
|
|
821
|
-
method
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
900
|
+
method allows an agent to spawn a read-eval-print loop
|
|
901
|
+
that can be useful while developing or operating agents.
|
|
902
|
+
It can be used to debug tool calls, confirm an
|
|
903
|
+
agent has done what was expected, or improve an agent by
|
|
904
|
+
asking questions about what it has done up to that point.
|
|
905
|
+
|
|
906
|
+
This feature requires that the [curses](https://github.com/ruby/curses)
|
|
907
|
+
and [kramdown](https://github.com/gettalong/kramdown) libraries are
|
|
908
|
+
installed and available to require.
|
|
826
909
|
|
|
827
910
|
```ruby
|
|
828
911
|
require "llm"
|
|
@@ -832,6 +915,43 @@ agent = LLM::Agent.new(llm)
|
|
|
832
915
|
agent.repl
|
|
833
916
|
```
|
|
834
917
|
|
|
918
|
+
#### Tools
|
|
919
|
+
|
|
920
|
+
The read-eval-print loop accepts a `tools` option that lets
|
|
921
|
+
you attach additional tools for the duration of the session.
|
|
922
|
+
|
|
923
|
+
```ruby
|
|
924
|
+
llm = LLM.deepseek(key: ENV["KEY"])
|
|
925
|
+
agent = LLM::Agent.new(llm)
|
|
926
|
+
agent.repl(tools: [Debugger])
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
#### Skills
|
|
930
|
+
|
|
931
|
+
The read-eval-print loop also accepts a `skills` option.
|
|
932
|
+
This can be useful when you want to load extra skills
|
|
933
|
+
without attaching them to an agent permanently.
|
|
934
|
+
|
|
935
|
+
```ruby
|
|
936
|
+
llm = LLM.deepseek(key: ENV["KEY"])
|
|
937
|
+
agent = LLM::Agent.new(llm)
|
|
938
|
+
agent.repl(skills: [__dir__])
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
#### Tracer
|
|
942
|
+
|
|
943
|
+
By default the tracer is disabled for the duration of the
|
|
944
|
+
session. This can be configured through the
|
|
945
|
+
`tracer` option. Setting it to `true` will configure
|
|
946
|
+
the REPL to use the tracer associated with an instance
|
|
947
|
+
of [`LLM::Agent`](https://r.uby.dev/api-docs/llm.rb/LLM/Agent.html).
|
|
948
|
+
|
|
949
|
+
```ruby
|
|
950
|
+
llm = LLM.deepseek(key: ENV["KEY"])
|
|
951
|
+
agent = LLM::Agent.new(llm, tracer: LLM.logger(llm, path: "agent.log"))
|
|
952
|
+
agent.repl(tracer: true, tools: [Debugger])
|
|
953
|
+
```
|
|
954
|
+
|
|
835
955
|
[Back to top](#table-of-contents)
|
|
836
956
|
|
|
837
957
|
## Images
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: llm.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 12.
|
|
4
|
+
version: 12.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- robert
|
|
@@ -277,8 +277,11 @@ dependencies:
|
|
|
277
277
|
- - "~>"
|
|
278
278
|
- !ruby/object:Gem::Version
|
|
279
279
|
version: '1.18'
|
|
280
|
-
description:
|
|
281
|
-
for building
|
|
280
|
+
description: |
|
|
281
|
+
llm.rb is an advanced runtime for building capable AI applications
|
|
282
|
+
on CRuby. By default it has zero runtime dependencies although certain
|
|
283
|
+
functionality – such as ActiveRecord support – require
|
|
284
|
+
optional dependencies that are opt-in.
|
|
282
285
|
email:
|
|
283
286
|
- robert@r.uby.dev
|
|
284
287
|
executables: []
|
|
@@ -464,7 +467,9 @@ files:
|
|
|
464
467
|
- lib/llm/providers/zai.rb
|
|
465
468
|
- lib/llm/registry.rb
|
|
466
469
|
- lib/llm/repl.rb
|
|
470
|
+
- lib/llm/repl/bar.rb
|
|
467
471
|
- lib/llm/repl/input.rb
|
|
472
|
+
- lib/llm/repl/markdown.rb
|
|
468
473
|
- lib/llm/repl/status.rb
|
|
469
474
|
- lib/llm/repl/stream.rb
|
|
470
475
|
- lib/llm/repl/transcript.rb
|
|
@@ -492,6 +497,8 @@ files:
|
|
|
492
497
|
- lib/llm/session.rb
|
|
493
498
|
- lib/llm/skill.rb
|
|
494
499
|
- lib/llm/stream.rb
|
|
500
|
+
- lib/llm/stream/disabled.rb
|
|
501
|
+
- lib/llm/stream/io.rb
|
|
495
502
|
- lib/llm/stream/queue.rb
|
|
496
503
|
- lib/llm/tool.rb
|
|
497
504
|
- lib/llm/tool/param.rb
|