{"id":26674199,"url":"https://github.com/fuutoru/docker-api-ollama","last_synced_at":"2026-04-17T15:32:01.287Z","repository":{"id":284286187,"uuid":"932663708","full_name":"FuuToru/docker-api-ollama","owner":"FuuToru","description":"A Dockerized project integrating FastAPI and Ollama for sentiment analysis of text using the llama3.2:1b model.","archived":false,"fork":false,"pushed_at":"2025-03-25T05:24:35.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T05:30:13.479Z","etag":null,"topics":["docker","fastapi","ollama"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FuuToru.png","metadata":{"files":{"readme":"README.en.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-14T09:43:35.000Z","updated_at":"2025-03-25T05:24:38.000Z","dependencies_parsed_at":"2025-03-25T05:40:19.766Z","dependency_job_id":null,"html_url":"https://github.com/FuuToru/docker-api-ollama","commit_stats":null,"previous_names":["fuutoru/docker-api-ollama"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FuuToru/docker-api-ollama","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuuToru%2Fdocker-api-ollama","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuuToru%2Fdocker-api-ollama/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuuToru%2Fdocker-api-ollama/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuuToru%2Fdocker-api-ollama/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FuuToru","download_url":"https://codeload.github.com/FuuToru/docker-api-ollama/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuuToru%2Fdocker-api-ollama/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31934330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T12:37:54.787Z","status":"ssl_error","status_checked_at":"2026-04-17T12:37:25.095Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","fastapi","ollama"],"created_at":"2025-03-26T02:17:59.280Z","updated_at":"2026-04-17T15:32:01.271Z","avatar_url":"https://github.com/FuuToru.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker API Ollama\n\nA lightweight Dockerized application integrating FastAPI and Ollama for sentiment analysis of text. The project uses the `llama3.2:1b` model to classify sentiments into three categories: Neutral (NEU), Positive (POS), and Negative (NEG).\n\n## Project Structure\n\n```\nfuutoru-docker-api-ollama/\n├── docker-compose.yml         # Docker Compose configuration\n├── fastapi/                   # FastAPI service directory\n│   ├── app.py                 # Main FastAPI application\n│   ├── Dockerfile             # Dockerfile for FastAPI service\n│   └── requirements.txt       # Python dependencies\n└── ollama/                    # Ollama service directory\n    ├── Dockerfile             # Dockerfile for Ollama service\n    └── pull-llama3.sh         # Script to pull and run llama3.2:1b model\n```\n\n## Features\n\n- **Sentiment Analysis**: Analyzes text input to determine sentiment (NEU, POS, NEG) using the `llama3.2:1b` model.\n- **Dockerized Services**: Runs FastAPI and Ollama in isolated containers for easy deployment and scalability.\n- **API Endpoint**: Provides a simple GET endpoint (`/ask`) to process text and return sentiment labels.\n\n## Prerequisites\n\n- [Docker](https://docs.docker.com/get-docker/)\n- [Docker Compose](https://docs.docker.com/compose/install/)\n\n## Installation\n\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/fuutoru/docker-api-ollama.git\n   cd docker-api-ollama\n   ```\n\n2. **Build and run the services**:\n   ```bash\n   docker-compose up --build\n   ```\n   This command builds the FastAPI and Ollama images and starts the containers. The Ollama service will automatically pull the `llama3.2:1b` model on the first run.\n\n3. **Verify the services**:\n   - FastAPI will be available at `http://localhost:8000`.\n   - Ollama will be available at `http://localhost:11434`.\n\n## Usage\n\n### API Endpoints\n\n1. **Health Check**:\n   - **Endpoint**: `GET /`\n   - **Response**: `{\"status\": \"Ok\"}`\n   - **Description**: Checks if the FastAPI service is running.\n\n   Example:\n   ```bash\n   curl http://localhost:8000/\n   ```\n\n2. **Sentiment Analysis**:\n   - **Endpoint**: `GET /ask?prompt=\u003cyour-text\u003e`\n   - **Response**: One of `NEU`, `POS`, or `NEG`\n   - **Description**: Analyzes the sentiment of the provided text.\n\n   Example:\n   ```bash\n   curl \"http://localhost:8000/ask?prompt=rất%20tuyệt%20vời\"\n   ```\n   Response: `POS`\n\n### Example Scenarios\n\n- Input: `\"hoạt động kém hiệu quả\"`\n  - Output: `NEG`\n- Input: `\"Tôi không có ý kiến gì\"`\n  - Output: `NEU`\n- Input: `\"đang phát triển mạnh mẽ\"`\n  - Output: `POS`\n\n## Configuration\n\n- **Ports**:\n  - FastAPI: `8000`\n  - Ollama: `11434`\n- **Volumes**:\n  - FastAPI source code is mounted for live reloading during development.\n  - Ollama persists model data in the `ollama_volume` Docker volume.\n\n## Development\n\nTo modify the FastAPI application:\n1. Edit `fastapi/app.py`.\n2. Changes will be reloaded automatically due to the `--reload` flag in the FastAPI Dockerfile.\n\nTo use a different model:\n1. Update the `model` field in `fastapi/app.py` (e.g., replace `llama3.2:1b` with another model).\n2. Modify `ollama/pull-llama3.sh` to pull the desired model.\n\n## Troubleshooting\n\n- **Service not starting**: Check Docker logs with `docker-compose logs`.\n- **Model not loading**: Ensure internet access for the Ollama container to pull the `llama3.2:1b` model.\n- **API errors**: Verify the Ollama service is running and accessible at `http://ollama:11434`.\n\n## Contributing\n\nFeel free to submit issues or pull requests to improve this project. Please follow standard GitHub workflows for contributions.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- [FastAPI](https://fastapi.tiangolo.com/) for the web framework.\n- [Ollama](https://ollama.ai/) for providing the `llama3.2:1b` model and runtime.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuutoru%2Fdocker-api-ollama","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuutoru%2Fdocker-api-ollama","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuutoru%2Fdocker-api-ollama/lists"}