Skip to main content

vtcode_core/llm/providers/
gemini.rs

1#![allow(clippy::collapsible_if)]
2
3use self::wire::function_calling::FunctionCall as GeminiFunctionCall;
4use self::wire::{
5    Candidate, Content, FunctionDeclaration, GenerateContentRequest, GenerateContentResponse,
6    Interaction, InteractionContent, InteractionInput, InteractionOutput, InteractionRequest,
7    InteractionResult, InteractionTool, InteractionToolChoice, InteractionTurn,
8    InteractionTurnContent, Part, StreamingCandidate, StreamingConfig, StreamingError,
9    StreamingProcessor, StreamingResponse, SystemInstruction, Tool, ToolConfig,
10};
11use self::wire::{FunctionCallingConfig, FunctionResponse};
12use crate::config::TimeoutsConfig;
13use crate::config::constants::{env_vars, models, urls};
14use crate::config::core::{
15    AnthropicConfig, GeminiPromptCacheMode, GeminiPromptCacheSettings, PromptCachingConfig,
16};
17use crate::llm::client::LLMClient;
18use crate::llm::error_display;
19use crate::llm::provider::{
20    FinishReason, FunctionCall, LLMError, LLMProvider, LLMRequest, LLMResponse, LLMStream,
21    LLMStreamEvent, Message, MessageRole, ToolCall, ToolChoice,
22};
23use async_stream::try_stream;
24use async_trait::async_trait;
25use futures::StreamExt;
26use hashbrown::HashMap;
27use reqwest::Client as HttpClient;
28use serde_json::{Map, Value, json};
29use std::sync::Arc;
30use tokio::sync::mpsc;
31use tracing;
32use vtcode_config::types::ReasoningEffortLevel;
33
34use super::common::{extract_prompt_cache_settings, override_base_url, resolve_model};
35use super::error_handling::{format_network_error, format_parse_error, is_rate_limit_error};
36
37mod client;
38mod helpers;
39mod llm_provider;
40mod provider;
41mod sanitize;
42#[cfg(test)]
43mod tests;
44pub mod wire;
45
46pub use provider::GeminiProvider;
47pub use sanitize::sanitize_function_parameters;