Skip to content

Commit 86269ba

Browse files
committed
Feature: Enable programmatically pass in api_key besides reading from env
1 parent f111615 commit 86269ba

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/llm/mod.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,17 @@ pub async fn new_llm_generation_client(
127127
}
128128
LlmApiType::OpenAi => Box::new(openai::Client::new(address, api_key, api_config)?)
129129
as Box<dyn LlmGenerationClient>,
130-
LlmApiType::Gemini => Box::new(gemini::AiStudioClient::new(address, api_key)?)
131-
as Box<dyn LlmGenerationClient>,
130+
LlmApiType::Gemini => {
131+
Box::new(gemini::AiStudioClient::new(address, api_key)?) as Box<dyn LlmGenerationClient>
132+
}
132133
LlmApiType::VertexAi => {
133134
Box::new(gemini::VertexAiClient::new(address, api_key, api_config).await?)
134135
as Box<dyn LlmGenerationClient>
135136
}
136-
LlmApiType::Anthropic => {
137-
Box::new(anthropic::Client::new(address, api_key).await?)
138-
as Box<dyn LlmGenerationClient>
139-
}
140-
LlmApiType::LiteLlm => {
141-
Box::new(litellm::Client::new_litellm(address, api_key).await?)
142-
as Box<dyn LlmGenerationClient>
143-
}
137+
LlmApiType::Anthropic => Box::new(anthropic::Client::new(address, api_key).await?)
138+
as Box<dyn LlmGenerationClient>,
139+
LlmApiType::LiteLlm => Box::new(litellm::Client::new_litellm(address, api_key).await?)
140+
as Box<dyn LlmGenerationClient>,
144141
LlmApiType::OpenRouter => {
145142
Box::new(openrouter::Client::new_openrouter(address, api_key).await?)
146143
as Box<dyn LlmGenerationClient>
@@ -164,12 +161,14 @@ pub async fn new_llm_embedding_client(
164161
LlmApiType::Ollama => {
165162
Box::new(ollama::Client::new(address).await?) as Box<dyn LlmEmbeddingClient>
166163
}
167-
LlmApiType::Gemini => Box::new(gemini::AiStudioClient::new(address, api_key)?)
168-
as Box<dyn LlmEmbeddingClient>,
164+
LlmApiType::Gemini => {
165+
Box::new(gemini::AiStudioClient::new(address, api_key)?) as Box<dyn LlmEmbeddingClient>
166+
}
169167
LlmApiType::OpenAi => Box::new(openai::Client::new(address, api_key, api_config)?)
170168
as Box<dyn LlmEmbeddingClient>,
171-
LlmApiType::Voyage => Box::new(voyage::Client::new(address, api_key)?)
172-
as Box<dyn LlmEmbeddingClient>,
169+
LlmApiType::Voyage => {
170+
Box::new(voyage::Client::new(address, api_key)?) as Box<dyn LlmEmbeddingClient>
171+
}
173172
LlmApiType::VertexAi => {
174173
Box::new(gemini::VertexAiClient::new(address, api_key, api_config).await?)
175174
as Box<dyn LlmEmbeddingClient>

0 commit comments

Comments
 (0)