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

Usage of Ollama and local models #1079

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
postgres:
image: postgres:14-alpine
Expand All @@ -23,29 +21,35 @@ services:
skyvern:
image: public.ecr.aws/skyvern/skyvern:latest
restart: on-failure
# comment out if you want to externally call skyvern API
ports:
- 8000:8000
volumes:
- ./artifacts:/data/artifacts
- ./videos:/data/videos
- ./har:/data/har
- ./.streamlit:/app/.streamlit
- ./skyvern/config.py:/app/skyvern/config.py
- ./skyvern/forge/sdk/api/llm/models.py:/app/skyvern/forge/sdk/api/llm/models.py
- ./skyvern/forge/sdk/api/llm/config_registry.py:/app/skyvern/forge/sdk/api/llm/config_registry.py
- ./skyvern/forge/sdk/api/llm/api_handler_factory.py:/app/skyvern/forge/sdk/api/llm/api_handler_factory.py
environment:
- DATABASE_STRING=postgresql+psycopg://skyvern:skyvern@postgres:5432/skyvern
- BROWSER_TYPE=chromium-headful
- ENABLE_OPENAI=true
- OPENAI_API_KEY=<your_openai_key>
# If you want to use other LLM provider, like azure and anthropic:
# - ENABLE_ANTHROPIC=true
# - LLM_KEY=ANTHROPIC_CLAUDE3_OPUS
# - ANTHROPIC_API_KEY=<your_anthropic_key>
# - ENABLE_AZURE=true
# - LLM_KEY=AZURE_OPENAI
# - AZURE_DEPLOYMENT=<your_azure_deployment>
# - AZURE_API_KEY=<your_azure_api_key>
# - AZURE_API_BASE=<your_azure_api_base>
# - AZURE_API_VERSION=<your_azure_api_version>
# Enable Ollama
- ENABLE_OLLAMA=true
- LLM_KEY=OLLAMA_TEXT
- OLLAMA_API_BASE=http://192.168.1.3:11434

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add option to persist model in memory

curl http://localhost:11434/api/generate -d '{
"model": "",
"keep_alive":
}'

- OLLAMA_TEXT_MODEL=llama3.1:70b
- OLLAMA_VISION_MODEL=moondream:latest
- OLLAMA_CONTEXT_WINDOW=8192
# Disable other providers
- ENABLE_OPENAI=false
- ENABLE_ANTHROPIC=false
- ENABLE_AZURE=false
- ENABLE_AZURE_GPT4O_MINI=false
- ENABLE_BEDROCK=false
- LITELLM_VERBOSE=true
- LOG_LEVEL=DEBUG
depends_on:
postgres:
condition: service_healthy
Expand Down
14 changes: 11 additions & 3 deletions skyvern/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class Settings(BaseSettings):
# browser settings
BROWSER_LOCALE: str = "en-US"
BROWSER_TIMEZONE: str = "America/New_York"
BROWSER_WIDTH: int = 1920
BROWSER_HEIGHT: int = 1080
BROWSER_WIDTH: int = 1366
BROWSER_HEIGHT: int = 768

# Workflow constant parameters
WORKFLOW_DOWNLOAD_DIRECTORY_PARAMETER_KEY: str = "SKYVERN_DOWNLOAD_DIRECTORY"
Expand All @@ -93,7 +93,7 @@ class Settings(BaseSettings):
LLM_KEY: str = "OPENAI_GPT4O"
SECONDARY_LLM_KEY: str | None = None
# COMMON
LLM_CONFIG_TIMEOUT: int = 300
LLM_CONFIG_TIMEOUT: int = 60
LLM_CONFIG_MAX_TOKENS: int = 4096
LLM_CONFIG_TEMPERATURE: float = 0
# LLM PROVIDER SPECIFIC
Expand Down Expand Up @@ -125,6 +125,14 @@ class Settings(BaseSettings):

SVG_MAX_LENGTH: int = 100000

# Add these new settings for Ollama
ENABLE_OLLAMA: bool = False
OLLAMA_API_BASE: str = "http://192.168.1.3:11434"
OLLAMA_MODEL: str = "llama2" # Default model, can be changed
OLLAMA_TEXT_MODEL: str = "command-r:latest" # Model for text-only requests
OLLAMA_VISION_MODEL: str = "llava:34b" # Model for vision requests
OLLAMA_CONTEXT_WINDOW: int = 8192

def is_cloud_environment(self) -> bool:
"""
:return: True if env is not local, else False
Expand Down
Loading