Skip to content

Commit b5ec67c

Browse files
committed
init
1 parent 0ad73e1 commit b5ec67c

22 files changed

+1430
-1
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ members = [
77
"llm/grok",
88
"llm/ollama",
99
"llm/openai",
10-
"llm/openrouter",
10+
"llm/openrouter", "search/search",
1111
]
1212

1313
[profile.release]

search/Makefile.toml

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
[config]
2+
default_to_workspace = false
3+
skip_core_tasks = true
4+
5+
[tasks.build]
6+
run_task = { name = [
7+
"build-anthropic",
8+
"build-grok",
9+
"build-openai",
10+
"build-openrouter",
11+
"build-ollama",
12+
] }
13+
14+
[tasks.build-portable]
15+
run_task = { name = [
16+
"build-anthropic-portable",
17+
"build-grok-portable",
18+
"build-openai-portable",
19+
"build-openrouter-portable",
20+
"build-ollama-portable",
21+
] }
22+
23+
[tasks.release-build]
24+
run_task = { name = [
25+
"release-build-anthropic",
26+
"release-build-grok",
27+
"release-build-openai",
28+
"release-build-openrouter",
29+
"release-build-ollama",
30+
] }
31+
32+
[tasks.release-build-portable]
33+
run_task = { name = [
34+
"release-build-anthropic-portable",
35+
"release-build-grok-portable",
36+
"release-build-openai-portable",
37+
"release-build-openrouter-portable",
38+
"release-build-ollama-portable",
39+
] }
40+
41+
[tasks.build-ollama]
42+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
43+
command = "cargo-component"
44+
args = ["build", "-p", "golem-llm-ollama"]
45+
46+
47+
[tasks.build-ollama-portable]
48+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
49+
command = "cargo-component"
50+
args = ["build", "-p", "golem-llm-ollama", "--no-default-features"]
51+
52+
53+
[tasks.build-anthropic]
54+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
55+
command = "cargo-component"
56+
args = ["build", "-p", "golem-llm-anthropic"]
57+
58+
[tasks.build-anthropic-portable]
59+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
60+
command = "cargo-component"
61+
args = ["build", "-p", "golem-llm-anthropic", "--no-default-features"]
62+
63+
[tasks.build-grok]
64+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
65+
command = "cargo-component"
66+
args = ["build", "-p", "golem-llm-grok"]
67+
68+
[tasks.build-grok-portable]
69+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
70+
command = "cargo-component"
71+
args = ["build", "-p", "golem-llm-grok", "--no-default-features"]
72+
73+
[tasks.build-openai]
74+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
75+
command = "cargo-component"
76+
args = ["build", "-p", "golem-llm-openai"]
77+
78+
[tasks.build-openai-portable]
79+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
80+
command = "cargo-component"
81+
args = ["build", "-p", "golem-llm-openai", "--no-default-features"]
82+
83+
[tasks.build-openrouter]
84+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
85+
command = "cargo-component"
86+
args = ["build", "-p", "golem-llm-openrouter"]
87+
88+
[tasks.build-openrouter-portable]
89+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
90+
command = "cargo-component"
91+
args = ["build", "-p", "golem-llm-openrouter", "--no-default-features"]
92+
93+
[tasks.release-build-ollama]
94+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
95+
command = "cargo-component"
96+
args = ["build", "-p", "golem-llm-ollama", "--release"]
97+
98+
[tasks.release-build-ollama-portable]
99+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
100+
command = "cargo-component"
101+
args = ["build", "-p", "golem-llm-ollama", "--release", "--no-default-features"]
102+
103+
104+
[tasks.release-build-anthropic]
105+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
106+
command = "cargo-component"
107+
args = ["build", "-p", "golem-llm-anthropic", "--release"]
108+
109+
[tasks.release-build-anthropic-portable]
110+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
111+
command = "cargo-component"
112+
args = [
113+
"build",
114+
"-p",
115+
"golem-llm-anthropic",
116+
"--release",
117+
"--no-default-features",
118+
]
119+
120+
[tasks.release-build-grok]
121+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
122+
command = "cargo-component"
123+
args = ["build", "-p", "golem-llm-grok", "--release"]
124+
125+
[tasks.release-build-grok-portable]
126+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
127+
command = "cargo-component"
128+
args = ["build", "-p", "golem-llm-grok", "--release", "--no-default-features"]
129+
130+
[tasks.release-build-openai]
131+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
132+
command = "cargo-component"
133+
args = ["build", "-p", "golem-llm-openai", "--release"]
134+
135+
[tasks.release-build-openai-portable]
136+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
137+
command = "cargo-component"
138+
args = ["build", "-p", "golem-llm-openai", "--release", "--no-default-features"]
139+
140+
[tasks.release-build-openrouter]
141+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
142+
command = "cargo-component"
143+
args = ["build", "-p", "golem-llm-openrouter", "--release"]
144+
145+
[tasks.release-build-openrouter-portable]
146+
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
147+
command = "cargo-component"
148+
args = [
149+
"build",
150+
"-p",
151+
"golem-llm-openrouter",
152+
"--release",
153+
"--no-default-features",
154+
]
155+
156+
[tasks.wit-update]
157+
install_crate = { crate_name = "wit-deps-cli" }
158+
command = "wit-deps"
159+
args = ["update"]
160+
161+
[tasks.wit]
162+
dependencies = ["wit-update"]
163+
164+
script_runner = "@duckscript"
165+
script = """
166+
modules = array llm openai anthropic grok openrouter ollama
167+
168+
for module in ${modules}
169+
rm -r ${module}/wit/deps
170+
mkdir ${module}/wit/deps/golem-llm
171+
cp wit/golem-llm.wit ${module}/wit/deps/golem-llm/golem-llm.wit
172+
cp wit/deps/wasi:io ${module}/wit/deps
173+
174+
echo "Copied WIT for module llm::${module}"
175+
end
176+
177+
# Copy WIT files for integration tests
178+
rm -r ../test/wit
179+
mkdir ../test/wit/deps/golem-llm
180+
mkdir ../test/wit/deps/io
181+
cp wit/golem-llm.wit ../test/wit/deps/golem-llm/golem-llm.wit
182+
cp wit/deps/wasi:io/error.wit ../test/wit/deps/io/error.wit
183+
cp wit/deps/wasi:io/poll.wit ../test/wit/deps/io/poll.wit
184+
cp wit/deps/wasi:io/streams.wit ../test/wit/deps/io/streams.wit
185+
cp wit/deps/wasi:io/world.wit ../test/wit/deps/io/world.wit
186+
187+
echo "Copied WIT for module test"
188+
"""
189+
190+
[tasks.build-test-components]
191+
dependencies = ["build"]
192+
install_crate = "cargo-binstall"
193+
description = "Builds llm test components with golem-cli"
194+
script = '''
195+
cargo-binstall golem-cli@1.2.2-dev.11 --locked --no-confirm
196+
cargo-binstall wac-cli --locked --no-confirm
197+
cd ../test
198+
199+
golem-cli --version
200+
golem-cli app clean
201+
golem-cli app build -b anthropic-debug
202+
golem-cli app clean
203+
golem-cli app build -b grok-debug
204+
golem-cli app clean
205+
golem-cli app build -b openai-debug
206+
golem-cli app clean
207+
golem-cli app build -b openrouter-debug
208+
golem-cli app clean
209+
golem-cli app build -b ollama-debug
210+
'''

