Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rig/rig-core/tests/deepseek/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::support::{BASIC_PREAMBLE, BASIC_PROMPT, assert_nonempty_response};
async fn completion_smoke() {
let client = deepseek::Client::from_env().expect("client should build");
let agent = client
.agent(deepseek::DEEPSEEK_CHAT)
.agent(deepseek::DEEPSEEK_V4_FLASH)
.preamble(BASIC_PREAMBLE)
.build();

Expand Down
2 changes: 1 addition & 1 deletion rig/rig-core/tests/deepseek/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::support::{EXTRACTOR_TEXT, SmokePerson, assert_nonempty_response};
async fn extractor_smoke() {
let client = deepseek::Client::from_env().expect("client should build");
let extractor = client
.extractor::<SmokePerson>(deepseek::DEEPSEEK_CHAT)
.extractor::<SmokePerson>(deepseek::DEEPSEEK_V4_FLASH)
.build();

let person = extractor
Expand Down
24 changes: 18 additions & 6 deletions rig/rig-core/tests/deepseek/extractor_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ fn assert_compatible_professions(left: Option<&str>, right: &str) -> Result<()>
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn extract_backward_compatibility() -> Result<()> {
let client = deepseek::Client::from_env().expect("client should build");
let extractor = client.extractor::<Person>(deepseek::DEEPSEEK_CHAT).build();
let extractor = client
.extractor::<Person>(deepseek::DEEPSEEK_V4_FLASH)
.build();

let person = extractor
.extract("John Doe is a 30 year old software engineer.")
Expand All @@ -66,7 +68,9 @@ async fn extract_backward_compatibility() -> Result<()> {
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn extract_with_usage_returns_data_and_usage() -> Result<()> {
let client = deepseek::Client::from_env().expect("client should build");
let extractor = client.extractor::<Person>(deepseek::DEEPSEEK_CHAT).build();
let extractor = client
.extractor::<Person>(deepseek::DEEPSEEK_V4_FLASH)
.build();

let response: ExtractionResponse<Person> = extractor
.extract_with_usage("Jane Smith is a 45 year old data scientist.")
Expand Down Expand Up @@ -94,7 +98,9 @@ async fn extract_with_usage_returns_data_and_usage() -> Result<()> {
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn extract_with_chat_history_with_usage_works() -> Result<()> {
let client = deepseek::Client::from_env().expect("client should build");
let extractor = client.extractor::<Address>(deepseek::DEEPSEEK_CHAT).build();
let extractor = client
.extractor::<Address>(deepseek::DEEPSEEK_V4_FLASH)
.build();

let chat_history = vec![Message::user(
"I'm looking at a property that might be interesting.",
Expand Down Expand Up @@ -137,7 +143,9 @@ async fn extract_with_chat_history_with_usage_works() -> Result<()> {
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn extract_and_extract_with_usage_return_same_data() -> Result<()> {
let client = deepseek::Client::from_env().expect("client should build");
let extractor = client.extractor::<Person>(deepseek::DEEPSEEK_CHAT).build();
let extractor = client
.extractor::<Person>(deepseek::DEEPSEEK_V4_FLASH)
.build();

let text = "Bob Johnson is a 55 year old retired teacher.";
let person = extractor.extract(text).await?;
Expand Down Expand Up @@ -175,7 +183,9 @@ async fn extract_and_extract_with_usage_return_same_data() -> Result<()> {
async fn usage_tracking_works_for_different_schemas() -> Result<()> {
let client = deepseek::Client::from_env().expect("client should build");

let person_extractor = client.extractor::<Person>(deepseek::DEEPSEEK_CHAT).build();
let person_extractor = client
.extractor::<Person>(deepseek::DEEPSEEK_V4_FLASH)
.build();
let person_response = person_extractor
.extract_with_usage("Alice is a 25 year old developer.")
.await?;
Expand All @@ -184,7 +194,9 @@ async fn usage_tracking_works_for_different_schemas() -> Result<()> {
"expected person usage tokens"
);

let address_extractor = client.extractor::<Address>(deepseek::DEEPSEEK_CHAT).build();
let address_extractor = client
.extractor::<Address>(deepseek::DEEPSEEK_V4_FLASH)
.build();
let address_response = address_extractor
.extract_with_usage("456 Oak Avenue, Cambridge, MA 02139")
.await?;
Expand Down
1 change: 1 addition & 0 deletions rig/rig-core/tests/deepseek/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod agent;
mod extractor;
mod extractor_usage;
mod models;
mod multi_extract;
mod permission_control;
mod reasoning_roundtrip;
Expand Down
33 changes: 33 additions & 0 deletions rig/rig-core/tests/deepseek/models.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//! DeepSeek model listing smoke test.
//!
//! Run with:
//! `cargo test -p rig-core --test deepseek deepseek::models::list_models_smoke -- --ignored --nocapture`

use rig::client::{ModelListingClient, ProviderClient};
use rig::providers::deepseek;

#[tokio::test]
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn list_models_smoke() {
let client = deepseek::Client::from_env().expect("client should build");
let models = match client.list_models().await {
Ok(models) => models,
Err(error) => {
panic!("listing DeepSeek models should succeed\nDisplay: {error}\nDebug: {error:#?}")
}
};

assert!(
!models.is_empty(),
"expected DeepSeek to return at least one model\nModel list: {models:#?}"
);

assert!(
models
.iter()
.any(|model| model.owned_by.as_deref() == Some("deepseek")),
"expected at least one DeepSeek-owned model\nModel list: {models:#?}"
);

println!("DeepSeek returned {} models", models.len());
}
6 changes: 3 additions & 3 deletions rig/rig-core/tests/deepseek/multi_extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ struct Sentiment {
async fn batch_multi_extract_chain() -> Result<()> {
let client = deepseek::Client::from_env().expect("client should build");
let names_extractor = client
.extractor::<Names>(deepseek::DEEPSEEK_CHAT)
.extractor::<Names>(deepseek::DEEPSEEK_V4_FLASH)
.preamble("Extract names from the given text.")
.retries(2)
.build();
let topics_extractor = client
.extractor::<Topics>(deepseek::DEEPSEEK_CHAT)
.extractor::<Topics>(deepseek::DEEPSEEK_V4_FLASH)
.preamble("Extract topics from the given text.")
.retries(2)
.build();
let sentiment_extractor = client
.extractor::<Sentiment>(deepseek::DEEPSEEK_CHAT)
.extractor::<Sentiment>(deepseek::DEEPSEEK_V4_FLASH)
.preamble("Extract sentiment and confidence from the given text.")
.retries(2)
.build();
Expand Down
4 changes: 2 additions & 2 deletions rig/rig-core/tests/deepseek/permission_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async fn permission_control_prompt_example() -> Result<()> {

let agent = deepseek::Client::from_env()
.expect("client should build")
.agent(deepseek::DEEPSEEK_CHAT)
.agent(deepseek::DEEPSEEK_V4_FLASH)
.preamble("You are a helpful assistant that can read files using different methods.")
.tool(ReadFileHead)
.tool(ReadFileTail)
Expand Down Expand Up @@ -197,7 +197,7 @@ async fn permission_control_streaming_example() -> Result<()> {

let agent = deepseek::Client::from_env()
.expect("client should build")
.agent(deepseek::DEEPSEEK_CHAT)
.agent(deepseek::DEEPSEEK_V4_FLASH)
.preamble("You are a helpful assistant that can read files using different methods.")
.tool(ReadFileHead)
.tool(ReadFileTail)
Expand Down
14 changes: 10 additions & 4 deletions rig/rig-core/tests/deepseek/reasoning_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ use rig::providers::deepseek;

use crate::reasoning::{self, ReasoningRoundtripAgent};

fn thinking_params() -> serde_json::Value {
serde_json::json!({
"thinking": { "type": "enabled" }
})
}

#[tokio::test]
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn streaming() {
let client = deepseek::Client::from_env().expect("client should build");
reasoning::run_reasoning_roundtrip_streaming(ReasoningRoundtripAgent::new(
client.completion_model(deepseek::DEEPSEEK_REASONER),
None,
client.completion_model(deepseek::DEEPSEEK_V4_FLASH),
Some(thinking_params()),
))
.await;
}
Expand All @@ -21,8 +27,8 @@ async fn streaming() {
async fn nonstreaming() {
let client = deepseek::Client::from_env().expect("client should build");
reasoning::run_reasoning_roundtrip_nonstreaming(ReasoningRoundtripAgent::new(
client.completion_model(deepseek::DEEPSEEK_REASONER),
None,
client.completion_model(deepseek::DEEPSEEK_V4_FLASH),
Some(thinking_params()),
))
.await;
}
12 changes: 10 additions & 2 deletions rig/rig-core/tests/deepseek/reasoning_tool_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ use rig::streaming::StreamingChat;

use crate::reasoning::{self, WeatherTool};

fn thinking_params() -> serde_json::Value {
serde_json::json!({
"thinking": { "type": "enabled" }
})
}

#[tokio::test]
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn streaming() {
let call_count = Arc::new(AtomicUsize::new(0));
let client = deepseek::Client::from_env().expect("client should build");
let agent = client
.agent(deepseek::DEEPSEEK_REASONER)
.agent(deepseek::DEEPSEEK_V4_FLASH)
.preamble(reasoning::TOOL_SYSTEM_PROMPT)
.max_tokens(4096)
.tool(WeatherTool::new(call_count.clone()))
.additional_params(thinking_params())
.build();

let stream = agent
Expand All @@ -45,10 +52,11 @@ async fn nonstreaming() {
let call_count = Arc::new(AtomicUsize::new(0));
let client = deepseek::Client::from_env().expect("client should build");
let agent = client
.agent(deepseek::DEEPSEEK_REASONER)
.agent(deepseek::DEEPSEEK_V4_FLASH)
.preamble(reasoning::TOOL_SYSTEM_PROMPT)
.max_tokens(4096)
.tool(WeatherTool::new(call_count.clone()))
.additional_params(thinking_params())
.build();

let result = agent
Expand Down
2 changes: 1 addition & 1 deletion rig/rig-core/tests/deepseek/request_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
async fn request_hook_records_prompt_and_response() -> Result<()> {
let agent = deepseek::Client::from_env()
.expect("client should build")
.agent(deepseek::DEEPSEEK_CHAT)
.agent(deepseek::DEEPSEEK_V4_FLASH)
.preamble("You are a comedian here to entertain the user using humour and jokes.")
.build();

Expand Down
4 changes: 2 additions & 2 deletions rig/rig-core/tests/deepseek/streaming.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DeepSeek streaming smoke test.

use rig::client::{CompletionClient, ProviderClient};
use rig::providers::deepseek::{self, DEEPSEEK_CHAT};
use rig::providers::deepseek::{self, DEEPSEEK_V4_FLASH};
use rig::streaming::StreamingPrompt;

use crate::support::{assert_nonempty_response, collect_stream_final_response};
Expand All @@ -11,7 +11,7 @@ use crate::support::{assert_nonempty_response, collect_stream_final_response};
async fn streaming_prompt_smoke() {
let client = deepseek::Client::from_env().expect("client should build");
let agent = client
.agent(DEEPSEEK_CHAT)
.agent(DEEPSEEK_V4_FLASH)
.preamble("You are a helpful assistant.")
.build();

Expand Down
27 changes: 20 additions & 7 deletions rig/rig-core/tests/deepseek/streaming_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rig::OneOrMany;
use rig::client::{CompletionClient, ProviderClient};
use rig::completion::CompletionModel;
use rig::message::{AssistantContent, Message, ToolChoice};
use rig::providers::deepseek::{self, DEEPSEEK_CHAT};
use rig::providers::deepseek::{self, DEEPSEEK_V4_FLASH};
use rig::streaming::StreamingChat;
use rig::tool::Tool;

Expand All @@ -19,16 +19,23 @@ use crate::support::{
zero_arg_tool_definition,
};

fn non_thinking_params() -> serde_json::Value {
serde_json::json!({
"thinking": { "type": "disabled" }
})
}

#[tokio::test]
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn streaming_chat_with_tools() {
let client = deepseek::Client::from_env().expect("client should build");
let agent = client
.agent(DEEPSEEK_CHAT)
.agent(DEEPSEEK_V4_FLASH)
.preamble("You are a calculator here to help the user perform arithmetic operations.")
.max_tokens(1024)
.tool(Adder)
.tool(Subtract)
.additional_params(non_thinking_params())
.build();

let history: &[Message] = &[];
Expand All @@ -44,11 +51,12 @@ async fn streaming_chat_with_tools() {
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn raw_stream_emits_required_zero_arg_tool_call() {
let client = deepseek::Client::from_env().expect("client should build");
let model = client.completion_model(DEEPSEEK_CHAT);
let model = client.completion_model(DEEPSEEK_V4_FLASH);
let request = model
.completion_request(REQUIRED_ZERO_ARG_TOOL_PROMPT)
.tool(zero_arg_tool_definition("ping"))
.tool_choice(ToolChoice::Required)
.additional_params(non_thinking_params())
.build();
let stream = model.stream(request).await.expect("stream should start");

Expand All @@ -59,12 +67,13 @@ async fn raw_stream_emits_required_zero_arg_tool_call() {
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn raw_stream_surfaces_two_distinct_tool_calls_before_text() {
let client = deepseek::Client::from_env().expect("client should build");
let model = client.completion_model(DEEPSEEK_CHAT);
let model = client.completion_model(DEEPSEEK_V4_FLASH);
let request = model
.completion_request(TWO_TOOL_STREAM_PROMPT)
.preamble(TWO_TOOL_STREAM_PREAMBLE.to_string())
.tool(AlphaSignal.definition(String::new()).await)
.tool(BetaSignal.definition(String::new()).await)
.additional_params(non_thinking_params())
.build();

let observation = collect_raw_stream_observation(
Expand All @@ -86,10 +95,11 @@ async fn raw_stream_surfaces_two_distinct_tool_calls_before_text() {
async fn streaming_chat_surfaces_two_distinct_tool_calls_before_final_answer() {
let client = deepseek::Client::from_env().expect("client should build");
let agent = client
.agent(DEEPSEEK_CHAT)
.agent(DEEPSEEK_V4_FLASH)
.preamble(TWO_TOOL_STREAM_PREAMBLE)
.tool(AlphaSignal)
.tool(BetaSignal)
.additional_params(non_thinking_params())
.build();

let history: &[Message] = &[];
Expand All @@ -111,9 +121,10 @@ async fn streaming_chat_surfaces_two_distinct_tool_calls_before_final_answer() {
async fn streaming_chat_emits_tool_call_before_later_text() {
let client = deepseek::Client::from_env().expect("client should build");
let agent = client
.agent(DEEPSEEK_CHAT)
.agent(DEEPSEEK_V4_FLASH)
.preamble(ORDERED_TOOL_STREAM_PREAMBLE)
.tool(AlphaSignal)
.additional_params(non_thinking_params())
.build();

let history: &[Message] = &[];
Expand All @@ -134,11 +145,12 @@ async fn streaming_chat_emits_tool_call_before_later_text() {
#[ignore = "requires DEEPSEEK_API_KEY"]
async fn raw_followup_uses_tool_result_without_new_tool_calls() {
let client = deepseek::Client::from_env().expect("client should build");
let model = client.completion_model(DEEPSEEK_CHAT);
let model = client.completion_model(DEEPSEEK_V4_FLASH);
let request = model
.completion_request(ORDERED_TOOL_STREAM_PROMPT)
.preamble(ORDERED_TOOL_STREAM_PREAMBLE.to_string())
.tool(AlphaSignal.definition(String::new()).await)
.additional_params(non_thinking_params())
.build();

let first_turn = collect_raw_stream_observation(
Expand Down Expand Up @@ -170,6 +182,7 @@ async fn raw_followup_uses_tool_result_without_new_tool_calls() {
.preamble("Use the provided tool result and answer directly.".to_string())
.message(assistant_message)
.message(tool_result_message)
.additional_params(non_thinking_params())
.build();

let second_turn = collect_raw_stream_observation(
Expand Down
2 changes: 1 addition & 1 deletion rig/rig-core/tests/deepseek/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::support::{
async fn tools_smoke() {
let client = deepseek::Client::from_env().expect("client should build");
let agent = client
.agent(deepseek::DEEPSEEK_CHAT)
.agent(deepseek::DEEPSEEK_V4_FLASH)
.preamble(TOOLS_PREAMBLE)
.tool(Adder)
.tool(Subtract)
Expand Down
Loading