Skip to content

Commit 663868e

Browse files
Update README.md
1 parent a57c2ac commit 663868e

File tree

1 file changed

+80
-13
lines changed

1 file changed

+80
-13
lines changed

README.md

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@
2222
**🚨 Due to current server resource constraints, DeepSeek temporarily suspended API service recharges to prevent any potential impact on users operations.
2323
Existing balances can still be used for calls.**
2424

25-
## 🍳 Overview
25+
## Overview
2626

2727
DeepSeek Swift SDK is a lightweight and efficient Swift-based client for interacting with the DeepSeek API. It provides support for chat message completion, streaming, error handling, and configurating DeepSeek LLM with advanced parameters.
2828

29-
## Features
29+
## Features
3030

31-
- **Chat Completion Support**: Easily send and process chat-based AI requests.
32-
- **Smart Error Handling**: Provides detailed error descriptions along with actionable solutions.
33-
- **Streaming Responses**: Supports real-time AI-generated content streaming.
34-
- **Multi-Model Compatibility**: Works seamlessly with various DeepSeek models and advanced configurations.
35-
- **Swift Concurrency Optimized**: Leverages `async/await` for efficient and modern networking.
31+
- Supports **chat completion** requests
32+
- Handles **error responses** with detailed error descriptions and solving advices.
33+
- **streaming responses**
34+
- Built-in support for **different models and advanced parameters**
35+
- Uses **Swift concurrency (async/await)** for network calls
3636

37-
## 📦 Installation
37+
## Installation
3838

3939
To integrate `DeepSwiftSeek` into your project, you can use **Swift Package Manager (SPM)**:
4040

@@ -52,7 +52,7 @@ Or add it via Xcode:
5252
3. Enter the repository URL.
5353
4. Choose the latest version and click **Next**.
5454

55-
## 🔧 Usage
55+
## Usage
5656

5757
### 1. Initialize the Client
5858

@@ -103,7 +103,75 @@ Task {
103103
}
104104
```
105105

106-
### 4. Handling Errors
106+
### 4. Streaming FIM Completion
107+
```swift
108+
Task {
109+
do {
110+
let stream = try await deepSeekClient.fimCompletionStream(
111+
messages: {
112+
[
113+
ChatMessageRequest(
114+
role: .user,
115+
content: "function greet() {\n /* FIM_START */\n /* FIM_END */\n return 'Hello world';\n}",
116+
name: "User"
117+
)
118+
]
119+
},
120+
model: .deepSeekReasoner,
121+
parameters: .streaming
122+
)
123+
124+
for try await chunk in stream {
125+
// Each chunk is a streamed part of the fill-in-the-middle response.
126+
print("FIM Stream Chunk:\n\(chunk)")
127+
}
128+
} catch {
129+
print("FIM Streaming Error: \(error.localizedDescription)")
130+
}
131+
}
132+
```
133+
134+
### 5. Sending FIM Completion Request
135+
```swift
136+
Task {
137+
do {
138+
let response = try await deepSeekClient.fimCompletions(
139+
messages: {
140+
[
141+
ChatMessageRequest(
142+
role: .user,
143+
content: "function greet() {\n // FIM_START\n // FIM_END\n return 'Hello world';\n}",
144+
name: "User"
145+
)
146+
]
147+
},
148+
model: .deepSeekReasoner,
149+
parameters: .creative
150+
)
151+
if let content = response.choices.first?.message.content {
152+
print("FIM Completion:\n\(content)")
153+
}
154+
} catch {
155+
print("FIM Error: \(error.localizedDescription)")
156+
}
157+
}
158+
159+
```
160+
161+
### 6. Getting List of Models
162+
```swift
163+
Task {
164+
do {
165+
let response = try await deepSeekClient.listModels()
166+
} catch {
167+
print("ListModels Error: \(error.localizedDescription)")
168+
}
169+
}
170+
171+
```
172+
173+
174+
### 7. Handling Errors
107175

108176
The SDK provides detailed error handling:
109177

@@ -188,16 +256,15 @@ DeepSeek SDK has built-in error handling for various API failures:
188256
| `serverOverloaded` | High traffic on server. |
189257
| `encodingError` | Failed to encode request body. |
190258

191-
## 📌 TODOs
259+
## TODOs
192260

193261
- [ ] Improve documentation with more examples
194262
- [ ] SwiftUI full demo based on chat, history and reasoning
195263
- [ ] Reasoning model + OpenAI SDK
196264

197-
## 🪪 License
265+
## License
198266

199267
This project is available under the MIT License.
200268

201269
### Disclaimer
202270
This SDK is **not affiliated** with DeepSeek and is an independent implementation to interact with their API.
203-

0 commit comments

Comments
 (0)