Skip to content

Commit 156da8c

Browse files
authored
feat: support LaTeX (#9)
1 parent 9eb3d46 commit 156da8c

23 files changed

+733
-279
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release Next Version
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
release_tag:
6+
description: 'Release Version'
7+
required: true
8+
type: string
9+
release_code:
10+
description: 'Release Version Code'
11+
required: true
12+
type: string
13+
env:
14+
NEW_VERSION: ${{ github.event.inputs.release_tag }}
15+
NEW_VERSION_CODE: ${{ github.event.inputs.release_code }}
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: main
23+
fetch-depth: 0
24+
token: ${{ secrets.PROJECT_TOKEN }}
25+
- uses: actions/setup-java@v4
26+
with:
27+
distribution: 'corretto'
28+
java-version: '17'
29+
- name: Modify for next release
30+
run: |
31+
cd react-native
32+
chmod +x release.sh
33+
./release.sh ${{ env.NEW_VERSION }} ${{ env.NEW_VERSION_CODE }}
34+
npm i
35+
cd ..
36+
git diff
37+
git add .
38+
git config user.name '${{ vars.USER_NAME }}'
39+
git config user.email '${{ vars.USER_EMAIL }}'
40+
git commit -m 'release: SwiftChat v${{ env.NEW_VERSION }}'
41+
git push
42+
git tag ${{ env.NEW_VERSION }}
43+
git push origin ${{ env.NEW_VERSION }}
44+
- name: Prepare release file
45+
run: |
46+
cd react-native/android
47+
./gradlew assembleRelease
48+
- name: Create GitHub release
49+
uses: softprops/action-gh-release@v2
50+
with:
51+
name: "SwiftChat v${{ env.NEW_VERSION }}"
52+
files: |
53+
react-native/android/app/build/outputs/apk/release/*.apk
54+
tag_name: "${{ env.NEW_VERSION }}"
55+
prerelease: true
56+
generate_release_notes: true

README.md

Lines changed: 46 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ macOS platforms.
1212
**Key Features:**
1313

1414
- Real-time streaming chat with AI
15+
- Rich Markdown Support: Tables, Code Blocks, LaTeX and More
1516
- AI image generation with progress
1617
- Multimodal support (images, videos & documents)
1718
- Conversation history list view and management
@@ -28,6 +29,14 @@ macOS platforms.
2829
- Upload large videos (1080p/4K) beyond 8MB with auto compression
2930
- Support using natural language to make Nova Canvas generate images, remove backgrounds, replace backgrounds, and
3031
create images in similar styles.
32+
- Support LaTeX formula rendering for Amazon Nova.
33+
34+
The image below demonstrates SwiftChat rich markdown content support. We redesigned the UI with optimized font sizes and
35+
line spacing for a more elegant and clean presentation.
36+
37+
![](assets/markdown.png)
38+
39+
All of these features are seamlessly displayed across all supported platforms with native UI.
3140

3241
## Architecture
3342

@@ -47,11 +56,12 @@ this [example](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examp
4756

4857
Ensure you have access to Amazon Bedrock foundation models. SwiftChat default settings are:
4958

50-
* Region: `us-west-2`
51-
* Text Model: `Claude 3.5 Sonnet`
52-
* Image Model: `Stable Image Core 1.0`
59+
- Region: `us-west-2`
60+
- Text Model: `Amazon Nova Pro`
61+
- Image Model: `Stable Image Core 1.0`
5362

54-
Follow the [Amazon Bedrock User Guide](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access-modify.html) to
63+
If you are using the image generation feature, please make sure you have enabled access to the `Amazon Nova Lite` model.
64+
Please follow the [Amazon Bedrock User Guide](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access-modify.html) to
5565
enable your models.
5666

5767
### Step 1: Set up your API Key
@@ -61,29 +71,30 @@ enable your models.
6171
2. Check whether you are in the [supported region](#supported-region), then click on the **Create parameter** button.
6272
3. Fill in the parameters below, leaving other options as default:
6373

64-
* **Name**: Enter a parameter name (e.g., "SwiftChatAPIKey", will be used as `ApiKeyParam` in Step 2).
74+
- **Name**: Enter a parameter name (e.g., "SwiftChatAPIKey", will be used as `ApiKeyParam` in Step 2).
6575

66-
* **Type**: Select `SecureString`
76+
- **Type**: Select `SecureString`
6777

68-
* **Value**: Enter any string without spaces.(this will be your `API Key` in Step 3)
78+
- **Value**: Enter any string without spaces.(this will be your `API Key` in Step 3)
6979

7080
4. Click **Create parameter**.
7181

7282
### Step 2: Deploy stack and get your API URL
7383

7484
1. Click one of the following buttons to launch the CloudFormation Stack in the same region where your API Key was
7585
created.
76-
- **App Runner**
7786

78-
[![Launch Stack](assets/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatAPI&templateURL=https://aws-gcr-solutions.s3.amazonaws.com/swift-chat/latest/SwiftChatAppRunner.template)
87+
- **App Runner**
88+
89+
[![Launch Stack](assets/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatAPI&templateURL=https://aws-gcr-solutions.s3.amazonaws.com/swift-chat/latest/SwiftChatAppRunner.template)
7990

80-
- **Lambda** (Note: For AWS customer use only)
91+
- **Lambda** (Note: For AWS customer use only)
8192

82-
[![Launch Stack](assets/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatLambda&templateURL=https://aws-gcr-solutions.s3.amazonaws.com/swift-chat/latest/SwiftChatLambda.template)
93+
[![Launch Stack](assets/launch-stack.png)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatLambda&templateURL=https://aws-gcr-solutions.s3.amazonaws.com/swift-chat/latest/SwiftChatLambda.template)
8394

8495
2. Click **Next**, On the "Specify stack details" page, provide the following information:
85-
- Fill the `ApiKeyParam` with the parameter name you used for storing the API key (e.g., "SwiftChatAPIKey").
86-
- For App Runner, choose an `InstanceTypeParam` based on your needs.
96+
- Fill the `ApiKeyParam` with the parameter name you used for storing the API key (e.g., "SwiftChatAPIKey").
97+
- For App Runner, choose an `InstanceTypeParam` based on your needs.
8798
3. Click **Next**, Keep the "Configure stack options" page as default, Read the Capabilities and Check the "I
8899
acknowledge that AWS CloudFormation might create IAM resources" checkbox at the bottom.
89100
4. Click **Next**, In the "Review and create" Review your configuration and click **Submit**.
@@ -94,9 +105,10 @@ can find the **API URL** which looks like: `https://xxx.xxx.awsapprunner.com` or
94105
### Step 3: Download the app and setup with API URL and API Key
95106

96107
1. Download the App
97-
- Android App click to [Download](https://github.com/aws-samples/swift-chat/releases/download/1.7.0/SwiftChat.apk)
98-
- macOS App click to [Download](https://github.com/aws-samples/swift-chat/releases/download/1.7.0/SwiftChat.dmg)
99-
- iOS (Currently we do not provide the iOS version, you can build it locally with Xcode)
108+
109+
- Android App click to [Download](https://github.com/aws-samples/swift-chat/releases/download/1.7.0/SwiftChat.apk)
110+
- macOS App click to [Download](https://github.com/aws-samples/swift-chat/releases/download/1.7.0/SwiftChat.dmg)
111+
- iOS (Currently we do not provide the iOS version, you can build it locally with Xcode)
100112

101113
2. Launch the App, open the drawer menu, and tap **Settings**.
102114
3. Paste the `API URL` and `API Key` then select the Region.
@@ -120,27 +132,30 @@ Congratulations 🎉 Your SwiftChat App is ready to use!
120132

121133
## Detailed Features
122134

135+
We feature streamlined chat History, Settings pages, and intuitive Usage statistics:
136+
137+
![](assets/history_settings.png)
138+
123139
### Message Handling
124140

125141
- [x] Text copy support:
126-
* Copy button in message header
127-
* Copy button in code blocks
128-
* Direct Select and copy code on macOS (double click or long click on iOS)
129-
* Long press text to copy entire sentence (Right-click on macOS)
142+
- Copy button in message header
143+
- Copy button in code blocks
144+
- Direct Select and copy code on macOS (double click or long click on iOS)
145+
- Long press text to copy entire sentence (Right-click on macOS)
130146
- [x] Text selection mode by tapping message title or double-clicking text
131147
- [x] Message timeline view in history
132148
- [x] Delete messages through long press in history
133149
- [x] Click to preview for uploaded documents and images
134150
- [x] Support Markdown format for both questions and answers
135-
- [x] Support table display and code syntax highlighting
136151
- [x] Maximum 20 images and 5 documents per conversation
137152

138153
### Image Features
139154

140-
- [x] Support image generation with Chinese prompts(Make sure `Claude 3 Haiku` is enabled in your selected region)
155+
- [x] Support image generation with Chinese prompts(Make sure `Amazon Nova Lite` is enabled in your selected region)
141156
- [x] View and zoom generated images
142157
- [x] Long press images to save or share
143-
- [x] Automatic image compression to optimize token usage
158+
- [x] Automatic image compression to improve response speed
144159

145160
### User Experience
146161

@@ -152,6 +167,12 @@ Congratulations 🎉 Your SwiftChat App is ready to use!
152167
- [x] Check detailed token usage and image generation count in Settings
153168
- [x] In-app upgrade notifications (Android & macOS)
154169

170+
We have optimized the layout for landscape mode. As shown below, you can comfortably view table and code contents in
171+
landscape orientation.
172+
173+
![](assets/landscape.png)
174+
![](assets/landscape_code.png)
175+
155176
## What Makes SwiftChat Really "Swift"?
156177

157178
🚀 **Fast Launch Speed**
@@ -193,7 +214,7 @@ following command to download dependencies.
193214

194215
```bash
195216
cd react-native && npm i
196-
```
217+
```
197218

198219
### Build for Android
199220

@@ -215,83 +236,7 @@ npm start && npm run ios
215236

216237
## API Reference
217238

218-
### API Schema
219-
220-
First, please configure you `API URL` and `API Key` like:
221-
222-
```bash
223-
export API_URL=<API URL>
224-
export API_KEY=<API Key>
225-
```
226-
227-
1. `/api/converse`
228-
```bash
229-
curl -N "${API_URL}/api/converse" \
230-
--header 'Content-Type: application/json' \
231-
--header "Authorization: Bearer ${API_KEY}" \
232-
--data '{
233-
"messages": [
234-
{
235-
"role": "user",
236-
"content": [
237-
{
238-
"text": "Hi"
239-
}
240-
]
241-
}
242-
],
243-
"modelId": "anthropic.claude-3-5-sonnet-20240620-v1:0",
244-
"region": "us-west-2"
245-
}'
246-
```
247-
This API is used to implement streaming conversations, and it only returns the text and token usage for display.
248-
249-
The `messages` under body fully complies with the messages structure specification in Amazon
250-
Bedrock [converse stream](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime/client/converse_stream.html)
251-
API. You can also add `image` or `document` according to the specification to support multimodal conversations.
252-
253-
2. `/api/image`
254-
```bash
255-
curl "${API_URL}/api/image" \
256-
--header 'Content-Type: application/json' \
257-
--header "Authorization: Bearer ${API_KEY}" \
258-
--data '{
259-
"prompt": "Beautiful countryside",
260-
"modelId": "stability.stable-image-core-v1:0",
261-
"region": "us-west-2",
262-
"width": "1024",
263-
"height": "1024"
264-
}'
265-
```
266-
This API is used to generate images and returns a base64 encoded string of the image.
267-
268-
3. `/api/models`
269-
```bash
270-
curl "${API_URL}/api/models" \
271-
--header 'Content-Type: application/json' \
272-
--header 'accept: application/json' \
273-
--header "Authorization: Bearer ${API_KEY}" \
274-
--data '{
275-
"region": "us-west-2"
276-
}'
277-
```
278-
This API is used to get a list of all streaming-supported text models and image generation models in the specified
279-
region.
280-
281-
4. `/api/upgrade`
282-
```bash
283-
curl "${API_URL}/api/upgrade" \
284-
--header 'Content-Type: application/json' \
285-
--header 'accept: application/json' \
286-
--header "Authorization: Bearer ${API_KEY}"
287-
```
288-
This API is used to get the new version of SwiftChat for Android and macOS App updates.
289-
290-
### API Code Reference
291-
292-
- Client code: [bedrock-api.ts](/react-native/src/api/bedrock-api.ts)
293-
294-
- Server code: [main.py](server/src/main.py)
239+
Please refer [API Reference](server/README.md)
295240

296241
## How to upgrade?
297242

@@ -319,4 +264,3 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform
319264
## License
320265

321266
This library is licensed under the MIT-0 License. See the [LICENSE](LICENSE) file.
322-

0 commit comments

Comments
 (0)