From 8c73f7a34b14fcee22dfa56d994d4241581eec87 Mon Sep 17 00:00:00 2001 From: Gormery Kombo Wanjiru Date: Sun, 4 Feb 2024 23:37:19 +0100 Subject: [PATCH] initial commit --- .devcontainer/devcontainer.json | 44 ++++++++++++ .dockerignore | 5 ++ .gitignore | 4 ++ .vscode/Bookmark.bcat | 1 + .vscode/CatStatus.bcat | 1 + .vscode/extensions.json | 28 ++++++++ .vscode/settings.json | 5 ++ Dockerfile | 13 ++++ README.md | 62 ++++++++++++++++ docker-compose.yml | 52 ++++++++++++++ fly.toml | 17 +++++ model_file | 6 ++ requirements.txt | 4 ++ run.bat | 7 ++ run.sh | 5 ++ setup.sh | 8 +++ src/categorize_expenses.py | 4 ++ src/index.html | 123 ++++++++++++++++++++++++++++++++ src/main.py | 28 ++++++++ src/tempCodeRunnerFile.py | 1 + 20 files changed, 418 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 .vscode/Bookmark.bcat create mode 100644 .vscode/CatStatus.bcat create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 fly.toml create mode 100644 model_file create mode 100644 requirements.txt create mode 100644 run.bat create mode 100644 run.sh create mode 100644 setup.sh create mode 100644 src/categorize_expenses.py create mode 100644 src/index.html create mode 100644 src/main.py create mode 100644 src/tempCodeRunnerFile.py diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..b9baa04 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,44 @@ +{ + "name": "ollama-docker", + "dockerComposeFile": ["../docker-compose.yml"], + "service": "app", + "workspaceFolder": "/code", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.autopep8", + "ms-python.debugpy", + "ms-python.isort", + "donjayamanne.python-environment-manager", + "donjayamanne.python-extension-pack", + "etmoffat.pip-packages", + "aaron-bond.better-comments", + "formulahendry.auto-rename-tag", + "formulahendry.code-runner", + "github.copilot", + "github.vscode-pull-request-github", + "ms-azuretools.vscode-docker", + "ms-vscode-remote.remote-containers", + "ms-vscode-remote.remote-ssh", + "ms-vscode-remote.vscode-remote-extensionpack", + "ms-toolsai.jupyter", + "ritwickdey.liveserver", + "visualstudioexptteam.vscodeintellicode", + "vscode-icons-team.vscode-icons", + "esbenp.prettier-vscode", + "jpotterm.simple-vim" + ], + "settings": { + "python.pythonPath": "/usr/local/bin/python", + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.flake8Args": ["--max-line-length=88"], + "python.formatting.provider": "ms-python.python", + "editor.formatOnSave": true + } + } + }, + "postCreateCommand": "pip install -r requirements.txt" +} diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a57a296 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +# flyctl launch added from .gitignore +**\.dist +**\.vscode +src\__pycache__ +fly.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..67b9890 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.dist +/src/__pycache__ +venv/ +ollama/ \ No newline at end of file diff --git a/.vscode/Bookmark.bcat b/.vscode/Bookmark.bcat new file mode 100644 index 0000000..fcb2700 --- /dev/null +++ b/.vscode/Bookmark.bcat @@ -0,0 +1 @@ +[{"Group":"This is a sample~","Time":"","FileAndPath":[{"Tag":"Welcome use bookmark","Path":"","Start":"0.0","End":"0.0","Time":""}]}] \ No newline at end of file diff --git a/.vscode/CatStatus.bcat b/.vscode/CatStatus.bcat new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/.vscode/CatStatus.bcat @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..6102f6f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,28 @@ +{ + "recommendations": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.autopep8", + "ms-python.debugpy", + "ms-python.isort", + "donjayamanne.python-environment-manager", + "donjayamanne.python-extension-pack", + "etmoffat.pip-packages", + "aaron-bond.better-comments", + "formulahendry.auto-rename-tag", + "formulahendry.code-runner", + "github.copilot", + "github.vscode-pull-request-github", + "ms-azuretools.vscode-docker", + "ms-vscode-remote.remote-containers", + "ms-vscode-remote.remote-ssh", + "ms-vscode-remote.vscode-remote-extensionpack", + "ms-toolsai.jupyter", + "ritwickdey.liveserver", + "visualstudioexptteam.vscodeintellicode", + "vscode-icons-team.vscode-icons", + "esbenp.prettier-vscode" + ] +} + + \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..00d6496 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.languageServer": "Pylance", + "python.analysis.extraPaths": ["../"], + "python.formatting.provider": "prettier", +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4e61306 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.11-slim + +WORKDIR /code + +COPY ./requirements.txt ./ + +RUN pip install --no-cache-dir -r requirements.txt + +COPY ./src ./src + +EXPOSE 8000 + +CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..c6846c6 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# Ollama Docker Compose Setup + +Welcome to the Ollama Docker Compose Setup! This project simplifies the deployment of Ollama using Docker Compose, making it easy to run Ollama with all its dependencies in a containerized environment. + +## Getting Started + +To get started with the Ollama Docker Compose Setup, follow the steps below: + +### Prerequisites + +Make sure you have the following prerequisites installed on your machine: + +- [Docker](https://www.docker.com/) +- [Docker Compose](https://docs.docker.com/compose/) + +### Configuration + +1. Clone the Docker Compose repository: + + ```bash + git clone https://github.com/valiantlynx/ollama-docker.git + ``` + +2. Change to the project directory: + + ```bash + cd ollama-docker + mkdir ollama/ollama + mkdir ollama/ollama-webui + ``` + +### Usage + +Start Ollama and its dependencies using Docker Compose: + +```bash +docker-compose up -d +``` + +Visit [http://localhost:3000](http://localhost:3000) in your browser to access Ollama. + +### Stop and Cleanup + +To stop the containers and remove the network: + +```bash +docker-compose down +``` + +## Contributing + +We welcome contributions! If you'd like to contribute to the Ollama Docker Compose Setup, please follow our [Contribution Guidelines](CONTRIBUTING.md). + +## License + +This project is licensed under the [MIT License](LICENSE). Feel free to use, modify, and distribute it according to the terms of the license. + +## Contact + +If you have any questions or concerns, please contact us at [contact@ollama.com](mailto:contact@ollama.com). + +Enjoy using Ollama with Docker Compose! 🐳🚀 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..42ee2fe --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,52 @@ +version: '3.8' +services: + app: + build: . + ports: + - 8000:8000 + - 5678:5678 + volumes: + - .:/code + command: uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload + restart: always + depends_on: + - ollama + - llama-webui + networks: + - ollama-docker + + ollama: + image: ollama/ollama:latest + ports: + - 11434:11434 + volumes: + - .:/code + - ./ollama/ollama:/root/.ollama + container_name: ollama + pull_policy: always + tty: true + restart: always + networks: + - ollama-docker + + llama-webui: + image: ghcr.io/ollama-webui/ollama-webui:main + container_name: ollama-webui + volumes: + - ./ollama/ollama-webui:/app/backend/data + depends_on: + - ollama + ports: + - 3000:8080 + environment: + - '/ollama/api=http://ollama:11434/api' + extra_hosts: + - host.docker.internal:host-gateway + restart: unless-stopped + networks: + - ollama-docker + +networks: + ollama-docker: + external: false + diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..27da8b3 --- /dev/null +++ b/fly.toml @@ -0,0 +1,17 @@ +# fly.toml app configuration file generated for breath-first-search on 2023-10-17T03:52:02+02:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "ollama-docker" +primary_region = "arn" + +[env] + PORT = "8000" + +[http_service] + internal_port = 8000 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 diff --git a/model_file b/model_file new file mode 100644 index 0000000..6aff2d3 --- /dev/null +++ b/model_file @@ -0,0 +1,6 @@ +FROM llama2 + +PARAMETER temperature 0.8 + +SYSTEM You are a financial assistant, you help classify expenses +and income from bank transactions diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f67c8af --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +fastapi +uvicorn +debugpy +langchain_community \ No newline at end of file diff --git a/run.bat b/run.bat new file mode 100644 index 0000000..934c3b4 --- /dev/null +++ b/run.bat @@ -0,0 +1,7 @@ +call python -m venv venv +call venv\Scripts\activate + +call python -m pip install --upgrade pip + +call pip install -r requirements.txt +call python signal-processing.py diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..fccefce --- /dev/null +++ b/run.sh @@ -0,0 +1,5 @@ +python -m venv venv +source venv/Scripts/activate +pip install -r requirements.txt +python signal-processing.py + diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..f188dc4 --- /dev/null +++ b/setup.sh @@ -0,0 +1,8 @@ +# run using docker +docker build -t ollama-docker-image . +docker run --name ollama-docker-container -d -p 11434:11434 -p 8000:8000 -v $(pwd):/code ollama-docker-image + +#connect to turborepo +git subtree add --prefix=apps/ollama-docker https://github.com/valiantlynx/ollama-docker.git main --squash +git subtree pull --prefix=apps/ollama-docker https://github.com/valiantlynx/ollama-docker.git main --squash +git subtree push --prefix=apps/ollama-docker https://github.com/valiantlynx/ollama-docker.git main diff --git a/src/categorize_expenses.py b/src/categorize_expenses.py new file mode 100644 index 0000000..4405fa5 --- /dev/null +++ b/src/categorize_expenses.py @@ -0,0 +1,4 @@ +from langchain_community.llms import Ollama + +llm = Ollama(model="llama2") +llm.invoke("The first man on the moon was ...") diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..e7d28e2 --- /dev/null +++ b/src/index.html @@ -0,0 +1,123 @@ + + + + + + + + + + + + + Whisper Magic Chat + + + + +
+
+

