pub struct KagiConfig {
pub api_key: String,
pub api_base: String,
pub logdir: Option<PathBuf>,
}
Fields§
§api_key: String
§api_base: String
§logdir: Option<PathBuf>
Implementations§
Source§impl KagiConfig
impl KagiConfig
Sourcepub fn with_api_key(api_key: &str) -> Self
pub fn with_api_key(api_key: &str) -> Self
Examples found in repository?
examples/simple-fastgpt.rs (line 5)
4async fn main() {
5 let config = kagi_api::KagiConfig::with_api_key("api key goes here");
6 let client = kagi_api::KagiClient::new(config);
7
8 let use_cache = true;
9 let answer = client
10 .fastgpt("How do I entertain my cat?", use_cache)
11 .await
12 .expect("A valid FastGPT search result");
13
14 // FIXME: Cannot `.render()` without kagi-cli: Remove `Render` trait's coupling from `Args`.
15 serde_json::to_writer_pretty(std::io::stdout(), &answer).unwrap();
16}
More examples
examples/simple-summary.rs (line 5)
4async fn main() {
5 let config = kagi_api::KagiConfig::with_api_key("api key goes here");
6 let client = kagi_api::KagiClient::new(config);
7 let options = SummaryOptions::default();
8
9 let some_url = url::Url::parse("https://en.wikipedia.org/wiki/A_Cyborg_Manifesto").unwrap();
10 let summary = client
11 .summarize_url(some_url, options)
12 .await
13 .expect("A valid Universal Summarizer result");
14
15 // FIXME: Cannot `.render()` without kagi-cli: Remove `Render` trait's coupling from `Args`.
16 serde_json::to_writer_pretty(std::io::stdout(), &summary).unwrap();
17}
pub fn from_env() -> KagiResult<KagiConfig>
Trait Implementations§
Source§impl Clone for KagiConfig
impl Clone for KagiConfig
Source§fn clone(&self) -> KagiConfig
fn clone(&self) -> KagiConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for KagiConfig
impl RefUnwindSafe for KagiConfig
impl Send for KagiConfig
impl Sync for KagiConfig
impl Unpin for KagiConfig
impl UnwindSafe for KagiConfig
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