Skip to content

Commit fcc5547

Browse files
authored
Merge pull request #10 from golemcloud/remove-pollable-from-api
Removing the pollable from the WIT
2 parents 4af661b + cb00061 commit fcc5547

File tree

24 files changed

+234
-273
lines changed

24 files changed

+234
-273
lines changed

README.md

+39
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,45 @@ implemented test functions are demonstrating the following:
119119
| `test5` | Using an image in the prompt |
120120
| `test6` | Demonstrates that the streaming response is continued in case of a crash (with Golem only) |
121121

122+
### Running the examples
123+
124+
To run the examples first you need a running Golem instance. This can be Golem Cloud or the single-executable `golem`
125+
binary
126+
started with `golem server run`.
127+
128+
**NOTE**: `golem-llm` requires the latest (unstable) version of Golem currently. It's going to work with the next public
129+
stable release 1.2.2.
130+
131+
Then build and deploy the _test application_. Select one of the following profiles to choose which provider to use:
132+
| Profile Name | Description |
133+
|--------------|-----------------------------------------------------------------------------------------------|
134+
| `anthropic-debug` | Uses the Anthropic LLM implementation and compiles the code in debug profile |
135+
| `anthropic-release` | Uses the Anthropic LLM implementation and compiles the code in release profile |
136+
| `grok-debug` | Uses the Grok LLM implementation and compiles the code in debug profile |
137+
| `grok-release` | Uses the Grok LLM implementation and compiles the code in release profile |
138+
| `openai-debug` | Uses the OpenAI LLM implementation and compiles the code in debug profile |
139+
| `openai-release` | Uses the OpenAI LLM implementation and compiles the code in release profile |
140+
| `openrouter-debug` | Uses the OpenRouter LLM implementation and compiles the code in debug profile |
141+
| `openrouter-release` | Uses the OpenRouter LLM implementation and compiles the code in release profile |
142+
143+
```bash
144+
cd test
145+
golem app build -b openai-debug
146+
golem app deploy -b openai-debug
147+
```
148+
149+
Depending on the provider selected, an environment variable has to be set for the worker to be started, containing the API key for the given provider:
150+
151+
```bash
152+
golem worker new test:llm/debug --env OPENAI_API_KEY=xxx --env GOLEM_LLM_LOG=trace
153+
```
154+
155+
Then you can invoke the test functions on this worker:
156+
157+
```bash
158+
golem worker invoke test:llm/debug test1 --stream
159+
```
160+
122161
## Development
123162

