Requesting support for float32 in Motoko

I would like to request that Motoko implements supports the float32 Candid type.

If I understand it correctly, the Motoko Float maps on the Candid float64, and it does not support float32.

This is inconvenient, because the float32 type is very common in the C/C++ canisters that I am writing, and I now have to create a special interface to allow it being called from Motoko.


In more detail: I am porting C/C++ code to canisters that I then call from Motoko. The Candid interface designed for the C/C++ canisters was build from the inside out, and it uses float32 for the LLM Prompt with variables temperature & topp.

4 Likes

I was wondering when someone would ask for this… Do you want full numeric support for the Float32 type in Motoko or would it be enough to import/export Candid float32 as Float64 with some information loss when exporting as Candid float32 (if that even makes sense).

Does your API merely produce float32s (as results) or also consume them (as arguments)? If the former, we could simply convert them to Float64 on the Motoko side, with no loss of precision. If the latter, we would need Motoko to be able to create Float32 values, which could be a lot more work depending on how much support we provide.

2 Likes

An MVP might be to provide a Float32 type with no literals or operations and conversions from Float64 ↔ Float32. Still a fair whack of work though…

1 Like

In my case I both consume and produce Float32. A conversion to/from Candid Float32 is all I would need.

Thanks for the answer!

Hi there, I just ran into the same issue but for Rust (calling a Rust canister from a Motoko one). Is there any recommended workaround at this point you could share?

If anyone else runs into this, also consider upvoting the issue here
ICP Developer Feedback :slight_smile:

1 Like

Motoko should be able to call another canister expecting/returning float32 just fine, if it was just auto-converted to/from Float. What problem are you running into concretely, and would that be sufficient to solve it?

Hi @rossberg , thank you, I think auto-converting the inputs and the response would solve it in my case.

Posting the two errors I’m getting when calling a Rust canister that expects the input param to be f32:

Error 1

