pub async fn get_content(
client: &mut NlpClient,
request: GetContentRequest,
) -> Result<Vec<GetContentResponse>, Box<dyn Error>>Expand description
Gets the content for the given request.
§Arguments
client- The client to use to communicate with the server.request- The request to send to the server.
§Example
use aristech_nlp_client::{get_client, get_content, TlsOptions};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let mut client = get_client("https://nlp.example.com".to_string(), Some(TlsOptions::default())).await?;
let request = GetContentRequest {
prompt: "What are the lottery numbers?".to_string(),
threshold: 0.5,
return_payload: true,
num_results: 3,
metadata: Some(ContentMetaData {
project_id: "3f6959e6-cfb5-4eed-8195-033d47b73263".to_string(),
exclude_output_from_search: true,
..ContentMetaData::default()
}),
..GetContentRequest::default()
};
let responses = get_content(&mut client, request).await?;
for response in responses {
println!("{:?}", response.items);
}
Ok(())
}