124163
This repository uses [cargo-make](https://github.com/sagiegurari/cargo-make) to automate build tasks.

llm-anthropic/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ generate_unused_types = true
3333

3434
[package.metadata.component.bindings.with]
3535
"golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
36-
"wasi:io/poll@0.2.0" = "golem_rust::wasm_rpc::wasi::io::poll"
3736

3837
[package.metadata.component.target]
3938
path = "wit"

llm-anthropic/src/bindings.rs

+36-44
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,46 @@
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
44
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
5-
// * with "wasi:io/poll@0.2.0" = "golem_rust::wasm_rpc::wasi::io::poll"
65
// * generate_unused_types
7-
use golem_rust::wasm_rpc::wasi::io::poll as __with_name0;
8-
use golem_llm::golem::llm::llm as __with_name1;
6+
use golem_llm::golem::llm::llm as __with_name0;
97
#[cfg(target_arch = "wasm32")]
108
#[link_section = "component-type:wit-bindgen:0.36.0:golem:llm-anthropic@1.0.0:llm-library:encoded world"]
119
#[doc(hidden)]
12-
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1894] = *b"\
13-
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe4\x0d\x01A\x02\x01\
14-
A\x05\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\
15-
\x16[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]p\
16-
ollable.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\
17-
\x03\0\x12wasi:io/poll@0.2.0\x05\0\x02\x03\0\0\x08pollable\x01BO\x02\x03\x02\x01\
18-
\x01\x04\0\x08pollable\x03\0\0\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\
19-
\0\x04role\x03\0\x02\x01m\x06\x0finvalid-request\x15authentication-failed\x13rat\
20-
e-limit-exceeded\x0einternal-error\x0bunsupported\x07unknown\x04\0\x0aerror-code\
21-
\x03\0\x04\x01m\x06\x04stop\x06length\x0atool-calls\x0econtent-filter\x05error\x05\
22-
other\x04\0\x0dfinish-reason\x03\0\x06\x01m\x03\x03low\x04high\x04auto\x04\0\x0c\
23-
image-detail\x03\0\x08\x01k\x09\x01r\x02\x03urls\x06detail\x0a\x04\0\x09image-ur\
24-
l\x03\0\x0b\x01q\x02\x04text\x01s\0\x05image\x01\x0c\0\x04\0\x0ccontent-part\x03\
25-
\0\x0d\x01ks\x01p\x0e\x01r\x03\x04role\x03\x04name\x0f\x07content\x10\x04\0\x07m\
26-
essage\x03\0\x11\x01r\x03\x04names\x0bdescription\x0f\x11parameters-schemas\x04\0\
27-
\x0ftool-definition\x03\0\x13\x01r\x03\x02ids\x04names\x0earguments-jsons\x04\0\x09\
28-
tool-call\x03\0\x15\x01ky\x01r\x04\x02ids\x04names\x0bresult-jsons\x11execution-\
29-
time-ms\x17\x04\0\x0ctool-success\x03\0\x18\x01r\x04\x02ids\x04names\x0derror-me\
30-
ssages\x0aerror-code\x0f\x04\0\x0ctool-failure\x03\0\x1a\x01q\x02\x07success\x01\
31-
\x19\0\x05error\x01\x1b\0\x04\0\x0btool-result\x03\0\x1c\x01r\x02\x03keys\x05val\
32-
ues\x04\0\x02kv\x03\0\x1e\x01kv\x01ps\x01k!\x01p\x14\x01p\x1f\x01r\x07\x05models\
33-
\x0btemperature\x20\x0amax-tokens\x17\x0estop-sequences\"\x05tools#\x0btool-choi\
34-
ce\x0f\x10provider-options$\x04\0\x06config\x03\0%\x01r\x03\x0cinput-tokens\x17\x0d\
35-
output-tokens\x17\x0ctotal-tokens\x17\x04\0\x05usage\x03\0'\x01k\x07\x01k(\x01r\x05\
36-
\x0dfinish-reason)\x05usage*\x0bprovider-id\x0f\x09timestamp\x0f\x16provider-met\
37-
adata-json\x0f\x04\0\x11response-metadata\x03\0+\x01p\x16\x01r\x04\x02ids\x07con\
38-
tent\x10\x0atool-calls-\x08metadata,\x04\0\x11complete-response\x03\0.\x01r\x03\x04\
39-
code\x05\x07messages\x13provider-error-json\x0f\x04\0\x05error\x03\00\x01q\x03\x07\
40-
message\x01/\0\x0ctool-request\x01-\0\x05error\x011\0\x04\0\x0achat-event\x03\02\
41-
\x01k\x10\x01k-\x01r\x02\x07content4\x0atool-calls5\x04\0\x0cstream-delta\x03\06\
42-
\x01q\x03\x05delta\x017\0\x06finish\x01,\0\x05error\x011\0\x04\0\x0cstream-event\
43-
\x03\08\x04\0\x0bchat-stream\x03\x01\x01h:\x01p9\x01k<\x01@\x01\x04self;\0=\x04\0\
44-
\x1c[method]chat-stream.get-next\x01>\x01@\x01\x04self;\0<\x04\0%[method]chat-st\
45-
ream.blocking-get-next\x01?\x01i\x01\x01@\x01\x04self;\0\xc0\0\x04\0\x1d[method]\
46-
chat-stream.subscribe\x01A\x01p\x12\x01@\x02\x08messages\xc2\0\x06config&\03\x04\
47-
\0\x04send\x01C\x01o\x02\x16\x1d\x01p\xc4\0\x01@\x03\x08messages\xc2\0\x0ctool-r\
48-
esults\xc5\0\x06config&\03\x04\0\x08continue\x01F\x01i:\x01@\x02\x08messages\xc2\
49-
\0\x06config&\0\xc7\0\x04\0\x06stream\x01H\x04\0\x13golem:llm/llm@1.0.0\x05\x02\x04\
50-
\0%golem:llm-anthropic/llm-library@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\
51-
\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bi\
52-
ndgen-rust\x060.36.0";
10+
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1668] = *b"\
11+
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x82\x0c\x01A\x02\x01\
12+
A\x02\x01BJ\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\0\x04role\x03\0\0\
13+
\x01m\x06\x0finvalid-request\x15authentication-failed\x13rate-limit-exceeded\x0e\
14+
internal-error\x0bunsupported\x07unknown\x04\0\x0aerror-code\x03\0\x02\x01m\x06\x04\
15+
stop\x06length\x0atool-calls\x0econtent-filter\x05error\x05other\x04\0\x0dfinish\
16+
-reason\x03\0\x04\x01m\x03\x03low\x04high\x04auto\x04\0\x0cimage-detail\x03\0\x06\
17+
\x01k\x07\x01r\x02\x03urls\x06detail\x08\x04\0\x09image-url\x03\0\x09\x01q\x02\x04\
18+
text\x01s\0\x05image\x01\x0a\0\x04\0\x0ccontent-part\x03\0\x0b\x01ks\x01p\x0c\x01\
19+
r\x03\x04role\x01\x04name\x0d\x07content\x0e\x04\0\x07message\x03\0\x0f\x01r\x03\
20+
\x04names\x0bdescription\x0d\x11parameters-schemas\x04\0\x0ftool-definition\x03\0\
21+
\x11\x01r\x03\x02ids\x04names\x0earguments-jsons\x04\0\x09tool-call\x03\0\x13\x01\
22+
ky\x01r\x04\x02ids\x04names\x0bresult-jsons\x11execution-time-ms\x15\x04\0\x0cto\
23+
ol-success\x03\0\x16\x01r\x04\x02ids\x04names\x0derror-messages\x0aerror-code\x0d\
24+
\x04\0\x0ctool-failure\x03\0\x18\x01q\x02\x07success\x01\x17\0\x05error\x01\x19\0\
25+
\x04\0\x0btool-result\x03\0\x1a\x01r\x02\x03keys\x05values\x04\0\x02kv\x03\0\x1c\
26+
\x01kv\x01ps\x01k\x1f\x01p\x12\x01p\x1d\x01r\x07\x05models\x0btemperature\x1e\x0a\
27+
max-tokens\x15\x0estop-sequences\x20\x05tools!\x0btool-choice\x0d\x10provider-op\
28+
tions\"\x04\0\x06config\x03\0#\x01r\x03\x0cinput-tokens\x15\x0doutput-tokens\x15\
29+
\x0ctotal-tokens\x15\x04\0\x05usage\x03\0%\x01k\x05\x01k&\x01r\x05\x0dfinish-rea\
30+
son'\x05usage(\x0bprovider-id\x0d\x09timestamp\x0d\x16provider-metadata-json\x0d\
31+
\x04\0\x11response-metadata\x03\0)\x01p\x14\x01r\x04\x02ids\x07content\x0e\x0ato\
32+
ol-calls+\x08metadata*\x04\0\x11complete-response\x03\0,\x01r\x03\x04code\x03\x07\
33+
messages\x13provider-error-json\x0d\x04\0\x05error\x03\0.\x01q\x03\x07message\x01\
34+
-\0\x0ctool-request\x01+\0\x05error\x01/\0\x04\0\x0achat-event\x03\00\x01k\x0e\x01\
35+
k+\x01r\x02\x07content2\x0atool-calls3\x04\0\x0cstream-delta\x03\04\x01q\x03\x05\
36+
delta\x015\0\x06finish\x01*\0\x05error\x01/\0\x04\0\x0cstream-event\x03\06\x04\0\
37+
\x0bchat-stream\x03\x01\x01h8\x01p7\x01k:\x01@\x01\x04self9\0;\x04\0\x1c[method]\
38+
chat-stream.get-next\x01<\x01@\x01\x04self9\0:\x04\0%[method]chat-stream.blockin\
39+
g-get-next\x01=\x01p\x10\x01@\x02\x08messages>\x06config$\01\x04\0\x04send\x01?\x01\
40+
o\x02\x14\x1b\x01p\xc0\0\x01@\x03\x08messages>\x0ctool-results\xc1\0\x06config$\0\
41+
1\x04\0\x08continue\x01B\x01i8\x01@\x02\x08messages>\x06config$\0\xc3\0\x04\0\x06\
42+
stream\x01D\x04\0\x13golem:llm/llm@1.0.0\x05\0\x04\0%golem:llm-anthropic/llm-lib\
43+
rary@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\0G\x09producers\x01\x0cpro\
44+
cessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.36.0";
5345
#[inline(never)]
5446
#[doc(hidden)]
5547
pub fn __link_custom_section_describing_imports() {

llm-anthropic/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use golem_llm::golem::llm::llm::{
1717
Role, StreamDelta, StreamEvent, ToolCall, ToolResult,
1818
};
1919
use golem_llm::LOGGING_STATE;
20+
use golem_rust::wasm_rpc::Pollable;
2021
use log::trace;
2122
use std::cell::{Ref, RefCell, RefMut};
2223
use std::collections::HashMap;
@@ -366,6 +367,10 @@ impl ExtendedGuest for AnthropicComponent {
366367
});
367368
extended_messages
368369
}
370+
371+
fn subscribe(stream: &Self::ChatStream) -> Pollable {
372+
stream.subscribe()
373+
}
369374
}
370375

