Skip to content

Commit 3597c23

Browse files
committed
init bing
1 parent 21d8b83 commit 3597c23

File tree

7 files changed

+163
-1
lines changed

7 files changed

+163
-1
lines changed

Cargo.lock

Lines changed: 7 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
@@ -1,7 +1,7 @@
11
[workspace]
22
resolver = "2"
33

4-
members = [ "golem-llm/llm", "golem-llm/llm-anthropic", "golem-llm/llm-grok", "golem-llm/llm-ollama", "golem-llm/llm-openai", "golem-llm/llm-openrouter", "golem-web-search/web-search", "golem-web-search/websearch-google"]
4+
members = [ "golem-llm/llm", "golem-llm/llm-anthropic", "golem-llm/llm-grok", "golem-llm/llm-ollama", "golem-llm/llm-openai", "golem-llm/llm-openrouter", "golem-web-search/web-search", "golem-web-search/websearch-bing", "golem-web-search/websearch-google"]
55

66
[profile.release]
77
debug = false
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"rust-analyzer.check.overrideCommand": [
3+
"cargo",
4+
"component",
5+
"check",
6+
"--workspace",
7+
"--all-targets",
8+
"--message-format=json"
9+
],
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "websearch-bing"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
wit-bindgen-rt = { workspace = true, features = ["bitflags"] }
8+
9+
[lib]
10+
crate-type = ["cdylib"]
11+
12+
[package.metadata.component]
13+
package = "component:websearch-bing"
14+
15+
[package.metadata.component.dependencies]
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:websearch-bing:example:encoded world"
97+
)]
98+
#[doc(hidden)]
99+
#[allow(clippy::octal_escapes)]
100+
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 189] = *b"\
101+
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07@\x01A\x02\x01A\x02\x01\
102+
@\0\0s\x04\0\x0bhello-world\x01\0\x04\0\x20component:websearch-bing/example\x04\0\
103+
\x0b\x0d\x01\0\x07example\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit\
104+
-component\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+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#[allow(warnings)]
2+
mod bindings;
3+
4+
use bindings::Guest;
5+
6+
struct Component;
7+
8+
impl Guest for Component {
9+
/// Say hello!
10+
fn hello_world() -> String {
11+
"Hello, World!".to_string()
12+
}
13+
}
14+
15+
bindings::export!(Component with_types_in bindings);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package component:websearch-bing;
2+
3+
/// An example world for the component to target.
4+
world example {
5+
export hello-world: func() -> string;
6+
}

0 commit comments

Comments
 (0)