Skip to content

feat: ollama full support for golem and wasm #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"

members = ["llm", "llm-anthropic", "llm-grok", "llm-openai", "llm-openrouter"]
members = ["llm", "llm-anthropic", "llm-grok", "llm-ollama", "llm-openai", "llm-openrouter"]

[profile.release]
debug = false
Expand Down
38 changes: 38 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ args = ["clean"]
command = "cargo"
args = ["test"]

[tasks.build-ollama]
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
command = "cargo-component"
args = ["build", "-p", "golem-llm-ollama"]


[tasks.build-ollama-portable]
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
command = "cargo-component"
args = ["build", "-p", "golem-llm-ollama", "--no-default-features"]


[tasks.build-anthropic]
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
command = "cargo-component"
Expand Down Expand Up @@ -56,6 +68,7 @@ dependencies = [
"build-grok",
"build-openai",
"build-openrouter",
"build-ollama",
]

[tasks.build-portable]
Expand All @@ -64,6 +77,7 @@ dependencies = [
"build-grok-portable",
"build-openai-portable",
"build-openrouter-portable",
"build-ollama-portable",
]

[tasks.build-all]
Expand All @@ -78,6 +92,7 @@ cp target/wasm32-wasip1/debug/golem_llm_anthropic.wasm components/debug/golem_ll
cp target/wasm32-wasip1/debug/golem_llm_grok.wasm components/debug/golem_llm_grok.wasm
cp target/wasm32-wasip1/debug/golem_llm_openai.wasm components/debug/golem_llm_openai.wasm
cp target/wasm32-wasip1/debug/golem_llm_openrouter.wasm components/debug/golem_llm_openrouter.wasm
cp target/wasm32-wasip1/debug/golem_llm_ollama.wasm components/debug/golem_llm_ollama.wasm

cm_run_task clean
cm_run_task build-portable
Expand All @@ -86,8 +101,20 @@ cp target/wasm32-wasip1/debug/golem_llm_anthropic.wasm components/debug/golem_ll
cp target/wasm32-wasip1/debug/golem_llm_grok.wasm components/debug/golem_llm_grok-portable.wasm
cp target/wasm32-wasip1/debug/golem_llm_openai.wasm components/debug/golem_llm_openai-portable.wasm
cp target/wasm32-wasip1/debug/golem_llm_openrouter.wasm components/debug/golem_llm_openrouter-portable.wasm
cp target/wasm32-wasip1/debug/golem_llm_ollama.wasm components/debug/golem_llm_ollama-portable.wasm
'''

[tasks.release-build-ollama]
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
command = "cargo-component"
args = ["build", "-p", "golem-llm-ollama", "--release"]

[tasks.release-build-ollama-portable]
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
command = "cargo-component"
args = ["build", "-p", "golem-llm-ollama", "--release", "--no-default-features"]


[tasks.release-build-anthropic]
install_crate = { crate_name = "cargo-component", version = "0.20.0" }
command = "cargo-component"
Expand Down Expand Up @@ -146,6 +173,7 @@ dependencies = [
"release-build-grok",
"release-build-openai",
"release-build-openrouter",
"release-build-ollama",
]

[tasks.release-build-portable]
Expand All @@ -154,6 +182,7 @@ dependencies = [
"release-build-grok-portable",
"release-build-openai-portable",
"release-build-openrouter-portable",
"release-build-ollama-portable",
]

[tasks.release-build-all]
Expand All @@ -170,6 +199,7 @@ cp target/wasm32-wasip1/release/golem_llm_anthropic.wasm components/release/gole
cp target/wasm32-wasip1/release/golem_llm_grok.wasm components/release/golem_llm_grok.wasm
cp target/wasm32-wasip1/release/golem_llm_openai.wasm components/release/golem_llm_openai.wasm
cp target/wasm32-wasip1/release/golem_llm_openrouter.wasm components/release/golem_llm_openrouter.wasm
cp target/wasm32-wasip1/release/golem_llm_ollama.wasm components/release/golem_llm_ollama.wasm

cm_run_task clean
cm_run_task release-build-portable
Expand All @@ -178,6 +208,7 @@ cp target/wasm32-wasip1/release/golem_llm_anthropic.wasm components/release/gole
cp target/wasm32-wasip1/release/golem_llm_grok.wasm components/release/golem_llm_grok-portable.wasm
cp target/wasm32-wasip1/release/golem_llm_openai.wasm components/release/golem_llm_openai-portable.wasm
cp target/wasm32-wasip1/release/golem_llm_openrouter.wasm components/release/golem_llm_openrouter-portable.wasm
cp target/wasm32-wasip1/release/golem_llm_ollama.wasm components/release/golem_llm_ollama-portable.wasm
'''

[tasks.wit-update]
Expand Down Expand Up @@ -221,6 +252,11 @@ rm -r llm-openrouter/wit/deps
mkdir llm-openrouter/wit/deps/golem-llm
cp wit/golem-llm.wit llm-openrouter/wit/deps/golem-llm/golem-llm.wit
cp wit/deps/wasi:io llm-openrouter/wit/deps
rm -r llm-ollama/wit/deps
mkdir llm-ollama/wit/deps/golem-llm
cp wit/golem-llm.wit llm-ollama/wit/deps/golem-llm/golem-llm.wit
cp wit/deps/wasi:io llm-ollama/wit/deps