371376
type DurableAnthropicComponent = DurableLLM<AnthropicComponent>;

llm-anthropic/wit/deps/golem-llm/golem-llm.wit

-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package golem:llm@1.0.0;
22

33
interface llm {
4-
use wasi:io/poll@0.2.0.{pollable};
5-
64
// --- Roles, Error Codes, Finish Reasons ---
75

86
enum role {
@@ -159,7 +157,6 @@ interface llm {
159157
resource chat-stream {
160158
get-next: func() -> option<list<stream-event>>;
161159
blocking-get-next: func() -> list<stream-event>;
162-
subscribe: func() -> pollable;
163160
}
164161

165162
// --- Core Functions ---
@@ -182,11 +179,5 @@ interface llm {
182179
}
183180

184181
world llm-library {
185-
import wasi:io/poll@0.2.0;
186182
export llm;
187183
}
188-
189-
// UPDATE NOTES
190-
// send() and continue() returning chat-event directly as it already encodes the error
191-
// made continue's `tool-results` parameter get the original `tool-call` for each `tool-result` - according to OpenAI's docs the call has to be send back too
192-
// made the streaming API use wasi:io/poll.pollable

llm-grok/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ generate_unused_types = true
3333

3434
[package.metadata.component.bindings.with]
3535
"golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
36-
"wasi:io/poll@0.2.0" = "golem_rust::wasm_rpc::wasi::io::poll"
3736

3837
[package.metadata.component.target]
3938
path = "wit"

llm-grok/src/bindings.rs

+36-44
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,46 @@
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
44
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
5-
// * with "wasi:io/poll@0.2.0" = "golem_rust::wasm_rpc::wasi::io::poll"
65
// * generate_unused_types
7-
use golem_rust::wasm_rpc::wasi::io::poll as __with_name0;
8-
use golem_llm::golem::llm::llm as __with_name1;
6+
use golem_llm::golem::llm::llm as __with_name0;
97
#[cfg(target_arch = "wasm32")]
108
#[link_section = "component-type:wit-bindgen:0.36.0:golem:llm-grok@1.0.0:llm-library:encoded world"]
119
#[doc(hidden)]
12-
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1889] = *b"\
13-
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xdf\x0d\x01A\x02\x01\
14-
A\x05\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\
15-
\x16[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]p\
16-
ollable.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\
17-
\x03\0\x12wasi:io/poll@0.2.0\x05\0\x02\x03\0\0\x08pollable\x01BO\x02\x03\x02\x01\
18-
\x01\x04\0\x08pollable\x03\0\0\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\
19-
\0\x04role\x03\0\x02\x01m\x06\x0finvalid-request\x15authentication-failed\x13rat\
20-
e-limit-exceeded\x0einternal-error\x0bunsupported\x07unknown\x04\0\x0aerror-code\
21-
\x03\0\x04\x01m\x06\x04stop\x06length\x0atool-calls\x0econtent-filter\x05error\x05\
22-
other\x04\0\x0dfinish-reason\x03\0\x06\x01m\x03\x03low\x04high\x04auto\x04\0\x0c\
23-
image-detail\x03\0\x08\x01k\x09\x01r\x02\x03urls\x06detail\x0a\x04\0\x09image-ur\
24-
l\x03\0\x0b\x01q\x02\x04text\x01s\0\x05image\x01\x0c\0\x04\0\x0ccontent-part\x03\
25-
\0\x0d\x01ks\x01p\x0e\x01r\x03\x04role\x03\x04name\x0f\x07content\x10\x04\0\x07m\
26-
essage\x03\0\x11\x01r\x03\x04names\x0bdescription\x0f\x11parameters-schemas\x04\0\
27-
\x0ftool-definition\x03\0\x13\x01r\x03\x02ids\x04names\x0earguments-jsons\x04\0\x09\
28-
tool-call\x03\0\x15\x01ky\x01r\x04\x02ids\x04names\x0bresult-jsons\x11execution-\
29-
time-ms\x17\x04\0\x0ctool-success\x03\0\x18\x01r\x04\x02ids\x04names\x0derror-me\
30-
ssages\x0aerror-code\x0f\x04\0\x0ctool-failure\x03\0\x1a\x01q\x02\x07success\x01\
31-
\x19\0\x05error\x01\x1b\0\x04\0\x0btool-result\x03\0\x1c\x01r\x02\x03keys\x05val\
32-
ues\x04\0\x02kv\x03\0\x1e\x01kv\x01ps\x01k!\x01p\x14\x01p\x1f\x01r\x07\x05models\
33-
\x0btemperature\x20\x0amax-tokens\x17\x0estop-sequences\"\x05tools#\x0btool-choi\
34-
ce\x0f\x10provider-options$\x04\0\x06config\x03\0%\x01r\x03\x0cinput-tokens\x17\x0d\
35-
output-tokens\x17\x0ctotal-tokens\x17\x04\0\x05usage\x03\0'\x01k\x07\x01k(\x01r\x05\
36-
\x0dfinish-reason)\x05usage*\x0bprovider-id\x0f\x09timestamp\x0f\x16provider-met\
37-
adata-json\x0f\x04\0\x11response-metadata\x03\0+\x01p\x16\x01r\x04\x02ids\x07con\
38-
tent\x10\x0atool-calls-\x08metadata,\x04\0\x11complete-response\x03\0.\x01r\x03\x04\
39-
code\x05\x07messages\x13provider-error-json\x0f\x04\0\x05error\x03\00\x01q\x03\x07\
40-
message\x01/\0\x0ctool-request\x01-\0\x05error\x011\0\x04\0\x0achat-event\x03\02\
41-
\x01k\x10\x01k-\x01r\x02\x07content4\x0atool-calls5\x04\0\x0cstream-delta\x03\06\
42-
\x01q\x03\x05delta\x017\0\x06finish\x01,\0\x05error\x011\0\x04\0\x0cstream-event\
43-
\x03\08\x04\0\x0bchat-stream\x03\x01\x01h:\x01p9\x01k<\x01@\x01\x04self;\0=\x04\0\
44-
\x1c[method]chat-stream.get-next\x01>\x01@\x01\x04self;\0<\x04\0%[method]chat-st\
45-
ream.blocking-get-next\x01?\x01i\x01\x01@\x01\x04self;\0\xc0\0\x04\0\x1d[method]\
46-
chat-stream.subscribe\x01A\x01p\x12\x01@\x02\x08messages\xc2\0\x06config&\03\x04\
47-
\0\x04send\x01C\x01o\x02\x16\x1d\x01p\xc4\0\x01@\x03\x08messages\xc2\0\x0ctool-r\
48-
esults\xc5\0\x06config&\03\x04\0\x08continue\x01F\x01i:\x01@\x02\x08messages\xc2\
49-
\0\x06config&\0\xc7\0\x04\0\x06stream\x01H\x04\0\x13golem:llm/llm@1.0.0\x05\x02\x04\
50-
\0\x20golem:llm-grok/llm-library@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\
51-
\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bind\
52-
gen-rust\x060.36.0";
10+
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1663] = *b"\
11+
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xfd\x0b\x01A\x02\x01\
12+
A\x02\x01BJ\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\0\x04role\x03\0\0\
13+
\x01m\x06\x0finvalid-request\x15authentication-failed\x13rate-limit-exceeded\x0e\
14+
internal-error\x0bunsupported\x07unknown\x04\0\x0aerror-code\x03\0\x02\x01m\x06\x04\
15+
stop\x06length\x0atool-calls\x0econtent-filter\x05error\x05other\x04\0\x0dfinish\
16+
-reason\x03\0\x04\x01m\x03\x03low\x04high\x04auto\x04\0\x0cimage-detail\x03\0\x06\
17+
\x01k\x07\x01r\x02\x03urls\x06detail\x08\x04\0\x09image-url\x03\0\x09\x01q\x02\x04\
18+
text\x01s\0\x05image\x01\x0a\0\x04\0\x0ccontent-part\x03\0\x0b\x01ks\x01p\x0c\x01\
19+
r\x03\x04role\x01\x04name\x0d\x07content\x0e\x04\0\x07message\x03\0\x0f\x01r\x03\
20+
\x04names\x0bdescription\x0d\x11parameters-schemas\x04\0\x0ftool-definition\x03\0\
21+
\x11\x01r\x03\x02ids\x04names\x0earguments-jsons\x04\0\x09tool-call\x03\0\x13\x01\
22+
ky\x01r\x04\x02ids\x04names\x0bresult-jsons\x11execution-time-ms\x15\x04\0\x0cto\
23+
ol-success\x03\0\x16\x01r\x04\x02ids\x04names\x0derror-messages\x0aerror-code\x0d\
24+
\x04\0\x0ctool-failure\x03\0\x18\x01q\x02\x07success\x01\x17\0\x05error\x01\x19\0\
25+
\x04\0\x0btool-result\x03\0\x1a\x01r\x02\x03keys\x05values\x04\0\x02kv\x03\0\x1c\
26+
\x01kv\x01ps\x01k\x1f\x01p\x12\x01p\x1d\x01r\x07\x05models\x0btemperature\x1e\x0a\
27+
max-tokens\x15\x0estop-sequences\x20\x05tools!\x0btool-choice\x0d\x10provider-op\
28+
tions\"\x04\0\x06config\x03\0#\x01r\x03\x0cinput-tokens\x15\x0doutput-tokens\x15\
29+
\x0ctotal-tokens\x15\x04\0\x05usage\x03\0%\x01k\x05\x01k&\x01r\x05\x0dfinish-rea\
30+
son'\x05usage(\x0bprovider-id\x0d\x09timestamp\x0d\x16provider-metadata-json\x0d\
31+
\x04\0\x11response-metadata\x03\0)\x01p\x14\x01r\x04\x02ids\x07content\x0e\x0ato\
32+
ol-calls+\x08metadata*\x04\0\x11complete-response\x03\0,\x01r\x03\x04code\x03\x07\
33+
messages\x13provider-error-json\x0d\x04\0\x05error\x03\0.\x01q\x03\x07message\x01\
34+
-\0\x0ctool-request\x01+\0\x05error\x01/\0\x04\0\x0achat-event\x03\00\x01k\x0e\x01\
35+
k+\x01r\x02\x07content2\x0atool-calls3\x04\0\x0cstream-delta\x03\04\x01q\x03\x05\
36+
delta\x015\0\x06finish\x01*\0\x05error\x01/\0\x04\0\x0cstream-event\x03\06\x04\0\
37+
\x0bchat-stream\x03\x01\x01h8\x01p7\x01k:\x01@\x01\x04self9\0;\x04\0\x1c[method]\
38+
chat-stream.get-next\x01<\x01@\x01\x04self9\0:\x04\0%[method]chat-stream.blockin\
39+
g-get-next\x01=\x01p\x10\x01@\x02\x08messages>\x06config$\01\x04\0\x04send\x01?\x01\
40+
o\x02\x14\x1b\x01p\xc0\0\x01@\x03\x08messages>\x0ctool-results\xc1\0\x06config$\0\
41+
1\x04\0\x08continue\x01B\x01i8\x01@\x02\x08messages>\x06config$\0\xc3\0\x04\0\x06\
42+
stream\x01D\x04\0\x13golem:llm/llm@1.0.0\x05\0\x04\0\x20golem:llm-grok/llm-libra\
43+
ry@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\0G\x09producers\x01\x0cproce\
44+
ssed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.36.0";
5345
#[inline(never)]
5446
#[doc(hidden)]
5547
pub fn __link_custom_section_describing_imports() {

llm-grok/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use golem_llm::golem::llm::llm::{
1515
ResponseMetadata, StreamDelta, StreamEvent, ToolCall, ToolResult,
1616
};
1717
use golem_llm::LOGGING_STATE;
18+
use golem_rust::wasm_rpc::Pollable;
1819
use log::trace;
1920
use std::cell::{Ref, RefCell, RefMut};
2021

@@ -196,6 +197,10 @@ impl ExtendedGuest for GrokComponent {
196197
}
197198
})
198199
}
200+
201+
fn subscribe(stream: &Self::ChatStream) -> Pollable {
202+
stream.subscribe()
203+
}
199204
}
200205