Whisper Magic Chat

+ +
+
+ +
+
+

Unleash the Magic of Your Voice

+

Transform your voice into something enchanting with + Whisper Magic API. Experience the future of automatic speech recognition with unparalleled accuracy and speed.

+ Get + Started +
+
+ +
+
+

Whisper Magic Transcription

+

Upload an audio file to transcribe and experience the magic of + Whisper.

+ +
+ + + + + +
+
+
+ +
+
+

Enchanting Features

+
+ +
+

Voice Transformation

+

Turn your voice into a symphony of magical sounds. Choose from a variety of + enchanting transformations.

+
+ +
+

Whisper Recognition

+

Whisper Magic recognizes whispers with unparalleled precision, making it perfect for + ASMR applications.

+
+ +
+

Real-time Spell Casting

+

Cast spells using your voice in real-time. Experience the magic as your words come to + life.

+
+
+
+
+ + + + + diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..f3f268a --- /dev/null +++ b/src/main.py @@ -0,0 +1,28 @@ +from fastapi import FastAPI +from fastapi.responses import HTMLResponse +from fastapi.middleware.cors import CORSMiddleware +import debugpy +from typing import List + + +app = FastAPI() +# Allow all origins for CORS (you can customize this based on your requirements) +origins = ["*"] + +# Configure CORS middleware +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) +debugpy.listen(("0.0.0.0", 5678)) + +@app.get("/", response_class=HTMLResponse) +async def read_root(): + # Read the content of your HTML file + with open("./src/index.html", "r") as file: + html_content = file.read() + + return HTMLResponse(content=html_content) \ No newline at end of file diff --git a/src/tempCodeRunnerFile.py b/src/tempCodeRunnerFile.py new file mode 100644 index 0000000..76d83bd --- /dev/null +++ b/src/tempCodeRunnerFile.py @@ -0,0 +1 @@ +Ollama(model="llama2", \ No newline at end of file