Error: Call was rejected:
Request ID: 6981dde4d2671287fbd4ee351ed3300168d9aa25959704804ae384d26efab740
Reject code: 4
Reject text: IC0503: Error from Canister 44ti7-fiaaa-aaaak-qitia-cai: Canister called ic0.trap with message: failed to decode call arguments: Custom(Fail to decode argument 0 from table0 to variant { Embeddings : vec float32 }

Caused by:
0: input: 4449444c026b01dcbe83bd0c016d72020078_008004000000c008e2a6bf00000020251aa33f000000e02679a9bf000000e04385a5bf00000040e5d8a8bf000000e0b04c8c3f000000c08a7ba93f000000409f7ba9bf000000c03678a93f000000c045c093bf00000060a576a93f000000c05f6ea9bf000000209fc197bf000000604f74a9bf000000a0c476a9bf000000201784a1bf00000080f9a0a6bf00000080b27ba93f000000c01d44a93f0000006074fda53f000000a01e7ba9bf000000e0a66da93f00000000f903a9bf000000c0411592bf00000020d2079dbf00000060c67ca53f000000203763a93f000000e0c46ca93f0000008025a2a6bf000000603738a3bf00000060ff46a93f000000c01806a73f0000006057e7a6bf000000c0de72a9bf000000c03c74a93f000000008b83a73f00000000c602a8bf000000e07e4ca9bf000000809b7ba93f000000a05e63a73f000000409de7a6bf00000060c178a93f00000060fabd9cbf000000e05b79a9bf000000005d9b98bf000000c0e8d698bf000000e0d77aa9bf000000a00060a93f000000602a78a93f00000000cb42a3bf000000603458a93f000000005608a9bf000000204a78a9bf000000e08029a9bf000000e06327a9bf000000205f59a53f000000e05f43a7bf000000c0a477a93f00000060d341a5bf0000002001619e3f000000803978a9bf0000004049e3a83f000000402b5fa9bf000000007e91a6bf000000c02476a93f00000020fd77a9bf00000000b573a9bf000000c054b6a4bf000000e0055d9b3f000000208a75a93f000000c02292a6bf00000040b756a9bf00000040a87ba93f00000020b004a8bf0000008028d2a8bf000000e04902a4bf000000a0ef34973f00000020aa7ba93f000000e05570a4bf000000a0743fa0bf000000605576a9bf000000a0c140a9bf00000020e164a9bf000000801ba3a83f00000020d03fa53f00000060a963a93f000000e04c5da9bf00000040b866a9bf000000a0b17ba9bf000000c06c7aa93f0000002076c1933f00000080b27ba9bf000000800e40a9bf000000e09778a93f000000e084ba9fbf00000060917ba9bf0000004051aa7a3f000000e0667ba9bf00000020ab7aa93f000000003c19a53f000000001860a9bf0000004039369b3f00000020783da93f000000807920a93f000000e02062a6bf000000402c01a7bf000000a0a113a3bf000000802535a93f000000206a1970bf00000060d673a93f000000c06a6ca9bf00000000aa7aa9bf000000a0d87aa9bf000000007968a7bf00000000c64ca23f000000804c7f913f000000e01421a9bf000000e0277aa9bf00000040523191bf0000008099be923f00000060c01e65bf00000060d9c2a5bf000000e0f349a93f000000a0856ca9bf000000c0453ca63f000000809514a73f00000060fcfaa53f00000020450ea93f000000c04b9fa73f0000002014317c3f000000c06cada8bf000000e01c94a8bf00000060fdc7873f00000020844ca3bf000000606f22a9bf00000000797ba9bf00000040257aa93f00000020651fa8bf0000008021b7a3bf000000a03a19a93f000000606b76a9bf000000e0265b8abf00000060ea4da93f000000a0e94e92bf00000020b853a93f00000020c24ba23f00000020e180983f000000a00373a9bf00000080a961a9bf000000001d6aa9bf00000080781d9e3f00000080a47ba9bf000000609778a93f000000c09f85a7bf000000a05e03a7bf000000007e4fa93f000000406a31a13f000000a0116aa93f000000805883a6bf000000e06b047dbf000000007d34a8bf000000009a51a83f000000805764a93f000000e09633903f000000c083e5a8bf000000809d09a9bf000000a0d04fa9bf00000040987ba93f00000000b0d0a7bf000000607453a93f00000000063aa5bf00000000342d93bf00000020e74ca93f000000a0b91fa83f000000c06375a9bf0000004040005dbf000000000077a93f000000c05ec2a13f0000008061b5a73f000000c0dc9598bf000000e0375ba03f000000406b48813f000000e0fd36943f000000e04729a9bf000000c0c36ba93f00000060dd79a83f000000c0107ba93f00000020ec79a93f000000004573a9bf000000607e7ba9bf000000c03f048fbf000000a0e1a9a83f000000a0467ba9bf000000207b089e3f000000e08476a9bf000000800b6aa93f00000040e893a43f000000409969a53f000000a04c2ba9bf00000000d776a93f000000a08eada6bf000000c0cf5ea93f000000a09651a2bf000000e0d8ffa4bf0000008057529d3f000000402f68a93f000000200685a63f00000060a568a93f00000020fb74a5bf000000c09119a5bf00000060116fa93f000000809d6fa93f000000e01a47a93f00000060677ba93f000000a07e6c9d3f000000605258a7bf0000006054f7a5bf000000807659a9bf00000000aee4a8bf000000609993963f000000a00feb94bf000000c0f90aa9bf000000008c45a9bf00000080427aa93f00000020e933a83f0000000029a0a7bf00000000715ca93f000000c0bba27bbf00000020bd93953f000000601465a9bf000000c0d956a9bf000000e080dfa3bf00000040758695bf00000080ecafa73f00000040b924a4bf000000a0ad7ba9bf00000080e718a93f00000040d9a39f3f00000060788…00000c08d7ba9bf00000080fba6a83f000000e06d7ba9bf00000020e68da63f000000601deba83f00000020b17ba9bf000000407e76a93f000000c00f76a9bf0000004040a9a1bf000000e04b6da93f000000e04c5da93f00000040a056a6bf000000e0b97aa93f000000005ce1a3bf000000401476a8bf000000605070a93f000000e014aba7bf000000808e78a93f000000a0f958933f000000c0d051a9bf000000c07e7ba93f00000040985f92bf000000805156a9bf00000060865ba93f000000206073a93f00000060af7aa93f000000e0409fa8bf000000a01b03a7bf0000008003cba63f00000040f208a93f000000e0e5aca43f000000609f6ba93f0000006069e997bf00000000ca87a7bf000000000eac9ebf00000080dd02a93f000000c02879a93f0000002086f560bf000000c03e39a73f00000080d070a9bf00000020ac12a9bf000000a09bfca83f000000007308a6bf000000a08178a9bf00000080c252a93f000000002ec7973f000000a0e68fa43f000000803474a93f000000c0bf52a9bf000000404c8da83f000000402e73a93f000000408e7ba93f000000a0fbfaa7bf00000080d961a73f00000060d176a93f000000207f4ba8bf00000060bb13a73f000000809d349bbf000000604d77a93f000000e0a806a83f000000e0396ea0bf000000e0eeeda43f000000400cf182bf000000007cffa83f000000e06cae8ebf000000809023a6bf00000060a68fa83f000000a0e25ea93f000000206744a7bf000000809906a33f00000000d05195bf000000a0796da93f00000080317ba9bf00000000446aa83f000000402070a93f00000040f0c9993f000000600c7aa9bf000000003daba3bf00000060e179a9bf000000805f65a83f00000060e839a63f00000060cd71a93f000000e01564a93f00000080227ca8bf000000c029e5913f00000000346ea93f00000060da938ebf00000060d4c8a73f000000408972a93f000000a06347a9bf000000e09a6ea93f000000a09bc49f3f00000020e6f548bf00000000a412a93f000000001841a9bf00000020d869a9bf000000a0be6da93f000000208e7fa83f000000e07241a9bf00000040e942a9bf000000c0c0b4843f000000408409a7bf000000a0713fa93f000000e0b27ba9bf000000605b7aa9bf000000804266a23f000000e0987ba9bf000000209d6ca9bf000000008d7ba93f00000060813da83f00000040bfd9a83f00000080f78aa5bf000000805314a3bf00000020216ca53f000000c0a534a5bf000000a03f03a93f000000a0387ba9bf000000a0d7aca73f000000a05b8ba83f000000a08e7ba93f00000040a8c5a13f00000060a97ba93f0000004081e9a83f00000080a049a4bf00000080a07ba9bf000000609edca0bf000000a0287aa93f000000600a69a93f000000207512a5bf00000000471e8dbf000000a09d7ba9bf000000e0200a953f000000e0e77aa9bf00000020ce5ba9bf000000a0e948a93f000000805a77a9bf000000808d48a9bf0000006035f497bf000000407477a93f000000c0bb73a93f00000040dbeba83f000000c0f5a8783f000000e0df77a9bf000000c02e4aa9bf000000c03a4f693f000000e04044a93f00000020417aa9bf00000080417ba9bf000000e043eea83f00000060b17ba93f00000040b5eaa83f000000c0f223a9bf0000006077098cbf00000040967ba93f000000a0cf57a93f00000020f479a93f0000002040f5a83f00000020b86aa83f00000080f4b5a33f000000c0647aa9bf00000020147ba9bf000000205ad9a5bf000000c0677ba9bf000000003d71a9bf00000040a77aa9bf000000a0a97aa93f00000060dea7a83f000000606964a9bf00000040c600a8bf000000e0de78a9bf000000c0d08da6bf000000a0927ba93f000000401c75a93f000000e02492a7bf00000080ba4aa93f000000207f88a53f000000c0b466a9bf00000040ae10a0bf000000a07faca7bf00000080427ba93f000000c0417ba9bf000000c07179a93f000000c0a831a93f000000e0e778a93f000000802776a93f000000c0fe33a8bf000000a072d1a8bf00000060df1da9bf00000020b8cda83f000000a0d26aa93f000000c04079a93f000000806b72a93f000000000a5ba73f000000e0b57f843f000000e02f6aa93f00000040d668a9bf00000020d01ea9bf000000004b7ba9bf00000000b273a83f000000a0434fa93f0000000059b8a6bf000000e065d1a1bf00000060b8f0a5bf00000000fe57a7bf000000e0f8d8a8bf000000806079a93f000000a09a0fa93f000000800ae9a8bf000000c0320ca8bf00000000f223a9bf00000060c502a03f0000002006929c3f000000201f72a53f00000080e168a93f000000800942a4bf000000600e7ba93f000000c0d009a9bf000000609461a93f00000040c67aa9bf0100000000000000
table: type table0 = variant { 3_349_208_924 : table1 }
type table1 = vec float64
wire_type: table0, expect_type: variant { Embeddings : vec float32 }
1: table0 is not a subtype of variant { Embeddings : vec float32 }
2: Variant field 3_349_208_924: table1 is not a subtype of vec float32
3: float64 is not a subtype of float32).
Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: Execution errors | Internet Computer