201206
type DurableGrokComponent = DurableLLM<GrokComponent>;

llm-grok/wit/deps/golem-llm/golem-llm.wit

-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package golem:llm@1.0.0;
22

33
interface llm {
4-
use wasi:io/poll@0.2.0.{pollable};
5-
64
// --- Roles, Error Codes, Finish Reasons ---
75

86
enum role {
@@ -159,7 +157,6 @@ interface llm {
159157
resource chat-stream {
160158
get-next: func() -> option<list<stream-event>>;
161159
blocking-get-next: func() -> list<stream-event>;
162-
subscribe: func() -> pollable;
163160
}
164161

165162
// --- Core Functions ---
@@ -182,11 +179,5 @@ interface llm {
182179
}
183180

184181
world llm-library {
185-
import wasi:io/poll@0.2.0;
186182
export llm;
187183
}
188-
189-
// UPDATE NOTES
190-
// send() and continue() returning chat-event directly as it already encodes the error
191-
// made continue's `tool-results` parameter get the original `tool-call` for each `tool-result` - according to OpenAI's docs the call has to be send back too
192-
// made the streaming API use wasi:io/poll.pollable

llm-openai/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ generate_unused_types = true
3333

3434
[package.metadata.component.bindings.with]
3535
"golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
36-
"wasi:io/poll@0.2.0" = "golem_rust::wasm_rpc::wasi::io::poll"
3736

3837
[package.metadata.component.target]
3938
path = "wit"

0 commit comments

Comments
 (0)