Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ollama API Key Configuration Support #566

Merged
merged 2 commits into from
Dec 30, 2024
Merged

Conversation

ruanwz
Copy link
Contributor

@ruanwz ruanwz commented Dec 30, 2024

Add Ollama API Key Configuration Support

Description

Currently, the API key in OllamaModel is hardcoded to 'ollama', which limits scenarios where custom API keys are needed, such as when using nginx as a proxy. This change adds support for a configurable API key parameter, allowing users to set custom API keys as needed.

Changes

  • Added an optional api_key parameter to OllamaModel.__init__ with a default value of 'ollama'
  • Updated the API key passing logic to use the provided api_key parameter instead of the hardcoded value

Usage Example

Using default API key

model = OllamaModel('llama2')

Using custom API key

model = OllamaModel('llama2', api_key='custom-key')

# Add Ollama API Key Configuration Support

## Description
Currently, the API key in OllamaModel is hardcoded to 'ollama', which limits scenarios where custom API keys are needed, such as when using nginx as a proxy. This change adds support for a configurable API key parameter, allowing users to set custom API keys as needed.

## Changes
- Added an optional `api_key` parameter to `OllamaModel.__init__` with a default value of 'ollama'
- Updated the API key passing logic to use the provided api_key parameter instead of the hardcoded value

## Usage Example
Using default API key
model = OllamaModel('llama2')

Using custom API key
model = OllamaModel('llama2', api_key='custom-key')
@samuelcolvin samuelcolvin merged commit 2289879 into pydantic:main Dec 30, 2024
13 checks passed
@samuelcolvin
Copy link
Member

great, thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants