Struct kalosm_language::context::SearchQuery
source · pub struct SearchQuery<'a> { /* private fields */ }
Expand description
A search query that can be used to search for documents on the web.
§Example
// You must have the SERPER_API_KEY environment variable set to run this example.
use kalosm_language::prelude::*;
#[tokio::main]
async fn main() {
let query = "What is the best way to learn a language?";
let api_key = std::env::var("SERPER_API_KEY").unwrap();
let search_query = SearchQuery::new(query, &api_key, 5);
let documents = search_query.into_documents().await.unwrap();
let mut text = String::new();
for document in documents {
for word in document.body().split(' ').take(300) {
text.push_str(word);
text.push(' ');
}
text.push('\n');
}
println!("{}", text);
}
Implementations§
Trait Implementations§
source§impl IntoDocuments for SearchQuery<'_>
impl IntoDocuments for SearchQuery<'_>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for SearchQuery<'a>
impl<'a> Send for SearchQuery<'a>
impl<'a> Sync for SearchQuery<'a>
impl<'a> Unpin for SearchQuery<'a>
impl<'a> UnwindSafe for SearchQuery<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more