Skip to content

Durable Search Provider implementation for golem:search #52

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ members = [
"llm/ollama",
"llm/openai",
"llm/openrouter",
"search/search",
"search/elasticsearch",
"search/opensearch",
"search/algolia",
"search/typesense",
"search/meilisearch",
"test/components-rust/test-search",
]

[profile.release]
Expand All @@ -19,10 +26,16 @@ opt-level = 's'
golem-rust = "1.6.0"
log = "0.4.27"
golem-llm = { path = "llm/llm", version = "0.0.0", default-features = false }
golem-search = { path = "search/search", version = "0.0.0", default-features = false }
reqwest = { git = "https://github.com/golemcloud/reqwest", branch = "update-may-2025", features = [
"json",
] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
wit-bindgen-rt = { version = "0.40.0", features = ["bitflags"] }
wit-bindgen = { version = "0.40.0" }
base64 = { version = "0.22.1" }
sha2 = { version = "0.10" }
hmac = { version = "0.12" }
hex = { version = "0.4" }
chrono = { version = "0.4", features = ["serde"] }
16 changes: 8 additions & 8 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ args = ["test"]
[tasks.build]
script_runner = "@duckscript"
script = '''
domains = array llm
domains = array llm search

# if there is no domain passed run for every domain
if is_empty ${1}
Expand All @@ -28,7 +28,7 @@ end
[tasks.release-build]
script_runner = "@duckscript"
script = '''
domains = array llm
domains = array llm search

# if there is no domain passed run for every domain
if is_empty ${1}
Expand All @@ -44,7 +44,7 @@ end
script_runner = "@duckscript"
script = '''
#!/bin/bash
domains = array llm
domains = array llm search

# if there is no domain passed run for every domain
if is_empty ${1}
Expand All @@ -60,7 +60,7 @@ end
script_runner = "@duckscript"
script = '''
#!/bin/bash
domains = array llm
domains = array llm search

# if there is no domain passed run for every domain
if is_empty ${1}
Expand All @@ -75,7 +75,7 @@ end
[tasks.wit]
script_runner = "@duckscript"
script = '''
domains = array llm
domains = array llm search

# if there is no domain passed run for every domain
if is_empty ${1}
Expand All @@ -91,7 +91,7 @@ end
description = "Builds all test components with golem-cli"
script_runner = "@duckscript"
script = '''
domains = array llm
domains = array llm search

# if there is no domain passed run for every domain
if is_empty ${1}
Expand Down Expand Up @@ -137,7 +137,7 @@ script = '''

is_portable = eq ${1} "--portable"

targets = array llm_openai llm_anthropic llm_grok llm_openrouter llm_ollama
targets = array llm_openai llm_anthropic llm_grok llm_openrouter llm_ollama search_elasticsearch search_opensearch search_algolia search_typesense search_meilisearch
for target in ${targets}
if is_portable
cp target/wasm32-wasip1/debug/golem_${target}.wasm components/debug/golem_${target}-portable.wasm
Expand All @@ -153,7 +153,7 @@ script = '''

is_portable = eq ${1} "--portable"

targets = array llm_openai llm_anthropic llm_grok llm_openrouter llm_ollama
targets = array llm_openai llm_anthropic llm_grok llm_openrouter llm_ollama search_elasticsearch search_opensearch search_algolia search_typesense search_meilisearch
for target in ${targets}
if is_portable
cp target/wasm32-wasip1/release/golem_${target}.wasm components/release/golem_${target}-portable.wasm
Expand Down
185 changes: 185 additions & 0 deletions search/Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
[config]
default_to_workspace = false
skip_core_tasks = true

[tasks.build]
run_task = { name = [
"build-elasticsearch",
"build-opensearch",
"build-algolia",
"build-typesense",
"build-meilisearch",
] }

[tasks.build-portable]
run_task = { name = [
"build-elasticsearch-portable",
"build-opensearch-portable",
"build-algolia-portable",
"build-typesense-portable",
"build-meilisearch-portable",
] }

[tasks.release-build]
run_task = { name = [
"release-build-elasticsearch",
"release-build-opensearch",
"release-build-algolia",
"release-build-typesense",
"release-build-meilisearch",
] }

[tasks.release-build-portable]
run_task = { name = [
"release-build-elasticsearch-portable",
"release-build-opensearch-portable",
"release-build-algolia-portable",
"release-build-typesense-portable",
"release-build-meilisearch-portable",
] }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[tasks.wit-update]
install_crate = { crate_name = "wit-deps-cli" }
command = "wit-deps"
args = ["update"]

[tasks.wit]
dependencies = ["wit-update"]

script_runner = "@duckscript"
script = """
modules = array search elasticsearch opensearch algolia typesense meilisearch

for module in ${modules}
rm -r ${module}/wit/deps
mkdir ${module}/wit/deps/golem-search
cp wit/golem-search.wit ${module}/wit/deps/golem-search/golem-search.wit
cp wit/deps/wasi:io ${module}/wit/deps

echo "Copied WIT for module search::${module}"
end

echo "Copied WIT for module search"
"""

[tasks.build-test-components]
dependencies = ["build"]
install_crate = "cargo-binstall"
description = "Builds search test components with golem-cli"
script = '''
cargo-binstall golem-cli@1.2.2-dev.11 --locked --no-confirm
cargo-binstall wac-cli --locked --no-confirm
cd ../test

golem-cli --version
golem-cli app clean
golem-cli app build -b elasticsearch-debug
golem-cli app clean
golem-cli app build -b opensearch-debug
golem-cli app clean
golem-cli app build -b algolia-debug
golem-cli app clean
golem-cli app build -b typesense-debug
golem-cli app clean
golem-cli app build -b meilisearch-debug
'''
41 changes: 41 additions & 0 deletions search/algolia/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "golem-search-algolia"
version = "0.0.0"
edition = "2021"
license = "Apache-2.0"
homepage = "https://golem.cloud"
repository = "https://github.com/golemcloud/golem-llm"
description = "WebAssembly component for working with Algolia APIs, with special support for Golem Cloud"

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

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

[dependencies]
golem-search = { path = "../search" }
golem-rust = "1.6.0"
log = "0.4.27"
reqwest = { git = "https://github.com/golemcloud/reqwest", branch = "update-may-2025", features = ["json", "blocking"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wit-bindgen-rt = { version = "0.40.0", features = ["bitflags"] }

[package.metadata.component]
package = "golem:search-algolia"

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

[package.metadata.component.bindings.with]
"golem:search/core@1.0.0" = "golem_search::golem::search::core"

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

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