search/search/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "golem-search"
3+
version = "0.0.0"
4+
edition = "2021"
5+
license = "Apache-2.0"
6+
homepage = "https://golem.cloud"
7+
repository = "https://github.com/golemcloud/golem-llm"
8+
description = "WebAssembly components for working with LLM APIs, with special support for Golem Cloud"
9+
10+
[lib]
11+
path = "src/lib.rs"
12+
crate-type = ["rlib"]
13+
14+
[dependencies]
15+
golem-rust = { workspace = true }
16+
log = { workspace = true }
17+
reqwest = { workspace = true }
18+
thiserror = "2.0.12"
19+
wasi-logger = "0.1.2"
20+
wit-bindgen = { version = "0.40.0" }
21+
22+
[features]
23+
default = ["durability"]
24+
durability = ["golem-rust/durability"]

search/search/src/bindings.rs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
2+
// Options used:
3+
// * runtime_path: "wit_bindgen_rt"
4+
#[doc(hidden)]
5+
#[allow(non_snake_case)]
6+
pub unsafe fn _export_hello_world_cabi<T: Guest>() -> *mut u8 {
7+
#[cfg(target_arch = "wasm32")] _rt::run_ctors_once();
8+
let result0 = T::hello_world();
9+
let ptr1 = (&raw mut _RET_AREA.0).cast::<u8>();
10+
let vec2 = (result0.into_bytes()).into_boxed_slice();
11+
let ptr2 = vec2.as_ptr().cast::<u8>();
12+
let len2 = vec2.len();
13+
::core::mem::forget(vec2);
14+
*ptr1.add(::core::mem::size_of::<*const u8>()).cast::<usize>() = len2;
15+
*ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut();
16+
ptr1
17+
}
18+
#[doc(hidden)]
19+
#[allow(non_snake_case)]
20+
pub unsafe fn __post_return_hello_world<T: Guest>(arg0: *mut u8) {
21+
let l0 = *arg0.add(0).cast::<*mut u8>();
22+
let l1 = *arg0.add(::core::mem::size_of::<*const u8>()).cast::<usize>();
23+
_rt::cabi_dealloc(l0, l1, 1);
24+
}
25+
pub trait Guest {
26+
fn hello_world() -> _rt::String;
27+
}
28+
#[doc(hidden)]
29+
macro_rules! __export_world_example_cabi {
30+
($ty:ident with_types_in $($path_to_types:tt)*) => {
31+
const _ : () = { #[unsafe (export_name = "hello-world")] unsafe extern "C" fn
32+
export_hello_world() -> * mut u8 { unsafe { $($path_to_types)*::
33+
_export_hello_world_cabi::<$ty > () } } #[unsafe (export_name =
34+
"cabi_post_hello-world")] unsafe extern "C" fn _post_return_hello_world(arg0 : *
35+
mut u8,) { unsafe { $($path_to_types)*:: __post_return_hello_world::<$ty > (arg0)
36+
} } };
37+
};
38+
}
39+
#[doc(hidden)]
40+
pub(crate) use __export_world_example_cabi;
41+
#[cfg_attr(target_pointer_width = "64", repr(align(8)))]
42+
#[cfg_attr(target_pointer_width = "32", repr(align(4)))]
43+
struct _RetArea([::core::mem::MaybeUninit<u8>; 2 * ::core::mem::size_of::<*const u8>()]);
44+
static mut _RET_AREA: _RetArea = _RetArea(
45+
[::core::mem::MaybeUninit::uninit(); 2 * ::core::mem::size_of::<*const u8>()],
46+
);
47+
#[rustfmt::skip]
48+
mod _rt {
49+
#![allow(dead_code, clippy::all)]
50+
#[cfg(target_arch = "wasm32")]
51+
pub fn run_ctors_once() {
52+
wit_bindgen_rt::run_ctors_once();
53+
}
54+
pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) {
55+
if size == 0 {
56+
return;
57+
}
58+
let layout = alloc::Layout::from_size_align_unchecked(size, align);
59+
alloc::dealloc(ptr, layout);
60+
}
61+
pub use alloc_crate::string::String;
62+
pub use alloc_crate::alloc;
63+
extern crate alloc as alloc_crate;
64+
}
65+
/// Generates `#[unsafe(no_mangle)]` functions to export the specified type as
66+
/// the root implementation of all generated traits.
67+
///
68+
/// For more information see the documentation of `wit_bindgen::generate!`.
69+
///
70+
/// ```rust
71+
/// # macro_rules! export{ ($($t:tt)*) => (); }
72+
/// # trait Guest {}
73+
/// struct MyType;
74+
///
75+
/// impl Guest for MyType {
76+
/// // ...
77+
/// }
78+
///
79+
/// export!(MyType);
80+
/// ```
81+
#[allow(unused_macros)]
82+
#[doc(hidden)]
83+
macro_rules! __export_example_impl {
84+
($ty:ident) => {
85+
self::export!($ty with_types_in self);
86+
};
87+
($ty:ident with_types_in $($path_to_types_root:tt)*) => {
88+
$($path_to_types_root)*:: __export_world_example_cabi!($ty with_types_in
89+
$($path_to_types_root)*);
90+
};
91+
}
92+
#[doc(inline)]
93+
pub(crate) use __export_example_impl as export;
94+
#[cfg(target_arch = "wasm32")]
95+
#[unsafe(
96+
link_section = "component-type:wit-bindgen:0.41.0:component:search:example:encoded world"
97+
)]
98+
#[doc(hidden)]
99+
#[allow(clippy::octal_escapes)]
100+
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 181] = *b"\
101+
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x078\x01A\x02\x01A\x02\x01\
102+
@\0\0s\x04\0\x0bhello-world\x01\0\x04\0\x18component:search/example\x04\0\x0b\x0d\
103+
\x01\0\x07example\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-compone\
104+
nt\x070.227.1\x10wit-bindgen-rust\x060.41.0";
105+
#[inline(never)]
106+
#[doc(hidden)]
107+
pub fn __link_custom_section_describing_imports() {
108+
wit_bindgen_rt::maybe_link_cabi_realloc();
109+
}

search/search/src/config.rs

Whitespace-only changes.

search/search/src/durability.rs

Whitespace-only changes.

search/search/src/error.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)