{"id":48548739,"url":"https://github.com/legionio/lex-ollama","last_synced_at":"2026-04-08T08:00:47.725Z","repository":{"id":348610783,"uuid":"1197786387","full_name":"LegionIO/lex-ollama","owner":"LegionIO","description":"Connects LegionIO to Ollama local LLM server","archived":false,"fork":false,"pushed_at":"2026-04-08T06:01:26.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-08T08:00:28.975Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/LegionIO.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-31T22:13:41.000Z","updated_at":"2026-04-08T06:00:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"b669c16a-b50d-4f40-b516-1a4c75c3aaa0","html_url":"https://github.com/LegionIO/lex-ollama","commit_stats":null,"previous_names":["legionio/lex-ollama"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/LegionIO/lex-ollama","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegionIO%2Flex-ollama","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegionIO%2Flex-ollama/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegionIO%2Flex-ollama/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegionIO%2Flex-ollama/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LegionIO","download_url":"https://codeload.github.com/LegionIO/lex-ollama/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LegionIO%2Flex-ollama/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31545906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"online","status_checked_at":"2026-04-08T02:00:06.127Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2026-04-08T08:00:25.523Z","updated_at":"2026-04-08T08:00:47.718Z","avatar_url":"https://github.com/LegionIO.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lex-ollama\n\nOllama integration for [LegionIO](https://github.com/LegionIO/LegionIO). Connects LegionIO to a local Ollama LLM server for text generation, chat completions, embeddings, and model management.\n\n## Installation\n\n```bash\ngem install lex-ollama\n```\n\n## Functions\n\n### Completions\n- `generate` - Generate a text completion (POST /api/generate)\n- `generate_stream` - Stream a text completion with per-chunk callbacks\n\n### Chat\n- `chat` - Generate a chat completion with message history and tool support (POST /api/chat)\n- `chat_stream` - Stream a chat completion with per-chunk callbacks\n\n### Models\n- `create_model` - Create a model from another model, GGUF, or safetensors (POST /api/create)\n- `list_models` - List locally available models (GET /api/tags)\n- `show_model` - Show model details, template, parameters, license (POST /api/show)\n- `copy_model` - Copy a model to a new name (POST /api/copy)\n- `delete_model` - Delete a model and its data (DELETE /api/delete)\n- `pull_model` - Download a model from the Ollama library (POST /api/pull)\n- `push_model` - Upload a model to the Ollama library (POST /api/push)\n- `list_running` - List models currently loaded in memory (GET /api/ps)\n\n### Embeddings\n- `embed` - Generate embeddings from a model (POST /api/embed)\n\n### Blobs\n- `check_blob` - Check if a blob exists on the server (HEAD /api/blobs/:digest)\n- `push_blob` - Upload a binary blob to the server (POST /api/blobs/:digest)\n\n### S3 Model Distribution\n- `list_s3_models` - List models available in an S3 mirror\n- `import_from_s3` - Download model from S3 directly to Ollama's filesystem (works before Ollama starts)\n- `sync_from_s3` - Download model from S3, push blobs through Ollama's API, write manifest to filesystem\n- `import_default_models` - Import a list of models from S3 (fleet provisioning)\n\n### Version\n- `server_version` - Retrieve the Ollama server version (GET /api/version)\n\n## Standalone Client\n\n```ruby\nclient = Legion::Extensions::Ollama::Client.new\n# or with custom host\nclient = Legion::Extensions::Ollama::Client.new(host: 'http://remote:11434')\n\n# Chat\nresult = client.chat(model: 'llama3.2', messages: [{ role: 'user', content: 'Hello!' }])\n\n# Generate\nresult = client.generate(model: 'llama3.2', prompt: 'Why is the sky blue?')\n\n# Embeddings\nresult = client.embed(model: 'all-minilm', input: 'Some text to embed')\n\n# List models\nresult = client.list_models\n\n# Streaming generate\nclient.generate_stream(model: 'llama3.2', prompt: 'Tell me a story') do |event|\n  case event[:type]\n  when :delta then print event[:text]\n  when :done  then puts \"\\nDone!\"\n  end\nend\n\n# Streaming chat\nclient.chat_stream(model: 'llama3.2', messages: [{ role: 'user', content: 'Hello!' }]) do |event|\n  print event[:text] if event[:type] == :delta\nend\n```\n\n## S3 Model Distribution\n\nPull models from an internal S3 mirror instead of the public Ollama registry:\n\n```ruby\nclient = Legion::Extensions::Ollama::Client.new\n\n# List available models in S3\nclient.list_s3_models(bucket: 'legion', endpoint: 'https://mesh.s3api-core.optum.com')\n\n# Import directly to filesystem (works without Ollama running)\nclient.import_from_s3(model: 'llama3:latest', bucket: 'legion',\n                      endpoint: 'https://mesh.s3api-core.optum.com')\n\n# Push through Ollama API (requires Ollama running)\nclient.sync_from_s3(model: 'llama3:latest', bucket: 'legion',\n                    endpoint: 'https://mesh.s3api-core.optum.com')\n\n# Provision fleet with default models\nclient.import_default_models(\n  default_models: %w[llama3:latest nomic-embed-text:latest],\n  bucket: 'legion',\n  endpoint: 'https://mesh.s3api-core.optum.com'\n)\n```\n\nS3 operations use [lex-s3](https://github.com/LegionIO/lex-s3). The S3 bucket should mirror the Ollama models directory structure (`manifests/` and `blobs/` under the configured prefix).\n\nAll API calls include automatic retry with exponential backoff on connection failures and timeouts.\n\nGenerate and chat responses include standardized `usage:` data:\n```ruby\nresult = client.generate(model: 'llama3.2', prompt: 'Hello')\nresult[:usage]  # =\u003e { input_tokens: 1, output_tokens: 5, total_duration: ..., ... }\n```\n\n## Requirements\n\n- Ruby \u003e= 3.4\n- [LegionIO](https://github.com/LegionIO/LegionIO) framework\n- [Ollama](https://ollama.com) running locally or on a remote host\n\n## Version\n\n0.3.1\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flegionio%2Flex-ollama","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flegionio%2Flex-ollama","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flegionio%2Flex-ollama/lists"}