{"id":23002589,"url":"https://github.com/aws-samples/swift-chat","last_synced_at":"2025-04-12T18:45:59.819Z","repository":{"id":266031793,"uuid":"884016383","full_name":"aws-samples/swift-chat","owner":"aws-samples","description":"A lightning-fast, cross-platform AI chat application built with React Native.","archived":false,"fork":false,"pushed_at":"2025-04-02T15:42:46.000Z","size":5710,"stargazers_count":341,"open_issues_count":5,"forks_count":36,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-04-05T01:02:32.164Z","etag":null,"topics":["amazon-bedrock","amazon-nova","android","aws","bedrock-client","chat","claude-3-7-sonnet","deepseek","genai","gpt-4o","image-generation","ios","mac","mobile-app","ollama","ollama-client","react-native","swift-chat","swiftchat","video-understanding"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit-0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aws-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2024-11-06T01:32:40.000Z","updated_at":"2025-04-04T19:51:56.000Z","dependencies_parsed_at":"2025-01-20T05:33:12.518Z","dependency_job_id":null,"html_url":"https://github.com/aws-samples/swift-chat","commit_stats":null,"previous_names":["aws-samples/swift-chat"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Fswift-chat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Fswift-chat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Fswift-chat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Fswift-chat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aws-samples","download_url":"https://codeload.github.com/aws-samples/swift-chat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248617490,"owners_count":21134191,"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":["amazon-bedrock","amazon-nova","android","aws","bedrock-client","chat","claude-3-7-sonnet","deepseek","genai","gpt-4o","image-generation","ios","mac","mobile-app","ollama","ollama-client","react-native","swift-chat","swiftchat","video-understanding"],"created_at":"2024-12-15T07:11:28.698Z","updated_at":"2025-04-12T18:45:59.812Z","avatar_url":"https://github.com/aws-samples.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# SwiftChat - A Cross-platform AI Chat App\n\n\u003e 🚀 Your Personal AI Assistant - Fast, Private, and Cross-platform\n\n[![GitHub Release](https://img.shields.io/github/v/release/aws-samples/swift-chat)](https://github.com/aws-samples/swift-chat/releases)\n[![License](https://img.shields.io/badge/license-MIT--0-green)](LICENSE)\n\n## 📱 Quick Download\n\n- [Download for Android](https://github.com/aws-samples/swift-chat/releases/download/2.2.0/SwiftChat.apk)\n- [Download for macOS](https://github.com/aws-samples/swift-chat/releases/download/2.2.0/SwiftChat.dmg)\n- For iOS: Currently available through local build with Xcode\n\n[中文](/README_CN.md)\n\nSwiftChat is a fast and responsive AI chat application developed with [React Native](https://reactnative.dev/) and\npowered by [Amazon Bedrock](https://aws.amazon.com/bedrock/), with compatibility extending to other model providers such\nas Ollama, DeepSeek, OpenAI and OpenAI Compatible. With its minimalist design philosophy and robust privacy protection,\nit delivers real-time streaming conversations and AI image generation capabilities across Android, iOS, and macOS\nplatforms.\n\n![](assets/promo.avif)\n\n### What's New 🔥\n\n- Support for OpenAI Compatible models. You can now\n  use [easy-model-deployer](https://github.com/aws-samples/easy-model-deployer),\n  OpenRouter, or any OpenAI-compatible model provider via SwiftChat. Please\n  check [Configure OpenAI Compatible](#openai-compatible) section for more details(From v2.2.0).\n- Support for quick model switching (From v2.2.0).\n- Support regeneration of AI responses (From v2.2.0).\n\n**Key Features:**\n\n- Real-time streaming chat with AI\n- Rich Markdown Support: Tables, Code Blocks, LaTeX and More\n- AI image generation with progress\n- Multimodal support (images, videos \u0026 documents)\n- Conversation history list view and management\n- Cross-platform support (Android, iOS, macOS)\n- Tablet-optimized for iPad and Android tablets\n- Fast launch and responsive performance\n- Multiple AI model\n  supported ([Amazon Bedrock](https://aws.amazon.com/bedrock/), [Ollama](https://github.com/ollama/ollama), [DeepSeek](https://www.deepseek.com/), [OpenAI](https://openai.com/)\n  and [OpenAI Compatible](#openai-compatible) Models)\n- Fully Customizable System Prompt Assistant\n\n**Supported Features For Amazon Nova series**\n\n- Record 30-second videos directly on Android and iOS for Nova analysis\n- Upload large videos (1080p/4K) beyond 8MB with auto compression\n- Support using natural language to make Nova Canvas generate images, remove backgrounds, replace backgrounds, and\n  create images in similar styles.\n\n### Feature Showcase\n\n#### YouTube Video\n\n[\u003cimg src=\"./assets/youtube.avif\"\u003e](https://www.youtube.com/watch?v=rey05WzfEbM)\n\u003e The content in the video is an early version. For UI, architecture, and inconsistencies, please refer to the current \n\u003e documentation.\n\n**Comprehensive Multimodal Analysis**: Text, Image, Document and Video\n\n\u003cdiv style=\"display: flex; flex-direction: 'row'; background-color: #888888;\"\u003e\n\u003cimg src=\"assets/animations/text_streaming.avif\" width=24%\u003e\n\u003cimg src=\"assets/animations/image_summary.avif\" width=24%\u003e\n\u003cimg src=\"assets/animations/doc_summary.avif\" width=24%\u003e\n\u003cimg src=\"assets/animations/video_summary.avif\" width=24%\u003e\n\u003c/div\u003e\n\n**Creative Image Suite**: Generation, Style Replication, Background Removal \u0026 Replacement with Nova Canvas\n\n\u003cdiv style=\"display: flex; flex-direction: 'row'; background-color: #888888;\"\u003e\n\u003cimg src=\"assets/animations/gen_image.avif\" width=24%\u003e\n\u003cimg src=\"assets/animations/similar_style.avif\" width=24%\u003e\n\u003cimg src=\"assets/animations/remove_background.avif\" width=24%\u003e\n\u003cimg src=\"assets/animations/replace_background.avif\" width=24%\u003e\n\u003c/div\u003e\n\n**System Prompt Assistant**: Useful Preset System Prompts with Full Management Capabilities (Add/Edit/Sort/Delete)\n\n![](assets/animations/english_teacher.avif)\n\n**Rich Markdown Support**: Paragraph, Code Blocks, Tables, LaTeX and More\n\n![](assets/markdown.avif)\n\nWe redesigned the UI with optimized font sizes and line spacing for a more elegant and clean presentation.\nAll of these features are also seamlessly displayed on Android and macOS with native UI\n\n\u003e Note: Some animated images have been sped up for demonstration. If you experience lag, please view on Chrome, Firefox,\n\u003e or Edge browser on your computer.\n\n## Architecture\n\n![](/assets/architecture.avif)\n\nBy default, we use **AWS App Runner**, which is commonly used to host Python FastAPI servers, offering high performance,\nscalability and low latency.\n\nAlternatively, we provide the option to replace App Runner with **AWS Lambda** using Function URL for a more\ncost-effective\nsolution, as shown in\nthis [example](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/fastapi-response-streaming).\n\n## Getting Started with Amazon Bedrock\n\n### Prerequisites\n\nEnsure you have access to Amazon Bedrock foundation models. SwiftChat default settings are:\n\n- Region: `us-west-2`\n- Text Model: `Amazon Nova Pro`\n- Image Model: `Stable Diffusion 3.5 Large`\n\nIf you are using the image generation feature, please make sure you have enabled access to the `Amazon Nova Lite` model.\nPlease follow\nthe [Amazon Bedrock User Guide](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access-modify.html) to\nenable your models.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e🔧 Configuration Steps (Click to expand)\u003c/b\u003e\u003c/summary\u003e\n\n### Step 1: Set up your API Key\n\n1. Sign in to your AWS console and\n   right-click [Parameter Store](https://console.aws.amazon.com/systems-manager/parameters/) to open it in a new tab.\n2. Check whether you are in the [supported region](#supported-region), then click on the **Create parameter** button.\n3. Fill in the parameters below, leaving other options as default:\n\n    - **Name**: Enter a parameter name (e.g., \"SwiftChatAPIKey\", will be used as `ApiKeyParam` in Step 2).\n\n    - **Type**: Select `SecureString`\n\n    - **Value**: Enter any string without spaces.(this will be your `API Key` in Step 3)\n\n4. Click **Create parameter**.\n\n### Step 2: Deploy stack and get your API URL\n\n1. Click one of the following buttons to launch the CloudFormation Stack in the same region where your API Key was\n   created.\n\n    - **App Runner**\n\n      [![Launch Stack](assets/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatAPI\u0026templateURL=https://aws-gcr-solutions.s3.amazonaws.com/swift-chat/latest/SwiftChatAppRunner.template)\n\n    - **Lambda** (Note: For AWS customer use only)\n\n      [![Launch Stack](assets/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatLambda\u0026templateURL=https://aws-gcr-solutions.s3.amazonaws.com/swift-chat/latest/SwiftChatLambda.template)\n\n2. Click **Next**, On the \"Specify stack details\" page, provide the following information:\n    - Fill the `ApiKeyParam` with the parameter name you used for storing the API key (e.g., \"SwiftChatAPIKey\").\n    - For App Runner, choose an `InstanceTypeParam` based on your needs.\n3. Click **Next**, Keep the \"Configure stack options\" page as default, Read the Capabilities and Check the \"I\n   acknowledge that AWS CloudFormation might create IAM resources\" checkbox at the bottom.\n4. Click **Next**, In the \"Review and create\" Review your configuration and click **Submit**.\n\nWait about 3-5 minutes for the deployment to finish, then click the CloudFormation stack and go to **Outputs** tab, you\ncan find the **API URL** which looks like: `https://xxx.xxx.awsapprunner.com` or `https://xxx.lambda-url.xxx.on.aws`\n\n### Step 3: Open the App and setup with API URL and API Key\n\n1. Launch the App, open the drawer menu, and tap **Settings**.\n2. Paste the `API URL` and `API Key`(The **Value** you typed in Parameter Store) then select the Region.\n3. Click the top right ✓ icon to save your configuration and start your chat.\n\nCongratulations 🎉 Your SwiftChat App is ready to use!\n\u003c/details\u003e\n\n### Supported Region\n\n- US East (N. Virginia): us-east-1\n- US West (Oregon): us-west-2\n- Asia Pacific (Mumbai): ap-south-1\n- Asia Pacific (Singapore): ap-southeast-1\n- Asia Pacific (Sydney): ap-southeast-2\n- Asia Pacific (Tokyo): ap-northeast-1\n- Canada (Central): ca-central-1\n- Europe (Frankfurt): eu-central-1\n- Europe (London): eu-west-2\n- Europe (Paris): eu-west-3\n- South America (São Paulo): sa-east-1\n\n## Getting Started with Other Model Providers\n\n### Ollama\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e🔧 Configure Ollama (Click to expand)\u003c/b\u003e\u003c/summary\u003e\n\n1. Navigate to the **Settings Page** and select the **Ollama** tab.\n2. Enter your Ollama Server URL. For example:\n    ```bash\n    http://localhost:11434\n    ```\n3. Once the correct Server URL is entered, you can select your desired Ollama models from the **Text Model** dropdown\n   list.\n\n\u003c/details\u003e\n\n### DeepSeek\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e🔧 Configure DeepSeek (Click to expand)\u003c/b\u003e\u003c/summary\u003e\n\n1. Go to the **Settings Page** and select the **DeepSeek** tab.\n2. Input your DeepSeek API Key.\n3. Choose DeepSeek models from the **Text Model** dropdown list. Currently, the following DeepSeek models are supported:\n    - `DeepSeek-V3`\n    - `DeepSeek-R1`\n\n\u003c/details\u003e\n\n### OpenAI\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e🔧 Configure OpenAI (Click to expand)\u003c/b\u003e\u003c/summary\u003e\n\n1. Navigate to the **Settings Page** and select the **OpenAI** tab.\n2. Enter your OpenAI API Key.\n3. Select OpenAI models from the **Text Model** dropdown list. The following OpenAI models are currently supported:\n    - `GPT-4o`\n    - `GPT-4o mini`\n\nAdditionally, if you have deployed the [ClickStream Server](#step-2-deploy-stack-and-get-your-api-url), you can enable\nthe **Use Proxy** option to forward your requests.\n\n\u003c/details\u003e\n\n### OpenAI Compatible\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e🔧 Configure OpenAI Compatible models (Click to expand)\u003c/b\u003e\u003c/summary\u003e\n\n1. Navigate to the **Settings Page** and select the **OpenAI** tab.\n2. Under **OpenAI Compatible**, enter the following information:\n    - `Base URL` of your model provider\n    - `API Key` of your model provider\n    - `Model ID` of the models you want to use (separate multiple models with commas)\n3. Select one of your models from the **Text Model** dropdown list.\n\n\u003c/details\u003e\n\n## Detailed Features\n\n**Quick Access Tools**: Code \u0026 Content Copy, Selection Mode, Model Switch, Regenerate, Scroll Controls and Token Counter\n\n\u003cdiv style=\"display: flex; flex-direction: 'row'; background-color: #888888;\"\u003e\n\u003cimg src=\"assets/animations/copy.avif\" width=32%\u003e\n\u003cimg src=\"assets/animations/regenerate.avif\" width=32%\u003e\n\u003cimg src=\"assets/animations/scroll_token.avif\" width=32%\u003e\n\u003c/div\u003e\n\nWe feature streamlined chat History, Settings pages, and intuitive Usage statistics:\n\n![](assets/history_settings.avif)\n\n### Message Handling\n\n- [x] Text copy support:\n    - Copy button at the bottom of messages, or directly click the model name or user title section.\n    - Copy button in code blocks\n    - Direct Select and copy code on macOS (double click or long click on iOS)\n    - Long press text to copy entire sentence (Right-click on macOS)\n- [x] Text selection mode by click selection button.\n- [x] Message timeline view in history\n- [x] Delete messages through long press in history\n- [x] Click to preview for documents videos and images\n\n### Image Features\n\n- [x] Support image generation with Chinese prompts(Make sure `Amazon Nova Lite` is enabled in your selected region)\n- [x] Long press images to save or share\n- [x] Automatic image compression to improve response speed\n\n### User Experience\n\n- [x] Haptic feedback for Android and iOS (can be disabled in Settings)\n- [x] Support landscape mode on Android/iOS devices\n- [x] Double tap title bar to scroll to top\n- [x] Click bottom arrow to view latest messages\n- [x] Display system prompt and model switch icon again by clicking on the chat title\n- [x] View current session token usage by tapping twice Chat title\n- [x] Check detailed token usage and image generation count in Settings\n- [x] In-app upgrade notifications (Android \u0026 macOS)\n\nWe have optimized the layout for landscape mode. As shown below, you can comfortably view table/code contents in\nlandscape orientation.\n\n![](assets/animations/landscape.avif)\n\n## What Makes SwiftChat Really \"Swift\"?\n\n🚀 **Fast Launch Speed**\n\n- Thanks to the **AOT** (Ahead of Time) compilation of RN Hermes engine\n- Added **lazy loading** of complex components\n- App launches instantly and is immediately ready for input\n\n🌐 **Fast Request Speed**\n\n- Speed up end-to-end API requests through **image compression**\n- Deploying APIs in the **same region** as Bedrock provides lower latency\n\n📱 **Fast Render Speed**\n\n- Using `useMemo` and custom caching to creates secondary cache for session content\n- Reduce unnecessary re-renders and speed up streaming messages display\n- All UI components are rendered as **native components**\n\n📦 **Fast Storage Speed**\n\n- By using **react-native-mmkv** Messages can be read, stored, and updated **10x faster** than AsyncStorage\n- Optimized session content and session list storage structure to accelerates history list display\n\n## App Privacy \u0026 Security\n\n- Encrypted API key storage\n- Minimal permission requirements\n- Local-only data storage\n- No user behavior tracking\n- No data collection\n- Privacy-first approach\n\n## App Build and Development\n\nFirst, clone this repository. All app code is located in the `react-native` folder. Before proceeding, execute the\nfollowing command to download dependencies.\n\n```bash\ncd react-native \u0026\u0026 npm i \u0026\u0026 npm start\n```\n\n### Build for Android\n\nopen a new terminal and execute:\n\n```bash\nnpm run android\n```\n\n### Build for iOS\n\nalso open a new terminal, for the first time you need to install the native dependencies\nby execute `cd ios \u0026\u0026 pod install \u0026\u0026 cd ..`, then execute the follow command:\n\n```bash\nnpm run ios\n```\n\n### Build for macOS\n\n1. Execute `npm start`.\n2. Double click `ios/SwiftChat.xcworkspace` to open the project in your Xcode.\n3. Change the build destination to `My Mac (Mac Catalyst)` then click the ▶ Run button.\n\n## API Reference\n\nPlease refer [API Reference](server/README.md)\n\n## How to upgrade?\n\n### Upgrade App\n\n- **Android** and **macOS**: Navigate to **Settings** Page, if there is a new version, you will find it at the bottom\n  of this page, then click the app version to download and install it.\n- **iOS**: If a new version is released in the [Release page](https://github.com/aws-samples/swift-chat/releases),\n  update your local code, rebuild and install your app by Xcode.\n\n**Note**: After downloading a new version, please check\nthe [release notes](https://github.com/aws-samples/swift-chat/releases) to see if an API version update is required.\n\n### Upgrade API\n\n- **For AppRunner**: Click and open [App Runner Services](https://console.aws.amazon.com/apprunner/home#/services) page,\n  find and open `swiftchat-api`, click top right **Deploy** button.\n- **For Lambda**: Click and open [Lambda Services](https://console.aws.amazon.com/lambda/home#/functions), find and open\n  your Lambda which start with `SwiftChatLambda-xxx`, click the **Deploy new image** button and click Save.\n\n## Security\n\nSee [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.\n\n## License\n\nThis library is licensed under the MIT-0 License. See the [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-samples%2Fswift-chat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faws-samples%2Fswift-chat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-samples%2Fswift-chat/lists"}