{"id":30318472,"url":"https://github.com/guitaripod/swollama","last_synced_at":"2025-12-11T23:00:51.345Z","repository":{"id":260059082,"uuid":"878303631","full_name":"guitaripod/Swollama","owner":"guitaripod","description":"A comprehensive Swift SDK for Ollama","archived":false,"fork":false,"pushed_at":"2025-06-27T21:45:59.000Z","size":136,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-17T11:49:20.437Z","etag":null,"topics":["chat","cli","concurrency","ollama","package","swift"],"latest_commit_sha":null,"homepage":"https://guitaripod.github.io/Swollama/","language":"Swift","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/guitaripod.png","metadata":{"files":{"readme":"README.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,"zenodo":null}},"created_at":"2024-10-25T06:26:58.000Z","updated_at":"2025-08-12T05:51:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"af6e24b9-3d61-4bb5-b049-a6abf29001dc","html_url":"https://github.com/guitaripod/Swollama","commit_stats":null,"previous_names":["marcusziade/swollama","guitaripod/swollama"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/guitaripod/Swollama","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitaripod%2FSwollama","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitaripod%2FSwollama/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitaripod%2FSwollama/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitaripod%2FSwollama/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guitaripod","download_url":"https://codeload.github.com/guitaripod/Swollama/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guitaripod%2FSwollama/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270899582,"owners_count":24664720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"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":["chat","cli","concurrency","ollama","package","swift"],"created_at":"2025-08-17T20:12:10.457Z","updated_at":"2025-12-11T23:00:51.254Z","avatar_url":"https://github.com/guitaripod.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swollama\n\n\u003cimg src=\"https://github.com/user-attachments/assets/bcad3675-5c0f-47aa-b4d2-ff2ebec54437\" alt=\"swollama-logo-small\" width=\"256\" height=\"256\" /\u003e\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fguitaripod%2FSwollama%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/guitaripod/Swollama)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fguitaripod%2FSwollama%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/guitaripod/Swollama)\n[![Documentation](https://img.shields.io/badge/Documentation-DocC-blue)](https://guitaripod.github.io/Swollama/documentation/swollama/)\n![License](https://img.shields.io/badge/License-GPL--v3-blue)\n\nA comprehensive, protocol-oriented Swift client for the Ollama API. This package provides a type-safe way to interact with Ollama's machine learning models, supporting all API endpoints with native Swift concurrency.\n\n## Features\n\n- Autonomous agents with web search capabilities\n- Full Ollama API coverage (chat, generation, embeddings, model management)\n- Native async/await and AsyncSequence support\n- Type-safe API with comprehensive error handling\n- Thread-safe implementation using Swift actors\n- Automatic retry logic with exponential backoff\n- Cross-platform (macOS, Linux, iOS)\n- Zero external dependencies\n\n## Requirements\n\n- macOS 14+ / iOS 17+ / Linux\n- Swift 5.9+\n- [Ollama](https://ollama.ai) installed and running\n\n## Installation\n\n### Swift Package Manager\n\nAdd Swollama to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/guitaripod/Swollama.git\", from: \"1.0.0\")\n]\n```\n\nOr add via Xcode: File \u003e Add Package Dependencies \u003e `https://github.com/guitaripod/Swollama.git`\n\n## Quick Start\n\n### Autonomous Agent with Web Search\n\n```swift\nimport Swollama\n\nlet agent = OllamaAgent(webSearchAPIKey: \"your_ollama_api_key\")\nguard let model = OllamaModelName.parse(\"qwen2.5:3b\") else { fatalError() }\n\nfor try await event in agent.run(\n    prompt: \"What are the latest features in Swift 6?\",\n    model: model\n) {\n    switch event {\n    case .thinking(let thought):\n        print(\"Thinking: \\(thought)\")\n    case .toolCall(let name, _):\n        print(\"Using tool: \\(name)\")\n    case .message(let answer):\n        print(\"Answer: \\(answer)\")\n    case .done:\n        print(\"Complete\")\n    default:\n        break\n    }\n}\n```\n\n### Chat Completion\n\n```swift\nimport Swollama\n\nlet client = OllamaClient()\nguard let model = OllamaModelName.parse(\"llama3.2\") else { fatalError() }\n\nlet responses = try await client.chat(\n    messages: [\n        ChatMessage(role: .user, content: \"Hello! How are you?\")\n    ],\n    model: model\n)\n\nfor try await response in responses {\n    print(response.message.content, terminator: \"\")\n}\n```\n\n## CLI Usage\n\nInteractive chat:\n```bash\nswollama chat llama3.2\n```\n\nAutonomous agent:\n```bash\nswollama agent qwen2.5:3b --prompt \"What's new in Swift?\"\n```\n\nGenerate text:\n```bash\nswollama generate codellama\n```\n\nModel management:\n```bash\nswollama pull llama3.2\nswollama list\nswollama show llama3.2\nswollama delete old-model\n```\n\n## Documentation\n\nComplete API documentation, examples, and feature guides:\n- [API Reference](https://guitaripod.github.io/Swollama/documentation/swollama/)\n- [Feature Guide](FEATURES.md)\n\n## Examples\n\n### Text Generation with Options\n\n```swift\nlet client = OllamaClient()\nguard let model = OllamaModelName.parse(\"llama3.2\") else { fatalError() }\n\nlet stream = try await client.generateText(\n    prompt: \"Explain quantum computing\",\n    model: model,\n    options: GenerationOptions(\n        temperature: 0.7,\n        topP: 0.9,\n        numPredict: 200\n    )\n)\n\nfor try await response in stream {\n    print(response.response, terminator: \"\")\n}\n```\n\n### Embeddings\n\n```swift\nlet client = OllamaClient()\nguard let model = OllamaModelName.parse(\"nomic-embed-text\") else { fatalError() }\n\nlet response = try await client.generateEmbeddings(\n    input: .single(\"Hello world\"),\n    model: model\n)\n\nprint(\"Vector dimensions: \\(response.embeddings[0].count)\")\n```\n\n### Tool Calling\n\n```swift\nlet tools = [\n    ToolDefinition(\n        type: \"function\",\n        function: FunctionDefinition(\n            name: \"get_weather\",\n            description: \"Get current weather\",\n            parameters: JSONSchema(\n                type: \"object\",\n                properties: [\n                    \"location\": JSONSchemaProperty(type: \"string\")\n                ],\n                required: [\"location\"]\n            )\n        )\n    )\n]\n\nlet stream = try await client.chat(\n    messages: [ChatMessage(role: .user, content: \"What's the weather in Paris?\")],\n    model: OllamaModelName.parse(\"llama3.2\")!,\n    options: ChatOptions(tools: tools)\n)\n\nfor try await response in stream {\n    if let toolCalls = response.message.toolCalls {\n        for call in toolCalls {\n            print(\"Tool: \\(call.function.name)\")\n            print(\"Args: \\(call.function.arguments)\")\n        }\n    }\n}\n```\n\n## Contributing\n\nContributions are welcome. Please open an issue first to discuss major changes.\n\n## License\n\nGPL-v3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguitaripod%2Fswollama","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguitaripod%2Fswollama","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguitaripod%2Fswollama/lists"}