at pollForResponse (index-4f5b4824.js:840:1162)
at async I (index-4f5b4824.js:847:3680)
at async searchUserKnowledgebase (index-4f5b4824.js:16462:9345)
at async e (index-4f5b4824.js:16513:3265)

This is the code:

Motoko:

public type Embeddings = [Float];
type VecQuery = { #Embeddings : Types.Embeddings };
type PlainDoc = { content : Text };

public shared ({caller}) func search_user_knowledgebase(embeddings: Types.Embeddings) : async Types.SearchKnowledgeBaseResult {
    let knowledgebaseCanister = actor(knowledgebaseCanisterId): actor { search: (VecQuery, Nat64) -> async ?[PlainDoc] };
    let result = await knowledgebaseCanister.search(#Embeddings(embeddings), 1);
    switch (result) {
      case (null) { return #Err(#Other("none found")); };
      case (?resultDocs) { return #Ok(resultDocs[0].content); };
    };   
  };

Rust:

#[derive(CandidType, Serialize, Deserialize, Debug, Clone)]
pub enum VecQuery {
    Embeddings(Vec<f32>),
}

#[derive(CandidType, Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct PlainDoc {
    pub content: String,
}

pub fn search(vec_query: VecQuery, k: usize) -> Option<Vec<PlainDoc>>

Error 2

Error: Call was rejected:
Request ID: a0f744f60e185f033c712545c43e698e5b7733263c3924b3f9e76655a3681bf9
Reject code: 4
Reject text: IC0503: Error from Canister 44ti7-fiaaa-aaaak-qitia-cai: Canister called ic0.trap with message: failed to decode call arguments: Custom(Fail to decode argument 0 from table0 to record { content : text; embeddings : vec float32 }

Caused by:
0: input: 4449444c026c02b99adecb0171bcb6bf870d016d720100_0e7468697320697320612074657374800400000040893b8e3f00000040c401aebf000000e05297adbf00000040b2a77cbf000000a006d894bf000000c016859cbf000000c0dac1ac3f00000020a0f49dbf00000040b048acbf0000002093d7a4bf00000000b21dab3f0000004079a9a63f0000008073baadbf000000204bea84bf0000006000d84c3f00000020018a9d3f000000c0cf17adbf00000020156f88bf0000002063a5acbf000000204ec7a83f000000c043239dbf000000405f5dac3f000000402f969e3f000000e05214aa3f000000a00cc2933f00000020347e963f00000080796fadbf000000009bbb9f3f000000e0c31dadbf000000c07cda923f000000c0dfdfa8bf000000a0fe36a6bf000000a08f698e3f000000e05de2adbf00000040b949523f000000806e89993f00000020bb0eadbf00000040e82fad3f000000e05ee2ab3f0000002023eeab3f0000004087f6a93f000000e0586da93f000000e00552ac3f000000202dfcadbf000000407077a0bf000000809495aa3f00000040c6ab723f000000e05f87ad3f00000080929283bf00000040cfda9cbf00000020005d993f00000060e8b1ad3f00000040c166a83f000000e0f795ad3f00000060ea26a7bf00000000e44a9cbf0000004098c5abbf00000060e5a89dbf000000c0b2b7a03f000000a0d343adbf0000008017c1ad3f00000020528287bf0000006093d3adbf000000201099aabf00000000ca53a83f000000e0f377a73f000000e05dac5b3f000000e025daa9bf00000040e64bad3f000000c094caa53f000000606091abbf0000004007b4a5bf0000006022fcad3f000000a01c1b9d3f000000c0b790a73f000000602447abbf000000c01588a83f000000a0c103ae3f00000020e708acbf000000e0b8c8abbf00000020bb9dac3f000000201667acbf00000080b532abbf000000205d8ba83f000000a07210a53f00000000efe3ad3f0000000042f5a63f000000005404acbf0000006037e0acbf000000003f469ebf00000020b51085bf000000e0e44f973f000000c0d8b3a93f000000e09ac792bf000000603a4facbf000000c03964ad3f000000201eaca03f00000080353ea7bf000000e07be0abbf000000c0434c90bf0000002076c6adbf000000a0acf2a93f00000020b3de8abf000000002a60ab3f00000080d2dea9bf00000080d3ada2bf00000080c1d5adbf000000c072cfaa3f000000600ec280bf00000000d7349c3f0000006019fdabbf00000000127ca8bf000000005591acbf0000006054a3adbf000000c085e7a73f0000008073447cbf00000020f683adbf0000002033eda3bf000000c02cdea03f00000080746773bf000000801352903f00000020db58a9bf000000404061a8bf00000080d98fa1bf000000c06b21adbf00000020ee6fa4bf00000040daf997bf0000002086399a3f000000001215ab3f00000080dfdaa7bf000000e05c2e983f000000c0a030acbf000000a0011ba5bf000000c081fdad3f000000a0f1b4a1bf000000e0ded6adbf0000008004faa6bf000000e019f889bf000000205ec5a8bf00000020c21aad3f00000020823c89bf00000080d9709c3f000000a0478fac3f00000040f899ad3f00000040dda2ad3f00000000d5cd943f000000403d13ad3f00000060bf61ac3f000000c05ca59abf000000403367a03f000000400ce39fbf000000e076bdacbf000000c049f47fbf00000060e420ad3f000000c006e4a0bf000000807bdc853f000000e01451a8bf000000a0766b99bf00000080b614a73f00000080d5318fbf0000006093e2a3bf000000c00ae8ad3f000000e09ce5ac3f000000e0a2e2acbf0000008061b2953f00000080150395bf0000006030e49dbf000000003f2b6abf00000060fb2692bf00000020c2619b3f00000040c301a3bf000000c046b08e3f00000000a40c883f00000020db3686bf00000040806fabbf000000a0928c923f0000004059f49a3f00000060df03ae3f0000000017fc903f000000a0b029ac3f00000000f2987fbf00000000c010ad3f000000604d98ad3f000000204365adbf000000e011b38ebf000000400ae7abbf00000040f453a63f000000e09cf5ab3f000000407362a4bf000000c03a0ea8bf000000a0f9b7adbf000000200684a93f000000e07f9eac3f000000805240ab3f000000006a4baa3f000000c0c05d94bf000000600ff2ab3f00000000ddbda63f000000606275a43f000000c0e1fb8abf00000040398da9bf000000c04ee3a4bf000000202401aebf0000000032ebabbf00000060afe59e3f0000002098dfa9bf000000207cf0ad3f000000c0abe7ad3f000000204597743f000000e06feba83f000000a0f6c1a9bf000000c0bcf39d3f00000060f4219c3f0000002000b549bf00000000f19191bf000000a00bd78abf00000020897eaa3f000000c0e4c7ad3f000000a029d8ad3f000000806e19a63f0000002007d9a4bf000000409555743f000000806ac2973f00000060b802aebf000000405b68a13f000000c0adaeadbf00000000a663a5bf000000608ba3adbf000000c062a8a9bf000000c097f2adbf000000a01ddcadbf000000a08cba98bf000000e0239556bf00000060b03e763f000000406b7faabf000000…3f0000006041e9adbf000000e022ddad3f000000e00f1ba53f000000400ecaadbf000000c0525eac3f000000c08243adbf00000040a986a93f0000008057f5aabf0000006047c6ac3f000000c01f2aabbf000000a0ea6f9abf000000c0aa27adbf000000a0307bab3f000000a0f15ba9bf0000000095c5a1bf000000c006eaab3f0000000089e7ad3f00000000d74aad3f000000c0f1f4ad3f00000040f88d93bf000000e0432babbf00000000d8f4a2bf000000c00477a8bf000000c0069ea53f000000a00d0a943f00000040cd57933f000000c0867d4cbf000000e03dbda33f000000a08a1c953f000000c016ddacbf000000e04ec2ad3f00000020b54a923f000000808b58adbf00000040ff6da5bf00000020a4e4adbf000000400733a53f000000e035eea4bf00000040e3de9abf000000e051fca9bf000000204352ab3f0000000056fcad3f00000060b891a7bf0000006054dead3f000000a07959a6bf000000205b20a9bf000000808bcfadbf00000000da4f863f000000606404abbf000000a08da7adbf000000401a00ad3f000000e0f7e99ebf00000040777cac3f000000206ed1ad3f000000404e4b603f0000000070e4ac3f000000c09a6f77bf00000060ea96a33f00000020532fa8bf000000e0dfa99b3f000000c00051a3bf000000c0b79ca63f000000e028a285bf000000e064208fbf000000e01acaa23f0000008024e5a93f000000001618ab3f000000a04e1aab3f000000c0a16f94bf0000008002ccadbf00000000d232953f000000c0dff7a1bf0000002041f6aa3f0000002023a4a5bf00000000e4a6903f000000c0e47cadbf00000000cb0d9dbf000000e05f09783f000000c0075ba0bf000000209b4bac3f0000000099c37fbf000000204246a33f000000e0559b6cbf000000c0b78aadbf000000003866873f00000080a7e2ad3f00000020ab2fadbf000000a05361aabf00000020b2bbacbf000000c01d9c8b3f000000e0b1caab3f00000080b9bda4bf00000060cb9f91bf000000403f2aa03f000000c0e37c7cbf000000a0fa8a843f00000080cd6595bf00000020ca2daa3f000000c0fb0fa53f00000020c392ab3f000000c0269ea4bf000000005f56ad3f000000c0e184ad3f000000c01e5ba8bf000000e0d390a3bf00000020caf594bf00000080f2a7a03f000000207aacaa3f000000a0d519a6bf000000205ca0a43f00000060a0f9a63f000000e06956443f0000002069ccad3f000000a0b46792bf000000a0015c993f000000a091d69e3f000000e068bca7bf000000e0397585bf000000c02e8b933f000000a0f1b89b3f000000403dbaac3f000000c032a0adbf000000a03812adbf000000404ae2a6bf00000020fefeaa3f0000002001efad3f000000600573923f0000008074bea3bf000…3f000000a0fa9fa1bf000000a02d67ab3f00000020e914a93f0000000080d7983f00000020e7628abf00000060eeecadbf00000060a8ada9bf000000a0cab1aa3f0000002089efa63f000000006035933f000000a0fb23a2bf00000000412ead3f000000408610acbf000000206eadadbf000000409306a6bf00000040358cadbf000000004171a5bf000000804651723f000000e0d23c70bf000000a0e349a63f000000800bc4ac3f00000020d7e7a3bf0000002080eba3bf00000000e0c892bf000000200e0cacbf00000060a22dad3f0000008096c3acbf000000000beb723f000000c09325adbf000000c0d100ae3f000000a0f1e7abbf000000a003e4ad3f000000607bfeadbf000000004f14adbf000000405fa0adbf000000c0c75bad3f000000e067aca53f000000e0b0f4acbf000000e0bb94ad3f000000c0060ca33f000000e083fc993f00000040851464bf00000060fda9ad3f000000a0f8d4993f000000a09fe2a93f000000c0ce79aabf000000a06dddabbf000000809a7ea0bf00000000b57aac3f000000c0c13cad3f000000606a32a8bf000000c03772a93f00000000551c993f00000040048bad3f0000008026bf84bf000000400e02aa3f00000000215baabf000000208b754ebf0000006055d3a63f000000209ff0acbf000000206729adbf0000000049c0adbf000000a0e52aa8bf00000020ac99a93f000000a010ce8a3f000000e03217adbf000000801f97ab3f000000a065fcacbf000000a0b53b793f000000407bac89bf00000020969caa3f000000207ed0ac3f000000e0a3f2ad3f00000020c7afadbf000000a0f53b973f00000020ad65a73f000000e04a58683f0000006039ae9e3f000000808409ac3f00000020c5dcadbf000000807ad185bf000000800fb085bf0000004072b2963f000000e0e3b4ad3f00000040a122993f000000a0b165833f00000040fa7badbf000000a069bb9b3f000000a0a97796bf
table: type table0 = record { 427_265_337 : text; 3_505_380_156 : table1 }
type table1 = vec float64
wire_type: table0, expect_type: record { content : text; embeddings : vec float32 }
1: table0 is not a subtype of record { content : text; embeddings : vec float32 }
2: Record field embeddings: table1 is not a subtype of vec float32
3: float64 is not a subtype of float32).
Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: Execution errors | Internet Computer

at pollForResponse (index-4f5b4824.js:840:1162)
at async I (index-4f5b4824.js:847:3680)
at async addToUserKnowledgebase (index-4f5b4824.js:16462:8926)
at async I (index-4f5b4824.js:16513:3158)

This is the code:

Motoko:

public type Embeddings = [Float];

type VecDoc = { content : Text; embeddings : Types.Embeddings };

  public shared({ caller }) func add_to_user_knowledgebase(content: Text, embeddings: Types.Embeddings) : async Types.MemoryVectorsStoredResult {    
    let knowledgebaseCanister = actor(knowledgebaseCanisterId): actor { add: (VecDoc) -> async Text };
    let result = await knowledgebaseCanister.add({content=content ; embeddings=embeddings});

    return #Ok(true);
  };

Rust:

pub type Embeddings = Vec<f32>;

#[derive(CandidType, Serialize, Deserialize, Debug, Clone)]
pub struct VecDoc {
    pub content: String,
    pub embeddings: Embeddings,
}

pub fn add(doc: VecDoc) -> String 

I solved it for now by changing all f32 to f64 in the Rust code