nano_ai/
adapter.rs

1#![allow(unused)]
2#![allow(deprecated)]
3
4use js_sys::{Object, Promise};
5use wasm_bindgen::prelude::*;
6
7#[wasm_bindgen]
8extern "C" {
9    #[wasm_bindgen(js_namespace = window, js_name = ai)]
10    pub static AI: Ai;
11
12    #[wasm_bindgen(js_namespace = ai, js_name = AILanguageModelFactory)]
13    pub static AILANGUAGE_MODEL_FACTORY: ModelFactory;
14
15    #[wasm_bindgen(js_namespace = ai, js_name = AILanguageModel)]
16    pub static AILANGUAGE_MODEL: Session;
17
18    #[wasm_bindgen(extends = Object)]
19    pub type Ai;
20
21    #[wasm_bindgen(extends = Object)]
22    pub type ModelFactory;
23
24    #[wasm_bindgen(extends = Object)]
25    pub type Session;
26
27    #[wasm_bindgen(method, getter, js_name = languageModel)]
28    pub fn language_model(this: &Ai) -> ModelFactory;
29
30    #[wasm_bindgen(method, js_name = capabilities)]
31    pub fn capabilities(this: &ModelFactory) -> Promise;
32
33    #[wasm_bindgen(method, js_name = create)]
34    pub fn create(this: &ModelFactory) -> Promise;
35
36    #[wasm_bindgen(method, js_name = prompt)]
37    pub fn prompt(this: &Session, input: &str) -> Promise;
38
39    #[wasm_bindgen(method, js_name = promptStreaming)]
40    pub fn prompt_streaming(this: &Session, input: &str) -> Promise;
41
42    #[wasm_bindgen(method, js_name = destroy)]
43    pub fn destroy(this: &Session) -> Promise;
44
45    #[wasm_bindgen(method, js_name = clone)]
46    pub fn clone_session(this: &Session) -> Promise;
47}