MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / test_perplexity_llm

Function test_perplexity_llm

tests/rust_unit_tests/llm_tests.rs:137–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135#[tokio::test]
136#[ignore = "Requires Perplexity API key"]
137async fn test_perplexity_llm() {
138 if !has_perplexity_key() {
139 return;
140 }
141
142 let config = llm::LlmConfig::Perplexity {
143 api_key: std::env::var("PERPLEXITY_API_KEY").unwrap(),
144 model: "sonar".to_string(),
145 base_url: None,
146 };
147
148 let provider = llm::LlmProviderFactory::create_provider(config).unwrap();
149 let request = llm::LlmRequest::new("What is 2+2?")
150 .with_max_tokens(50) // Increased to avoid length truncation
151 .with_temperature(0.0);
152
153 let result = provider.complete(request).await;
154 if let Err(e) = &result {
155 println!("Perplexity API call failed: {:?}", e);
156 }
157 assert!(result.is_ok());
158
159 let response = result.unwrap();
160 println!("Perplexity finish reason: {:?}", response.finish_reason);
161 // Accept both natural stop and length truncation as valid completions
162 assert!(
163 response.finish_reason.is_natural_stop() || response.finish_reason.is_truncated(),
164 "Expected natural stop or length truncation, got: {:?}",
165 response.finish_reason
166 );
167}
168
169#[tokio::test]
170#[ignore = "Tests Perplexity authentication failure"]

Callers

nothing calls this directly

Calls 5

has_perplexity_keyFunction · 0.85
to_stringMethod · 0.80
with_temperatureMethod · 0.45
with_max_tokensMethod · 0.45
completeMethod · 0.45

Tested by

no test coverage detected