rm -r test/wit
mkdir test/wit/deps/golem-llm
Expand Down Expand Up @@ -289,6 +325,8 @@ golem-cli app clean
golem-cli app build -b openai-debug
golem-cli app clean
golem-cli app build -b openrouter-debug
golem-cli app clean
golem-cli app build -b ollama-debug
'''

[tasks.set-version]
Expand Down
4 changes: 2 additions & 2 deletions llm-anthropic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "golem-llm-anthropic"
version = "0.0.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not adjust the other creates in the project please

version = "0.0.1"
edition = "2021"
license = "Apache-2.0"
homepage = "https://golem.cloud"
Expand All @@ -16,7 +16,7 @@ default = ["durability"]
durability = ["golem-rust/durability", "golem-llm/durability"]

[dependencies]
golem-llm = { path = "../llm", version = "0.0.0", default-features = false }
golem-llm = { path = "../llm", version = "0.0.1", default-features = false }

golem-rust = { workspace = true }
log = { workspace = true }
Expand Down
9 changes: 6 additions & 3 deletions llm-anthropic/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
// Options used:
// * runtime_path: "wit_bindgen_rt"
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
// * generate_unused_types
use golem_llm::golem::llm::llm as __with_name0;
#[cfg(target_arch = "wasm32")]
#[link_section = "component-type:wit-bindgen:0.36.0:golem:llm-anthropic@1.0.0:llm-library:encoded world"]
#[unsafe(
link_section = "component-type:wit-bindgen:0.41.0:golem:llm-anthropic@1.0.0:llm-library:encoded world"
)]
#[doc(hidden)]
#[allow(clippy::octal_escapes)]
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1668] = *b"\
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x82\x0c\x01A\x02\x01\
A\x02\x01BJ\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\0\x04role\x03\0\0\
Expand Down Expand Up @@ -41,7 +44,7 @@ o\x02\x14\x1b\x01p\xc0\0\x01@\x03\x08messages>\x0ctool-results\xc1\0\x06config$\
1\x04\0\x08continue\x01B\x01i8\x01@\x02\x08messages>\x06config$\0\xc3\0\x04\0\x06\
stream\x01D\x04\0\x13golem:llm/llm@1.0.0\x05\0\x04\0%golem:llm-anthropic/llm-lib\
rary@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\0G\x09producers\x01\x0cpro\
cessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.36.0";
cessed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen-rust\x060.41.0";
#[inline(never)]
#[doc(hidden)]
pub fn __link_custom_section_describing_imports() {
Expand Down
4 changes: 2 additions & 2 deletions llm-grok/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "golem-llm-grok"
version = "0.0.0"
version = "0.0.1"
edition = "2021"
license = "Apache-2.0"
homepage = "https://golem.cloud"
Expand All @@ -16,7 +16,7 @@ default = ["durability"]
durability = ["golem-rust/durability", "golem-llm/durability"]

[dependencies]
golem-llm = { path = "../llm", version = "0.0.0", default-features = false }
golem-llm = { path = "../llm", version = "0.0.1", default-features = false }

golem-rust = { workspace = true }
log = { workspace = true }
Expand Down
9 changes: 6 additions & 3 deletions llm-grok/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// Generated by `wit-bindgen` 0.36.0. DO NOT EDIT!
// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
// Options used:
// * runtime_path: "wit_bindgen_rt"
// * with "golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"
// * generate_unused_types
use golem_llm::golem::llm::llm as __with_name0;
#[cfg(target_arch = "wasm32")]
#[link_section = "component-type:wit-bindgen:0.36.0:golem:llm-grok@1.0.0:llm-library:encoded world"]
#[unsafe(
link_section = "component-type:wit-bindgen:0.41.0:golem:llm-grok@1.0.0:llm-library:encoded world"
)]
#[doc(hidden)]
#[allow(clippy::octal_escapes)]
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1663] = *b"\
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xfd\x0b\x01A\x02\x01\
A\x02\x01BJ\x01m\x04\x04user\x09assistant\x06system\x04tool\x04\0\x04role\x03\0\0\
Expand Down Expand Up @@ -41,7 +44,7 @@ o\x02\x14\x1b\x01p\xc0\0\x01@\x03\x08messages>\x0ctool-results\xc1\0\x06config$\
1\x04\0\x08continue\x01B\x01i8\x01@\x02\x08messages>\x06config$\0\xc3\0\x04\0\x06\
stream\x01D\x04\0\x13golem:llm/llm@1.0.0\x05\0\x04\0\x20golem:llm-grok/llm-libra\
ry@1.0.0\x04\0\x0b\x11\x01\0\x0bllm-library\x03\0\0\0G\x09producers\x01\x0cproce\
ssed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.36.0";
ssed-by\x02\x0dwit-component\x070.227.1\x10wit-bindgen-rust\x060.41.0";
#[inline(never)]
#[doc(hidden)]
pub fn __link_custom_section_describing_imports() {
Expand Down
47 changes: 47 additions & 0 deletions llm-ollama/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "golem-llm-ollama"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
homepage = "https://golem.cloud"
repository = "https://github.com/golemcloud/golem-llm"
description = "WebAssembly component for working with Ollama APIs, with special support for Golem Cloud"

[lib]
path = "src/lib.rs"
crate-type = ["cdylib"]


[features]
default = ["durability"]
durability = ["golem-rust/durability", "golem-llm/durability"]

[dependencies]
golem-llm = { path = "../llm", version = "0.0.1", default-features = false }
base64 = "0.21"
mime_guess = "2.0"
url = "2.4"

golem-rust = { workspace = true }
log = { workspace = true }
reqwest = { workspace = true }
serde.workspace = true
serde_json = { workspace = true }
wit-bindgen-rt = { workspace = true }


[package.metadata.component]
package = "golem:llm-ollama"

[package.metadata.component.bindings]
generate_unused_types = true

[package.metadata.component.bindings.with]
"golem:llm/llm@1.0.0" = "golem_llm::golem::llm::llm"

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

[package.metadata.component.target.dependencies]
"golem:llm" = { path = "wit/deps/golem-llm" }
"wasi:io" = { path = "wit/deps/wasi:io" }
Loading