test(ollama): cover cloud search defaults
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
# Agents Upgrade Plan
|
# Agents Upgrade Plan
|
||||||
|
|
||||||
- test: rebuild ollama integration suite to exercise local, cloud, search, and quota error flows
|
|
||||||
- refactor: simplify provider/session coupling so compute_web_search_settings shares normalization utilities
|
- refactor: simplify provider/session coupling so compute_web_search_settings shares normalization utilities
|
||||||
- docs: clarify cloud vs local env configuration (api key precedence, insecure toggle) in configuration guide
|
- docs: clarify cloud vs local env configuration (api key precedence, insecure toggle) in configuration guide
|
||||||
- ci: add targeted regression job for ollama providers covering chat, streaming, and tool execution paths
|
- ci: add targeted regression job for ollama providers covering chat, streaming, and tool execution paths
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ fn configure_local(base_url: &str) -> Config {
|
|||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
fn configure_cloud(base_url: &str, search_endpoint: &str) -> Config {
|
fn configure_cloud(base_url: &str, search_endpoint: Option<&str>) -> Config {
|
||||||
let mut config = Config::default();
|
let mut config = Config::default();
|
||||||
config.general.default_provider = "ollama_cloud".into();
|
config.general.default_provider = "ollama_cloud".into();
|
||||||
config.general.default_model = Some("llama3:8b-cloud".into());
|
config.general.default_model = Some("llama3:8b-cloud".into());
|
||||||
@@ -130,10 +130,11 @@ fn configure_cloud(base_url: &str, search_endpoint: &str) -> Config {
|
|||||||
cloud.enabled = true;
|
cloud.enabled = true;
|
||||||
cloud.base_url = Some(base_url.to_string());
|
cloud.base_url = Some(base_url.to_string());
|
||||||
cloud.api_key = Some("test-key".into());
|
cloud.api_key = Some("test-key".into());
|
||||||
cloud.extra.insert(
|
if let Some(endpoint) = search_endpoint {
|
||||||
"web_search_endpoint".into(),
|
cloud
|
||||||
Value::String(search_endpoint.into()),
|
.extra
|
||||||
);
|
.insert("web_search_endpoint".into(), Value::String(endpoint.into()));
|
||||||
|
}
|
||||||
cloud.extra.insert(
|
cloud.extra.insert(
|
||||||
owlen_core::config::OLLAMA_CLOUD_ENDPOINT_KEY.into(),
|
owlen_core::config::OLLAMA_CLOUD_ENDPOINT_KEY.into(),
|
||||||
Value::String(base_url.to_string()),
|
Value::String(base_url.to_string()),
|
||||||
@@ -180,14 +181,13 @@ async fn run_local_completion(base_suffix: &str) {
|
|||||||
assert_eq!(snapshot.weekly.total_tokens, 36);
|
assert_eq!(snapshot.weekly.total_tokens, 36);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run_cloud_tool_flow(base_suffix: &str) {
|
async fn run_cloud_tool_flow(
|
||||||
|
base_suffix: &str,
|
||||||
|
search_endpoint: Option<&str>,
|
||||||
|
expected_search_path: &str,
|
||||||
|
) {
|
||||||
let server = MockServer::start().await;
|
let server = MockServer::start().await;
|
||||||
let raw_base = format!("{}{}", server.uri(), base_suffix);
|
let raw_base = format!("{}{}", server.uri(), base_suffix);
|
||||||
let search_endpoint = if base_suffix.is_empty() {
|
|
||||||
"/v1/web/search"
|
|
||||||
} else {
|
|
||||||
"/web/search"
|
|
||||||
};
|
|
||||||
|
|
||||||
let tags = load_fixture("ollama_tags");
|
let tags = load_fixture("ollama_tags");
|
||||||
let tool_call = load_fixture("ollama_cloud_tool_call");
|
let tool_call = load_fixture("ollama_cloud_tool_call");
|
||||||
@@ -219,7 +219,7 @@ async fn run_cloud_tool_flow(base_suffix: &str) {
|
|||||||
.await;
|
.await;
|
||||||
|
|
||||||
Mock::given(method("POST"))
|
Mock::given(method("POST"))
|
||||||
.and(path("/v1/web/search"))
|
.and(path(expected_search_path))
|
||||||
.and(header("authorization", "Bearer test-key"))
|
.and(header("authorization", "Bearer test-key"))
|
||||||
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
|
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
|
||||||
"results": [
|
"results": [
|
||||||
@@ -254,7 +254,7 @@ async fn run_cloud_tool_flow(base_suffix: &str) {
|
|||||||
let search_url = format!(
|
let search_url = format!(
|
||||||
"{}/{}",
|
"{}/{}",
|
||||||
raw_base.trim_end_matches('/'),
|
raw_base.trim_end_matches('/'),
|
||||||
search_endpoint.trim_start_matches('/')
|
expected_search_path.trim_start_matches('/')
|
||||||
);
|
);
|
||||||
|
|
||||||
session.grant_consent(
|
session.grant_consent(
|
||||||
@@ -325,7 +325,7 @@ async fn run_cloud_error(
|
|||||||
.mount(&server)
|
.mount(&server)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let config = configure_cloud(&raw_base, search_endpoint);
|
let config = configure_cloud(&raw_base, Some(search_endpoint));
|
||||||
let cloud_cfg = config
|
let cloud_cfg = config
|
||||||
.providers
|
.providers
|
||||||
.get("ollama_cloud")
|
.get("ollama_cloud")
|
||||||
@@ -368,12 +368,17 @@ async fn local_provider_accepts_v1_base_url() {
|
|||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn cloud_tool_call_flows_through_web_search() {
|
async fn cloud_tool_call_flows_through_web_search() {
|
||||||
run_cloud_tool_flow("").await;
|
run_cloud_tool_flow("", Some("/v1/web/search"), "/v1/web/search").await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
async fn cloud_tool_call_accepts_v1_base_url() {
|
async fn cloud_tool_call_accepts_v1_base_url() {
|
||||||
run_cloud_tool_flow("/v1").await;
|
run_cloud_tool_flow("/v1", Some("/web/search"), "/v1/web/search").await;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn cloud_tool_call_uses_default_search_endpoint() {
|
||||||
|
run_cloud_tool_flow("", None, "/api/web_search").await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread")]
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
|||||||
Reference in New Issue
Block a user