Skip to content

Commit 542fcfc

Browse files
committed
Fix CI
1 parent 9ac41f7 commit 542fcfc

File tree

11 files changed

+572
-25
lines changed

11 files changed

+572
-25
lines changed

.github/workflows/ci.yaml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,27 @@ jobs:
6363
build-test-components:
6464
runs-on: ubuntu-latest
6565
steps:
66-
- uses: actions/checkout@v4
67-
- uses: actions/cache@v3
68-
with:
69-
path: |
70-
~/.cargo/bin/
71-
~/.cargo/registry/index/
72-
~/.cargo/registry/cache/
73-
~/.cargo/git/db/
74-
target/
75-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-is
76-
- name: Setup Rust
77-
uses: actions-rs/toolchain@v1
78-
with:
79-
toolchain: stable
80-
override: true
81-
- uses: davidB/rust-cargo-make@v1
82-
- uses: cargo-bins/cargo-binstall@main
83-
- name: Build all test components
84-
run: cargo make build-test-components
66+
- uses: actions/checkout@v4
67+
- uses: actions/cache@v3
68+
with:
69+
path: |
70+
~/.cargo/bin/
71+
~/.cargo/registry/index/
72+
~/.cargo/registry/cache/
73+
~/.cargo/git/db/
74+
target/
75+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-is
76+
- name: Setup Rust
77+
uses: actions-rs/toolchain@v1
78+
with:
79+
toolchain: stable
80+
override: true
81+
- uses: davidB/rust-cargo-make@v1
82+
- uses: cargo-bins/cargo-binstall@main
83+
- name: Install cargo-component
84+
run: cargo binstall --force --locked cargo-component@0.20.0
85+
- name: Build all test components
86+
run: cargo make build-test-components
8587
publish-all:
8688
needs:
8789
- tests

