-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support extractor for deepseek (#255)
* feat: support extractor for deepseek * fixed: cargo fmt * make code tidy * add DEEPSEEK_REASONER completion model
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use rig::providers::deepseek; | ||
use schemars::JsonSchema; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Deserialize, JsonSchema, Serialize)] | ||
/// A record representing a person | ||
struct Person { | ||
/// The person's first name, if provided (null otherwise) | ||
pub first_name: Option<String>, | ||
/// The person's last name, if provided (null otherwise) | ||
pub last_name: Option<String>, | ||
/// The person's job, if provided (null otherwise) | ||
pub job: Option<String>, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), anyhow::Error> { | ||
// Create DeepSeek client | ||
let deepseek_client = deepseek::Client::from_env(); | ||
|
||
// Create extractor | ||
let data_extractor = deepseek_client | ||
.extractor::<Person>(deepseek::DEEPSEEK_CHAT) | ||
.build(); | ||
|
||
let person = data_extractor | ||
.extract("Hello my name is John Doe! I am a software engineer.") | ||
.await?; | ||
|
||
println!( | ||
"DeepSeek: {}", | ||
serde_json::to_string_pretty(&person).unwrap() | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters