Skip to content

Commit 3339d68

Browse files
authored
feat: support web search and create app
1 parent ecf3de1 commit 3339d68

File tree

121 files changed

+9826
-1370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+9826
-1370
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
required: true
1212
type: string
1313
permissions:
14-
contents: read
14+
contents: write
1515
pull-requests: write
1616
env:
1717
NEW_VERSION: ${{ github.event.inputs.release_tag }}

README.md

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,41 @@ across Android, iOS, and macOS platforms.
1616
![](assets/promo.avif)
1717

1818
### What's New 🔥
19+
- 🚀 Support Create App to create, edit and share instant web apps (From v2.7.0).
20+
- 🚀 Support Web Search for real-time information retrieval (From v2.7.0).
21+
- 🚀 Update SwiftChat Server with API Gateway + Lambda deployment supporting 15-minute streaming output (From v2.7.0).
22+
- 🚀 Support Image Gallery for browsing and managing generated images (From v2.7.0).
1923
- 🚀 Support streaming rendering of Mermaid charts (From v2.6.0).
20-
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
21-
<img src="assets/animations/mermaid_en.avif" width=48%>
22-
<img src="assets/animations/mermaid_save_en.avif" width=48%>
23-
</div>
2424
- 🚀 Support using Bedrock API Key for Amazon Bedrock models (From v2.5.0).
25-
- 🚀 Support virtual try-on, automatically recognize clothes, pants, shoes and try them on (From v2.5.0).
26-
- 🚀 Support shortcuts for macOS (From v2.5.0).
27-
- Use `Shift + Enter`, `Control + Enter` or `Option + Enter` to add a line break.
28-
- Use `⌘ + V` to add images (Screenshot), videos, or documents from your clipboard.
29-
- Use `⌘ + N` to opening multiple Mac windows for parallel operations.
25+
26+
**Create App**: Generate, Edit, Share and Preview Instant Web Apps
27+
28+
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
29+
<img src="assets/animations/create_app.avif" width=24%>
30+
<img src="assets/animations/edit_and_save.avif" width=24%>
31+
<img src="assets/animations/gallery_edit_app.avif" width=24%>
32+
<img src="assets/animations/share_and_import.avif" width=24%>
33+
</div>
34+
35+
**App Examples**: 2048 Game, Gomoku, News Reader and Tetris
36+
37+
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
38+
<img src="assets/animations/app_2048.avif" width=24%>
39+
<img src="assets/animations/app_gomoku.avif" width=24%>
40+
<img src="assets/animations/app_news.avif" width=24%>
41+
<img src="assets/animations/app_tetris.avif" width=24%>
42+
</div>
43+
44+
**Web Search & Mermaid**: Real-time Information Retrieval and Streaming Chart Rendering
45+
46+
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
47+
<img src="assets/animations/websearch_tavily.avif" width=24%>
48+
<img src="assets/animations/websearch_google.avif" width=24%>
49+
<img src="assets/animations/mermaid_en.avif" width=24%>
50+
<img src="assets/animations/mermaid_save_en.avif" width=24%>
51+
</div>
52+
53+
> Note: Tavily is recommended for best results. Google Search requires manual verification on first use. Baidu and Bing are currently in beta and may return inaccurate results.
3054
3155
## 📱 Quick Download
3256

@@ -36,11 +60,6 @@ across Android, iOS, and macOS platforms.
3660

3761
## Getting Started with Amazon Bedrock
3862

39-
### Prerequisites
40-
41-
Click [Amazon Bedrock Model access](https://console.aws.amazon.com/bedrock/home#/modelaccess) to enable your models
42-
access.
43-
4463
### Configuration
4564

4665
You can choose one of the following two methods for configuration
@@ -62,16 +81,13 @@ You can choose one of the following two methods for configuration
6281
<details>
6382
<summary><b>🔧 Configure SwiftChat Server (Click to expand)</b></summary>
6483

65-
### Architecture
84+
> **Note**: From v2.7.0, we recommend redeploying the SwiftChat Server for better performance with API Gateway + Lambda supporting 15-minute streaming output. Your existing API Key can be reused - you only need to update the Server URL in the app.
6685
67-
![](/assets/architecture.avif)
86+
### Architecture
6887

69-
By default, we use **AWS App Runner**, which is commonly used to host Python FastAPI servers, offering high performance,
70-
scalability and low latency.
88+
![](/assets/architecture.png)
7189

72-
Alternatively, we provide the option to replace App Runner with **AWS Lambda** using Function URL for a more
73-
cost-effective
74-
solution, as shown in
90+
We use **API Gateway** combined with **AWS Lambda** to enable streaming responses for up to 15 minutes, as shown in
7591
this [example](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/fastapi-response-streaming).
7692

7793
### Step 1: Set up your API Key
@@ -107,34 +123,28 @@ this [example](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examp
107123
- ECR repository name (or use default: `swift-chat-api`)
108124
- Image tag (please use default: `latest`)
109125
- AWS region (the region you want to deploy, e.g.,: `us-east-1`)
110-
- Deployment type:
111-
- Option 1 (default): **AppRunner** - uses amd64 architecture
112-
- Option 2: **Lambda** - uses arm64 architecture
113126

114127
4. The script will build and push the Docker image to your ECR repository.
115128

116129
5. **Important**: Copy the image URI displayed at the end of the script output. You'll need this in the next step.
117130

118131
### Step 3: Deploy stack and get your API URL
119132

120-
1. Download the CloudFormation template you want to use:
121-
- For App Runner: [SwiftChatAppRunner.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatAppRunner.template)
122-
- For Lambda: [SwiftChatLambda.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatLambda.template)
133+
1. Download the CloudFormation template:
134+
- Lambda: [SwiftChatLambda.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatLambda.template)
123135

124136
2. Go to [CloudFormation Console](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatAPI) and select **Upload a template file** under **Specify template**, then upload the template file you downloaded. (Make sure you are in the same region where your API Key was created.)
125137

126138
3. Click **Next**, On the "Specify stack details" page, provide the following information:
127-
- **Stack name**: Keep the default "SwiftChatAPI" or change if needed
128139
- **ApiKeyParam**: Enter the parameter name you used for storing the API key (e.g., "SwiftChatAPIKey")
129140
- **ContainerImageUri**: Enter the ECR image URI from Step 2 output
130-
- For App Runner, choose an **InstanceTypeParam** based on your needs
131141

132142
4. Click **Next**, Keep the "Configure stack options" page as default, Read the Capabilities and Check the "I
133143
acknowledge that AWS CloudFormation might create IAM resources" checkbox at the bottom.
134144
5. Click **Next**, In the "Review and create" Review your configuration and click **Submit**.
135145

136146
Wait about 3–5 minutes for the deployment to finish, then click the CloudFormation stack and go to **Outputs** tab, you
137-
can find the **API URL** which looks like: `https://xxx.xxx.awsapprunner.com` or `https://xxx.lambda-url.xxx.on.aws`
147+
can find the **API URL** which looks like: `https://xxx.execute-api.us-east-1.amazonaws.com/v1`
138148

139149
### Step 4: Open the App and setup with API URL and API Key
140150

@@ -258,20 +268,20 @@ can enable the **Use Proxy** option to forward your requests.
258268
<img src="assets/animations/video_summary.avif" width=24%>
259269
</div>
260270

261-
**Creative Image Suite**: Generation, Virtual try-on, Style Replication, Background Removal with Nova Canvas
271+
**Creative Image Suite**: Generation, Virtual try-on, Background Removal and Image Gallery with Nova Canvas
262272

263273
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
264274
<img src="assets/animations/gen_image.avif" width=24%>
265275
<img src="assets/animations/virtual_try_on_demo.avif" width=24%>
266-
<img src="assets/animations/similar_style.avif" width=24%>
267276
<img src="assets/animations/remove_background.avif" width=24%>
277+
<img src="assets/animations/image_gallery.avif" width=24%>
268278
</div>
269279

270280
**System Prompt Assistant**: Useful Preset System Prompts with Full Management Capabilities (Add/Edit/Sort/Delete)
271281

272282
![](assets/animations/english_teacher.avif)
273283

274-
**Rich Markdown Support**: Paragraph, Code Blocks, Tables, LaTeX and More
284+
**Rich Markdown Support**: Paragraph, Code Blocks, Tables, LaTeX, Mermaid and More
275285

276286
![](assets/markdown.avif)
277287

@@ -358,6 +368,7 @@ We feature streamlined chat History, Settings pages, and intuitive Usage statist
358368
- [x] Support image generation with Chinese prompts (Make sure `Amazon Nova Lite` is enabled in your selected region)
359369
- [x] Long press images to save or share
360370
- [x] Automatic image compression to improve response speed
371+
- [x] Image Gallery for browsing and managing all generated images
361372

362373
### User Experience
363374

@@ -464,10 +475,14 @@ the [release notes](https://github.com/aws-samples/swift-chat/releases) to see i
464475

465476
### Upgrade API
466477

467-
- **For AppRunner**: Click and open [App Runner Services](https://console.aws.amazon.com/apprunner/home#/services) page,
468-
find and open `swiftchat-api`, click top right **Deploy** button.
469-
- **For Lambda**: Click and open [Lambda Services](https://console.aws.amazon.com/lambda/home#/functions), find and open
470-
your Lambda which start with `SwiftChatLambda-xxx`, click the **Deploy new image** button and click Save.
478+
1. First, re-run the build script to update the image:
479+
```bash
480+
cd server/scripts
481+
bash ./push-to-ecr.sh
482+
```
483+
484+
2. Click and open [Lambda Services](https://console.aws.amazon.com/lambda/home#/functions), find and open
485+
your Lambda which starts with `SwiftChatAPILambda-xxx`, click the **Deploy new image** button and click Save.
471486

472487
## Security
473488

README_CN.md

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,41 @@ SwiftChat 是一款快速响应的 AI 聊天应用,采用 [React Native](https
1515
![](assets/promo.avif)
1616

1717
### 新功能 🔥
18-
18+
- 🚀 支持创建应用,创建、编辑和分享极速 Web 应用(自 v2.7.0 起)。
19+
- 🚀 支持网络搜索,获取实时信息(自 v2.7.0 起)。
20+
- 🚀 更新 SwiftChat 服务器,支持 API Gateway + Lambda 部署,最长支持 15 分钟流式输出(自 v2.7.0 起)。
21+
- 🚀 支持图片画廊,浏览和管理生成的图片(自 v2.7.0 起)。
1922
- 🚀 支持流式渲染 Mermaid 图表(自 v2.6.0 起)。
20-
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
21-
<img src="assets/animations/mermaid.avif" width=48%>
22-
<img src="assets/animations/mermaid_save.avif" width=48%>
23-
</div>
2423
- 🚀 支持使用 Bedrock API Key 连接 Amazon Bedrock 模型(自 v2.5.0 起)。
25-
- 🚀 支持虚拟试衣功能,自动识别衣服、裤子、鞋子并试穿(自 v2.5.0 起)。
26-
- 🚀 支持 macOS 快捷键操作(自 v2.5.0 起)。
27-
- 使用 `Shift + Enter``Control + Enter``Option + Enter` 添加换行。
28-
- 使用 `⌘ + V` 从剪贴板添加图片(截图)、视频或文档。
29-
- 使用 `⌘ + N` 打开多个 Mac 窗口进行并行操作。
24+
25+
**创建应用**:生成、编辑、分享和预览极速 Web 应用
26+
27+
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
28+
<img src="assets/animations/create_app.avif" width=24%>
29+
<img src="assets/animations/edit_and_save.avif" width=24%>
30+
<img src="assets/animations/gallery_edit_app.avif" width=24%>
31+
<img src="assets/animations/share_and_import.avif" width=24%>
32+
</div>
33+
34+
**应用示例**:2048 游戏、五子棋、新闻阅读器和俄罗斯方块
35+
36+
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
37+
<img src="assets/animations/app_2048.avif" width=24%>
38+
<img src="assets/animations/app_gomoku.avif" width=24%>
39+
<img src="assets/animations/app_news.avif" width=24%>
40+
<img src="assets/animations/app_tetris.avif" width=24%>
41+
</div>
42+
43+
**网络搜索 & Mermaid**:实时信息检索和流式图表渲染
44+
45+
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
46+
<img src="assets/animations/websearch_tavily.avif" width=24%>
47+
<img src="assets/animations/websearch_google.avif" width=24%>
48+
<img src="assets/animations/mermaid.avif" width=24%>
49+
<img src="assets/animations/mermaid_save.avif" width=24%>
50+
</div>
51+
52+
> 注意:推荐使用 Tavily 以获得最佳效果。Google 搜索首次使用需要手动验证。百度和必应目前处于测试版本,搜索结果可能不准确。
3053
3154
## 📱 快速下载
3255

@@ -36,10 +59,6 @@ SwiftChat 是一款快速响应的 AI 聊天应用,采用 [React Native](https
3659

3760
## Amazon Bedrock 入门指南
3861

39-
### 前置条件
40-
41-
点击 [Amazon Bedrock 模型访问](https://console.aws.amazon.com/bedrock/home#/modelaccess) 启用您的模型访问权限。
42-
4362
### 配置
4463

4564
您可以选择以下两种配置方法中的一种
@@ -58,14 +77,13 @@ SwiftChat 是一款快速响应的 AI 聊天应用,采用 [React Native](https
5877
<details>
5978
<summary><b>🔧 配置 SwiftChat 服务器(点击展开)</b></summary>
6079

61-
### 架构
80+
> **注意**:自 v2.7.0 起,我们建议重新部署 SwiftChat 服务器以获得更好的性能,支持 API Gateway + Lambda 实现最长 15 分钟的流式输出。您之前创建的 API Key 可以复用 - 只需在应用中更新服务器 URL 即可。
6281
63-
![](/assets/architecture.avif)
82+
### 架构
6483

65-
默认情况下,我们使用 **AWS App Runner**,它通常用于托管 Python FastAPI 服务器,提供高性能、可扩展性和低延迟。
84+
![](/assets/architecture.png)
6685

67-
或者,我们提供用 **AWS Lambda** 使用 Function URL 替代 App Runner
68-
的选项,以获得更具成本效益的解决方案,如此 [示例](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/fastapi-response-streaming)
86+
我们提供用 **API Gateway****AWS Lambda** 结合的方式,实现最长15分钟的流式传输,如此 [示例](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examples/fastapi-response-streaming)
6987
所示。
7088

7189
### 步骤 1:设置您的 API 密钥
@@ -100,32 +118,26 @@ SwiftChat 是一款快速响应的 AI 聊天应用,采用 [React Native](https
100118
- ECR 仓库名称(或使用默认值:`swift-chat-api`
101119
- 镜像标签(请使用默认值:`latest`
102120
- AWS 区域(填写你希望部署的区域,例如:`us-east-1`
103-
- 部署类型:
104-
- 选项 1(默认):**AppRunner** - 使用 amd64 架构
105-
- 选项 2:**Lambda** - 使用 arm64 架构
106121

107122
4. 脚本将构建并推送 Docker 镜像到您的 ECR 仓库。
108123

109124
5. **重要**:复制脚本输出末尾显示的镜像 URI。您将在下一步中需要它。
110125

111126
### 步骤 3:部署堆栈并获取 API URL
112127

113-
1. 下载您想使用的 CloudFormation 模板:
114-
- App Runner:[SwiftChatAppRunner.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatAppRunner.template)
128+
1. 下载 CloudFormation 模板:
115129
- Lambda:[SwiftChatLambda.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatLambda.template)
116130

117131
2. 前往 [CloudFormation 控制台](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatAPI),在**指定模板**下选择**上传模板文件**,然后上传您下载的模板文件。(确保您所在的区域与创建 API Key 的区域相同。)
118132

119133
3. 点击 **下一步**,在"指定堆栈详细信息"页面,提供以下信息:
120-
- **Stack name**:保持默认的 "SwiftChatAPI" 或根据需要更改
121134
- **ApiKeyParam**:输入您用于存储 API 密钥的参数名称(例如 "SwiftChatAPIKey")
122135
- **ContainerImageUri**:输入步骤 2 输出的 ECR 镜像 URI
123-
- 对于 App Runner,根据您的需求选择 **InstanceTypeParam**
124136

125137
4. 点击 **下一步**,保持"配置堆栈选项"页面为默认,阅读功能并勾选底部的"我确认 AWS CloudFormation 可能会创建 IAM 资源"复选框。
126138
5. 点击 **下一步**,在"审核并创建"中检查您的配置并点击 **提交**
127139

128-
等待约 3-5 分钟完成部署,然后点击 CloudFormation 堆栈并转到 **输出** 选项卡,您可以找到 **API URL**,类似于:`https://xxx.xxx.awsapprunner.com``https://xxx.lambda-url.xxx.on.aws`
140+
等待约 3-5 分钟完成部署,然后点击 CloudFormation 堆栈并转到 **输出** 选项卡,您可以找到 **API URL**,类似于:`https://xxx.execute-api.us-east-1.amazonaws.com/v1`
129141

130142
### 步骤 4:打开应用并使用 API URL 和 API Key 进行设置
131143

@@ -245,20 +257,20 @@ SwiftChat 是一款快速响应的 AI 聊天应用,采用 [React Native](https
245257
<img src="assets/animations/video_summary.avif" width=24%>
246258
</div>
247259

248-
**创意图像套件**:生成、虚拟试衣、风格复制、背景移除,由 Nova Canvas 提供支持
260+
**创意图像套件**:生成、虚拟试衣、背景移除和图片画廊,由 Nova Canvas 提供支持
249261

250262
<div style="display: flex; flex-direction: 'row'; background-color: #888888;">
251263
<img src="assets/animations/gen_image.avif" width=24%>
252-
<img src="assets/animations/virtual_try_on.avif" width=24%>
253-
<img src="assets/animations/similar_style.avif" width=24%>
264+
<img src="assets/animations/virtual_try_on_demo.avif" width=24%>
254265
<img src="assets/animations/remove_background.avif" width=24%>
266+
<img src="assets/animations/image_gallery.avif" width=24%>
255267
</div>
256268

257269
**系统提示词助手**:有用的预设系统提示词,具备完整管理功能(添加/编辑/排序/删除)
258270

259271
![](assets/animations/english_teacher.avif)
260272

261-
**丰富的 Markdown 支持**:段落、代码块、表格、LaTeX 等
273+
**丰富的 Markdown 支持**:段落、代码块、表格、LaTeX、Mermaid
262274

263275
![](assets/markdown.avif)
264276

@@ -341,6 +353,7 @@ https://github.com/user-attachments/assets/c70fc2b4-8960-4a5e-b4f8-420fcd5eafd4
341353
- [x] 支持使用中文提示生成图像(确保在您选择的区域启用了 `Amazon Nova Lite`
342354
- [x] 长按图像保存或分享
343355
- [x] 自动图像压缩以提高响应速度
356+
- [x] 图片画廊,浏览和管理所有生成的图片
344357

345358
### 用户体验
346359

@@ -441,10 +454,14 @@ npm run ios
441454

442455
### 升级 API
443456

444-
- **对于 AppRunner**:点击打开 [App Runner 服务](https://console.aws.amazon.com/apprunner/home#/services) 页面,找到并打开
445-
`swiftchat-api`,点击右上角 **部署** 按钮。
446-
- **对于 Lambda**:点击打开 [Lambda 服务](https://console.aws.amazon.com/lambda/home#/functions) 页面,找到并打开以
447-
`SwiftChatLambda-xxx` 开头的 Lambda,点击 **部署新镜像** 按钮并点击保存。
457+
1. 首先重新运行构建脚本以更新镜像:
458+
```bash
459+
cd server/scripts
460+
bash ./push-to-ecr.sh
461+
```
462+
463+
2. 点击打开 [Lambda 服务](https://console.aws.amazon.com/lambda/home#/functions) 页面,找到并打开以
464+
`SwiftChatAPILambda-xxx` 开头的 Lambda,点击 **部署新镜像** 按钮并点击保存。
448465

449466
## 安全
450467

assets/animations/app_2048.avif

180 KB
Binary file not shown.

assets/animations/app_gomoku.avif

156 KB
Binary file not shown.

assets/animations/app_news.avif

329 KB
Binary file not shown.

assets/animations/app_tetris.avif

109 KB
Binary file not shown.

assets/animations/create_app.avif

337 KB
Binary file not shown.
341 KB
Binary file not shown.
228 KB
Binary file not shown.

0 commit comments

Comments
 (0)