diff --git a/crates/goose/src/providers/openai.rs b/crates/goose/src/providers/openai.rs index ff6b65253c93..93d501e0a838 100644 --- a/crates/goose/src/providers/openai.rs +++ b/crates/goose/src/providers/openai.rs @@ -48,6 +48,8 @@ pub struct OpenAiProvider { project: Option, model: ModelConfig, custom_headers: Option>, + enable_streaming: bool, + enable_embeddings: bool, } impl Default for OpenAiProvider { @@ -74,6 +76,16 @@ impl OpenAiProvider { .or_else(|_| config.get_param("OPENAI_CUSTOM_HEADERS")) .ok() .map(parse_custom_headers); + let enable_streaming: bool = config + .get_param("OPENAI_ENABLE_STREAMING") + .unwrap_or_else(|_| "true".to_string()) + .parse() + .unwrap_or(true); + let enable_embeddings: bool = config + .get_param("OPENAI_ENABLE_EMBEDDINGS") + .unwrap_or_else(|_| "true".to_string()) + .parse() + .unwrap_or(true); let timeout_secs: u64 = config.get_param("OPENAI_TIMEOUT").unwrap_or(600); let client = Client::builder() .timeout(Duration::from_secs(timeout_secs)) @@ -88,6 +100,8 @@ impl OpenAiProvider { project, model, custom_headers, + enable_streaming, + enable_embeddings, }) } @@ -156,6 +170,8 @@ impl Provider for OpenAiProvider { ConfigKey::new("OPENAI_ORGANIZATION", false, false, None), ConfigKey::new("OPENAI_PROJECT", false, false, None), ConfigKey::new("OPENAI_CUSTOM_HEADERS", false, true, None), + ConfigKey::new("OPENAI_ENABLE_STREAMING", false, false, Some("true")), + ConfigKey::new("OPENAI_ENABLE_EMBEDDINGS", false, false, Some("true")), ConfigKey::new("OPENAI_TIMEOUT", false, false, Some("600")), ], ) @@ -232,7 +248,7 @@ impl Provider for OpenAiProvider { } fn supports_embeddings(&self) -> bool { - true + self.enable_embeddings } async fn create_embeddings(&self, texts: Vec) -> Result>, ProviderError> { @@ -242,7 +258,7 @@ impl Provider for OpenAiProvider { } fn supports_streaming(&self) -> bool { - true + self.enable_streaming } async fn stream( diff --git a/documentation/docs/getting-started/providers.md b/documentation/docs/getting-started/providers.md index edf0b7639c0a..776c3fbee6b7 100644 --- a/documentation/docs/getting-started/providers.md +++ b/documentation/docs/getting-started/providers.md @@ -32,7 +32,7 @@ Goose relies heavily on tool calling capabilities and currently works best with | [Groq](https://groq.com/) | High-performance inference hardware and tools for LLMs. | `GROQ_API_KEY` | | [Ollama](https://ollama.com/) | Local model runner supporting Qwen, Llama, DeepSeek, and other open-source models. **Because this provider runs locally, you must first [download and run a model](#local-llms).** | `OLLAMA_HOST` | | [Ramalama](https://ramalama.ai/) | Local model using native [OCI](https://opencontainers.org/) container runtimes, [CNCF](https://www.cncf.io/) tools, and supporting models as OCI artifacts. Ramalama API an compatible alternative to Ollama and can be used with the Goose Ollama provider. Supports Qwen, Llama, DeepSeek, and other open-source models. **Because this provider runs locally, you must first [download and run a model](#local-llms).** | `OLLAMA_HOST` | -| [OpenAI](https://platform.openai.com/api-keys) | Provides gpt-4o, o1, and other advanced language models. Also supports OpenAI-compatible endpoints (e.g., self-hosted LLaMA, vLLM, KServe). **o1-mini and o1-preview are not supported because Goose uses tool calling.** | `OPENAI_API_KEY`, `OPENAI_HOST` (optional), `OPENAI_ORGANIZATION` (optional), `OPENAI_PROJECT` (optional), `OPENAI_CUSTOM_HEADERS` (optional) | +| [OpenAI](https://platform.openai.com/api-keys) | Provides gpt-4o, o1, and other advanced language models. Also supports OpenAI-compatible endpoints (e.g., self-hosted LLaMA, vLLM, KServe). **o1-mini and o1-preview are not supported because Goose uses tool calling.** | `OPENAI_API_KEY`, `OPENAI_HOST` (optional), `OPENAI_ORGANIZATION` (optional), `OPENAI_PROJECT` (optional), `OPENAI_CUSTOM_HEADERS` (optional), `OPENAI_ENABLE_STREAMING` (optional), `OPENAI_ENABLE_EMBEDDINGS` (optional) | | [OpenRouter](https://openrouter.ai/) | API gateway for unified access to various models with features like rate-limiting management. | `OPENROUTER_API_KEY` | | [Snowflake](https://docs.snowflake.com/user-guide/snowflake-cortex/aisql#choosing-a-model) | Access the latest models using Snowflake Cortex services, including Claude models. **Requires a Snowflake account and programmatic access token (PAT)**. | `SNOWFLAKE_HOST`, `SNOWFLAKE_TOKEN` | | [Venice AI](https://venice.ai/home) | Provides access to open source models like Llama, Mistral, and Qwen while prioritizing user privacy. **Requires an account and an [API key](https://docs.venice.ai/overview/guides/generating-api-key)**. | `VENICE_API_KEY`, `VENICE_HOST` (optional), `VENICE_BASE_PATH` (optional), `VENICE_MODELS_PATH` (optional) | @@ -165,6 +165,8 @@ Goose supports using custom OpenAI-compatible endpoints, which is particularly u | `OPENAI_ORGANIZATION` | No | Organization ID for usage tracking and governance | | `OPENAI_PROJECT` | No | Project identifier for resource management | | `OPENAI_CUSTOM_HEADERS` | No | Additional headers to include in the request. Can be set via environment variable, configuration file, or CLI, in the format `HEADER_A=VALUE_A,HEADER_B=VALUE_B`. | +| `OPENAI_ENABLE_STREAMING` | No | Enable or disable streaming support (defaults to true) | +| `OPENAI_ENABLE_EMBEDDINGS` | No | Enable or disable embeddings support (defaults to true) | ### Example Configurations