You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// backend/src/server/services/groq/error.rsuse thiserror::Error;#[derive(Error,Debug)]pubenumGroqError{#[error("API request failed: {0}")]RequestFailed(String),#[error("Failed to parse response: {0}")]ParseError(String),#[error("Rate limit exceeded")]RateLimitExceeded,#[error("Invalid API key")]InvalidApiKey,}
5. Add Configuration
// backend/src/server/services/groq/config.rsuse serde::{Deserialize,Serialize};#[derive(Debug,Clone,Serialize,Deserialize)]pubstructGroqConfig{pubapi_key:String,pubbase_url:Option<String>,pubdefault_model:Option<String>,pubtimeout_secs:Option<u64>,}implDefaultforGroqConfig{fndefault() -> Self{Self{api_key: std::env::var("GROQ_API_KEY").expect("GROQ_API_KEY must be set"),base_url:None,default_model:None,timeout_secs:Some(180),}}}
6. Add Tests
// backend/tests/groq.rsusecrate::server::services::groq::GroqService;usecrate::server::services::gateway::Gateway;#[tokio::test]asyncfntest_groq_metadata(){let service = GroqService::new("test-key".to_string());let metadata = service.metadata();assert_eq!(metadata.name,"Groq");assert!(metadata.openai_compatible);}#[tokio::test]asyncfntest_groq_chat(){let service = GroqService::new("test-key".to_string());let(response, _) = service.chat("Hello".to_string(),false).await.unwrap();assert!(!response.is_empty());}#[tokio::test]asyncfntest_groq_chat_stream(){let service = GroqService::new("test-key".to_string());let stream = service.chat_stream("Hello".to_string(),false).await.unwrap();// Test streaming functionality}
This issue outlines the implementation of a Groq Gateway service that implements the Gateway trait similar to the existing Deepseek service.
Overview
The Groq service will provide:
Implementation Details
1. Create Service Structure
2. Implement Gateway Trait
3. Add Types Module
4. Add Error Handling
5. Add Configuration
6. Add Tests
Tasks
Environment Variables
Add to
.env.example
:Related Issues
Next Steps
The text was updated successfully, but these errors were encountered: