diff --git a/.gitignore b/.gitignore index 4be981783..e2d4bcf58 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,7 @@ next-env.d.ts # docs docs/.source docs/.contentlayer -docs/.content-collections \ No newline at end of file +docs/.content-collections + +# database instantiation +**/postgres_data/ \ No newline at end of file diff --git a/README.md b/README.md index bc55f10d5..13d48de59 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,12 @@ cd sim # Create environment file and update with required environment variables (BETTER_AUTH_SECRET) cp sim/.env.example sim/.env -# Start the Docker environment -docker compose up -d +# Start Sim Studio using the provided script +docker compose up -d --build + +or + +./start_simstudio_docker.sh ``` After running these commands: @@ -66,6 +70,36 @@ After running these commands: docker compose up -d --build ``` +#### Working with Local Models + +To use local models with Sim Studio, follow these steps: + +1. **Pull Local Models** + + ```bash + # Run the ollama_docker.sh script to pull the required models + ./sim/scripts/ollama_docker.sh pull + ``` + +2. **Start Sim Studio with Local Models** + + ```bash + #Start Sim Studio with local model support + ./start_simstudio_docker.sh --local + + # or + + # Start Sim Studio with local model support if you have nvidia GPU + docker compose up --profile local-gpu -d --build + + # or + + # Start Sim Studio with local model support if you don't have nvidia GPU + docker compose up --profile local-cpu -d --build + ``` + +The application will now be configured to use your local models. You can access it at [http://localhost:3000/w/](http://localhost:3000/w/). + ### Option 2: Dev Containers 1. Open VS Code or your favorite VS Code fork (Cursor, Windsurf, etc.) diff --git a/docker-compose.yml b/docker-compose.yml index 9561f2b08..6cd2d2a82 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,5 +46,54 @@ services: timeout: 5s retries: 5 + local-llm-gpu: + profiles: + - local-gpu # This profile requires both 'local' and 'gpu' + image: ollama/ollama:latest + pull_policy: always + volumes: + - ${HOME}/.ollama:/root/.ollama + ports: + - "11434:11434" + environment: + - NVIDIA_DRIVER_CAPABILITIES=all + - OLLAMA_LOAD_TIMEOUT=-1 + - OLLAMA_KEEP_ALIVE=-1 + - OLLAMA_DEBUG=1 + command: "serve" + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:11434/"] + interval: 10s + timeout: 5s + retries: 5 + + local-llm-cpu: + profiles: + - local-cpu # This profile requires both 'local' and 'cpu' + image: ollama/ollama:latest + pull_policy: always + volumes: + - ${HOME}/.ollama:/root/.ollama + ports: + - "11434:11434" + environment: + - OLLAMA_LOAD_TIMEOUT=-1 + - OLLAMA_KEEP_ALIVE=-1 + - OLLAMA_DEBUG=1 + command: "serve" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:11434/"] + interval: 10s + timeout: 5s + retries: 5 + volumes: - postgres_data: \ No newline at end of file + postgres_data: + diff --git a/sim/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx b/sim/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx index ebd8deec2..e299be63d 100644 --- a/sim/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx +++ b/sim/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx @@ -1,4 +1,4 @@ -import { useEffect } from 'react' +import { useEffect, useMemo } from 'react' import { Select, SelectContent, @@ -9,7 +9,7 @@ import { import { useSubBlockValue } from '../hooks/use-sub-block-value' interface DropdownProps { - options: Array + options: Array | (() => Array) defaultValue?: string blockId: string subBlockId: string @@ -18,14 +18,19 @@ interface DropdownProps { export function Dropdown({ options, defaultValue, blockId, subBlockId }: DropdownProps) { const [value, setValue] = useSubBlockValue(blockId, subBlockId, true) + // Evaluate options if it's a function + const evaluatedOptions = useMemo(() => { + return typeof options === 'function' ? options() : options + }, [options]) + // Set the value to the first option if it's not set useEffect(() => { - if (!value && options.length > 0) { - const firstOption = options[0] + if (!value && evaluatedOptions.length > 0) { + const firstOption = evaluatedOptions[0] const firstValue = typeof firstOption === 'string' ? firstOption : firstOption.id setValue(firstValue) } - }, [value, options, defaultValue, setValue]) + }, [value, evaluatedOptions, defaultValue, setValue]) const getOptionValue = (option: string | { label: string; id: string }) => { return typeof option === 'string' ? option : option.id @@ -38,14 +43,14 @@ export function Dropdown({ options, defaultValue, blockId, subBlockId }: Dropdow return (