async_dashscope/operation/
embeddings.rs1use crate::error::Result;
2use crate::{operation::validate::check_model_parameters, Client};
3pub use output::*;
4pub use param::*;
5
6mod output;
7mod param;
8
9const EMBEDDINGS_PATH: &str = "/services/embeddings/text-embedding/text-embedding";
10
11pub struct Embeddings<'a> {
12 client: &'a Client,
13}
14
15impl<'a> Embeddings<'a> {
16 pub fn new(client: &'a Client) -> Self {
17 Self { client }
18 }
19
20 pub async fn call(&self, request: param::EmbeddingsParam) -> Result<output::EmbeddingsOutput> {
35 let validator = check_model_parameters(&request.model);
37 validator.validate(&request)?;
38
39 self.client.post(EMBEDDINGS_PATH, request).await
42 }
43}