forked from 0xPlaygrounds/rig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperplexity_agent.rs
34 lines (29 loc) · 900 Bytes
/
perplexity_agent.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::env;
use rig::{
completion::Prompt,
providers::{self, perplexity::LLAMA_3_1_70B_INSTRUCT},
};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// Create OpenAI client
let client = providers::perplexity::Client::new(
&env::var("PERPLEXITY_API_KEY").expect("PERPLEXITY_API_KEY not set"),
);
// Create agent with a single context prompt
let agent = client
.agent(LLAMA_3_1_70B_INSTRUCT)
.preamble("Be precise and concise.")
.temperature(0.5)
.additional_params(json!({
"return_related_questions": true,
"return_images": true
}))
.build();
// Prompt the agent and print the response
let response = agent
.prompt("When and where and what type is the next solar eclipse?")
.await?;
println!("{}", response);
Ok(())
}