{"id":27206474,"url":"https://github.com/developerzelentsov/swiftassistant","last_synced_at":"2025-04-09T23:33:13.556Z","repository":{"id":207767006,"uuid":"718848184","full_name":"DeveloperZelentsov/SwiftAssistant","owner":"DeveloperZelentsov","description":" A Swift library for integrating with the OpenAI Assistants API, enabling the creation and management of assistants, message processing, and AI runs.","archived":false,"fork":false,"pushed_at":"2025-03-18T16:04:33.000Z","size":137,"stargazers_count":31,"open_issues_count":10,"forks_count":6,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-24T01:23:10.217Z","etag":null,"topics":["ai","api","assistant","assistants","async","await","chatgpt","gpt","gpt-3","gpt-4","openai","spm","swift","swift4","swift5","swiftui","uikit"],"latest_commit_sha":null,"homepage":"https://platform.openai.com/docs/api-reference/assistants","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeveloperZelentsov.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}},"created_at":"2023-11-14T23:06:25.000Z","updated_at":"2025-03-20T10:36:23.000Z","dependencies_parsed_at":"2025-02-16T02:31:55.945Z","dependency_job_id":"c2450f54-dfa2-4dfc-b1af-969d3f8e25f6","html_url":"https://github.com/DeveloperZelentsov/SwiftAssistant","commit_stats":null,"previous_names":["developerzelentsov/aiswiftassist","developerzelentsov/swiftassistant"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeveloperZelentsov%2FSwiftAssistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeveloperZelentsov%2FSwiftAssistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeveloperZelentsov%2FSwiftAssistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeveloperZelentsov%2FSwiftAssistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeveloperZelentsov","download_url":"https://codeload.github.com/DeveloperZelentsov/SwiftAssistant/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248129998,"owners_count":21052677,"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","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":["ai","api","assistant","assistants","async","await","chatgpt","gpt","gpt-3","gpt-4","openai","spm","swift","swift4","swift5","swiftui","uikit"],"created_at":"2025-04-09T23:32:07.474Z","updated_at":"2025-04-09T23:33:13.546Z","avatar_url":"https://github.com/DeveloperZelentsov.png","language":"Swift","funding_links":["https://www.buymeacoffee.com/zelentsov"],"categories":[],"sub_categories":[],"readme":"# AISwiftAssist\n\nA Swift Package Manager (SPM) library for iOS 13 and above, designed to simplify the integration with OpenAI's Assistants API in iOS applications. This library allows you to build AI-powered assistants efficiently and interactively.\n\n[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/zelentsov)\n\n## Features\n\n- Seamless integration with OpenAI's Assistants API.\n- Easily create and manage AI assistants with various models and tools.\n- Handle conversations through threads and messages.\n- Utilize Code Interpreter, Retrieval, and Function calling tools.\n- Optimized for iOS 13+ with Swift.\n\n## Installation\n\n### Using Xcode\n\nTo add `AISwiftAssist` to your Xcode project, follow these steps:\n\n1. Open your project in Xcode.\n2. Click on \"File\" in the menu bar, then select \"Swift Packages\" and then \"Add Package Dependency...\"\n3. In the dialog that appears, enter the package repository URL: `https://github.com/DeveloperZelentsov/AiSwiftAssist.git`.\n4. Choose the last version to integrate and click \"Next\".\n5. Confirm the package products and targets and click \"Finish\".\n\n## Usage\n\n### Step 1: Import the Library\n\nImport `AISwiftAssist` into your Swift file where you wish to use it:\n\n```swift\nimport AISwiftAssist\n```\n\n### Step 2: Initialize the Client\n\nCreate an instance of AISwiftAssistClient using your API key and organization ID:\n\n```swift\nlet config = AISwiftAssistConfig(apiKey: \"your-api-key\", organizationId: \"your-org-id\")\nlet aiSwiftAssistClient = AISwiftAssistClient(config: config)\n```\n\n### Step 3: Create an Assistant\n\nTo create an AI assistant, define its parameters such as model, name, description, and instructions. You can also specify tools and file IDs if required:\n\n```swift\nlet assistantParams = AssistantCreationParams(\n    modelName: \"gpt-4-1106-preview\",\n    name: \"Math Tutor\",\n    description: \"Your personal math tutor.\",\n    instructions: \"Solve math problems and explain solutions.\"\n)\n\nlet creationAssistantParams = try await aiSwiftAssistClient.createAssistantAndThread(with: assistantParams)\nlet assistantId = creationParams.assistant.id\nlet threadId = creationParams.thread.id\n```\n\n### Step 4: Manage Conversations\n\nSending Messages\n\nSend a message to your assistant through a created thread:\n\n```swift\nlet messageRequest: ASACreateMessageRequest = .init(role: \"user\", content: content)\ntry await aiSwiftAssistClient.messagesApi.create(by: threadId, createMessage: messageRequest)\n```\n\nInitiating a Run\n\nTo process the message and receive a response, initiate a run:\n\n```swift\nlet runRequest = ASACreateRunRequest(assistantId: assistantId)\ntry await aiSwiftAssistClient.runsApi.create(by: threadId, createRun: runRequest)\n```\n\nFetching Responses\n\nRetrieve the assistant's response:\n\n```swift\nlet messages = try await aiSwiftAssistClient.messagesApi.list(threadId: threadId)\n// Process and display these messages, including the assistant's response.\n```\n\n### Step 5: Continuous Interaction\n\nContinue the conversation by sending additional messages, initiating runs, and fetching responses. This creates a dynamic and interactive communication flow with the assistant.\n\n## Beyond the Basics\n\nThis is an example of the most basic usage of the Assistants API. There is potential for much more complex and interesting assistants, and I will continue to evolve this Swift API to enable you to leverage these advanced capabilities.\n\n## Feedback and Contributions\n\nWe welcome your feedback and contributions to enhance `AISwiftAssist`. Please feel free to report issues or submit pull requests on our GitHub repository.\n\n## License\n\nThis library is distributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperzelentsov%2Fswiftassistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloperzelentsov%2Fswiftassistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperzelentsov%2Fswiftassistant/lists"}