Makefile.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,15 @@ rm -r llm-openrouter/wit/deps
221221
mkdir llm-openrouter/wit/deps/golem-llm
222222
cp wit/golem-llm.wit llm-openrouter/wit/deps/golem-llm/golem-llm.wit
223223
cp wit/deps/wasi:io llm-openrouter/wit/deps
224+
225+
rm -r test/wit
226+
mkdir test/wit/deps/golem-llm
227+
mkdir test/wit/deps/io
228+
cp wit/golem-llm.wit test/wit/deps/golem-llm/golem-llm.wit
229+
cp wit/deps/wasi:io/error.wit test/wit/deps/io/error.wit
230+
cp wit/deps/wasi:io/poll.wit test/wit/deps/io/poll.wit
231+
cp wit/deps/wasi:io/streams.wit test/wit/deps/io/streams.wit
232+
cp wit/deps/wasi:io/world.wit test/wit/deps/io/world.wit
224233
"""
225234

226235
[tasks.check]
@@ -264,6 +273,7 @@ args = [
264273
]
265274

266275
[tasks.build-test-components]
276+
dependencies = ["build"]
267277
description = "Builds all test components with golem-cli"
268278
install_crate = "cargo-binstall"
269279
script = '''

llm-anthropic/src/bindings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
4-
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
54
// * with "wasi:io/poll@0.2.0" = "golem_rust::wasm_rpc::wasi::io::poll"
5+
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
66
// * generate_unused_types
77
use golem_rust::wasm_rpc::wasi::io::poll as __with_name0;
88
use golem_llm::golem::llm::llm as __with_name1;

llm-grok/src/bindings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
22
// Options used:
33
// * runtime_path: "wit_bindgen_rt"
4-
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
54
// * with "wasi:io/poll@0.2.0" = "golem_rust::wasm_rpc::wasi::io::poll"
5+
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
66
// * generate_unused_types
77
use golem_rust::wasm_rpc::wasi::io::poll as __with_name0;
88
use golem_llm::golem::llm::llm as __with_name1;

test/components-rust/test-llm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ path = "wit-generated"
3535
"golem:rpc/types@0.2.0" = "golem_rust::wasm_rpc::golem_rpc_0_2_x::types"
3636

3737
[package.metadata.component.target.dependencies]
38-
"wasi:io" = { path = "wit-generated/deps/wasi:io" }
38+
"wasi:io" = { path = "wit-generated/deps/io" }
3939
"golem:llm" = { path = "wit-generated/deps/golem-llm" }
4040
"wasi:clocks" = { path = "wit-generated/deps/clocks" }
4141
"golem:rpc" = { path = "wit-generated/deps/golem-rpc" }

test/golem.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# See https://learn.golem.cloud/docs/app-manifest#field-reference for field reference
77

88
includes:
9-
- common-*/golem.yaml
10-
- components-*/*/golem.yaml
9+
- common-*/golem.yaml
10+
- components-*/*/golem.yaml
1111
witDeps:
12-
- ../llm/wit/deps
12+
- wit/deps

test/wit/deps/golem-llm/golem-llm.wit

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
package golem:llm@1.0.0;
2+
3+
interface llm {
4+
use wasi:io/poll@0.2.0.{pollable};
5+
6+
// --- Roles, Error Codes, Finish Reasons ---
7+
8+
enum role {
9+
user,
10+
assistant,
11+
system,
12+
tool,
13+
}
14+
15+
enum error-code {
16+
invalid-request,
17+
authentication-failed,
18+
rate-limit-exceeded,
19+
internal-error,
20+
unsupported,
21+
unknown,
22+
}
23+
24+
enum finish-reason {
25+
stop,
26+
length,
27+
tool-calls,
28+
content-filter,
29+
error,
30+
other,
31+
}
32+
33+
enum image-detail {
34+
low,
35+
high,
36+
auto,
37+
}
38+
39+
// --- Message Content ---
40+
41+
record image-url {
42+
url: string,
43+
detail: option<image-detail>,
44+
}
45+
46+
variant content-part {
47+
text(string),
48+
image(image-url),
49+
}
50+
51+
record message {
52+
role: role,
53+
name: option<string>,
54+
content: list<content-part>,
55+
}
56+
57+
// --- Tooling ---
58+
59+
record tool-definition {
60+
name: string,
61+
description: option<string>,
62+
parameters-schema: string,
63+
}
64+
65+
record tool-call {
66+
id: string,
67+
name: string,
68+
arguments-json: string,
69+
}
70+
71+
record tool-success {
72+
id: string,
73+
name: string,
74+
result-json: string,
75+
execution-time-ms: option<u32>,
76+
}
77+
78+
record tool-failure {
79+
id: string,
80+
name: string,
81+
error-message: string,
82+
error-code: option<string>,
83+
}
84+
85+
variant tool-result {
86+
success(tool-success),
87+
error(tool-failure),
88+
}
89+
90+
// --- Configuration ---
91+
92+
record kv {
93+
key: string,
94+
value: string,
95+
}
96+
97+
record config {
98+
model: string,
99+
temperature: option<f32>,
100+
max-tokens: option<u32>,
101+
stop-sequences: option<list<string>>,
102+
tools: list<tool-definition>,
103+
tool-choice: option<string>,
104+
provider-options: list<kv>,
105+
}
106+
107+
// --- Usage / Metadata ---
108+
109+
record usage {
110+
input-tokens: option<u32>,
111+
output-tokens: option<u32>,
112+
total-tokens: option<u32>,
113+
}
114+
115+
record response-metadata {
116+
finish-reason: option<finish-reason>,
117+
usage: option<usage>,
118+
provider-id: option<string>,
119+
timestamp: option<string>,
120+
provider-metadata-json: option<string>,
121+
}
122+
123+
record complete-response {
124+
id: string,
125+
content: list<content-part>,
126+
tool-calls: list<tool-call>,
127+
metadata: response-metadata,
128+
}
129+
130+
// --- Error Handling ---
131+
132+
record error {
133+
code: error-code,
134+
message: string,
135+
provider-error-json: option<string>,
136+
}
137+
138+
// --- Chat Response Variants ---
139+
140+
variant chat-event {
141+
message(complete-response),
142+
tool-request(list<tool-call>),
143+
error(error),
144+
}
145+
146+
// --- Streaming ---
147+
148+
record stream-delta {
149+
content: option<list<content-part>>,
150+
tool-calls: option<list<tool-call>>,
151+
}
152+
153+
variant stream-event {
154+
delta(stream-delta),
155+
finish(response-metadata),
156+
error(error),
157+
}
158+
159+
resource chat-stream {
160+
get-next: func() -> option<list<stream-event>>;
161+
blocking-get-next: func() -> list<stream-event>;
162+
subscribe: func() -> pollable;
163+
}
164+
165+
// --- Core Functions ---
166+
167+
send: func(
168+
messages: list<message>,
169+
config: config
170+
) -> chat-event;
171+
172+
continue: func(
173+
messages: list<message>,
174+
tool-results: list<tuple<tool-call, tool-result>>,
175+
config: config
176+
) -> chat-event;
177+
178+
%stream: func(
179+
messages: list<message>,
180+
config: config
181+
) -> chat-stream;
182+
}
183+
184+
world llm-library {
185+
import wasi:io/poll@0.2.0;
186+
export llm;
187+
}
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

test/wit/deps/io/error.wit

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package wasi:io@0.2.0;
2+
3+
4+
interface error {
5+
/// A resource which represents some error information.
6+
///
7+
/// The only method provided by this resource is `to-debug-string`,
8+
/// which provides some human-readable information about the error.
9+
///
10+
/// In the `wasi:io` package, this resource is returned through the
11+
/// `wasi:io/streams/stream-error` type.
12+
///
13+
/// To provide more specific error information, other interfaces may
14+
/// provide functions to further "downcast" this error into more specific
15+
/// error information. For example, `error`s returned in streams derived
16+
/// from filesystem types to be described using the filesystem's own
17+
/// error-code type, using the function
18+
/// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter
19+
/// `borrow<error>` and returns
20+
/// `option<wasi:filesystem/types/error-code>`.
21+
///
22+
/// The set of functions which can "downcast" an `error` into a more
23+
/// concrete type is open.
24+
resource error {
25+
/// Returns a string that is suitable to assist humans in debugging
26+
/// this error.
27+
///
28+
/// WARNING: The returned string should not be consumed mechanically!
29+
/// It may change across platforms, hosts, or other implementation
30+
/// details. Parsing this string is a major platform-compatibility
31+
/// hazard.
32+
to-debug-string: func() -> string;
33+
}
34+
}

test/wit/deps/io/poll.wit

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package wasi:io@0.2.0;
2+
3+
/// A poll API intended to let users wait for I/O events on multiple handles
4+
/// at once.
5+
interface poll {
6+
/// `pollable` represents a single I/O event which may be ready, or not.
7+
resource pollable {
8+
9+
/// Return the readiness of a pollable. This function never blocks.
10+
///
11+
/// Returns `true` when the pollable is ready, and `false` otherwise.
12+
ready: func() -> bool;
13+
14+
/// `block` returns immediately if the pollable is ready, and otherwise
15+
/// blocks until ready.
16+
///
17+
/// This function is equivalent to calling `poll.poll` on a list
18+
/// containing only this pollable.
19+
block: func();
20+
}
21+
22+
/// Poll for completion on a set of pollables.
23+
///
24+
/// This function takes a list of pollables, which identify I/O sources of
25+
/// interest, and waits until one or more of the events is ready for I/O.
26+
///
27+
/// The result `list<u32>` contains one or more indices of handles in the
28+
/// argument list that is ready for I/O.
29+
///
30+
/// If the list contains more elements than can be indexed with a `u32`
31+
/// value, this function traps.
32+
///
33+
/// A timeout can be implemented by adding a pollable from the
34+
/// wasi-clocks API to the list.
35+
///
36+
/// This function does not return a `result`; polling in itself does not
37+
/// do any I/O so it doesn't fail. If any of the I/O sources identified by
38+
/// the pollables has an error, it is indicated by marking the source as
39+
/// being reaedy for I/O.
40+
poll: func(in: list<borrow<pollable>>) -> list<u32>;
41+
}

0 commit comments

Comments
 (0)