Skip to content

Commit 4dc67cc

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents cc132aa + f5cb942 commit 4dc67cc

26 files changed

+1307
-184
lines changed

MyApp/Pages/Index.cshtml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,26 @@
110110
</div>
111111

112112
<div class="text-center sm:col-span-6">
113-
<a href="https://servicestack.net/creatorkit/">
113+
<a href="/ai-server/">
114114
<div class="text-center">
115-
<svg class="w-20 h-20 inline-block text-indigo-600" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M13 23V13h10v10H13Zm1.5-1.5h7v-.8q-.625-.775-1.525-1.238T18 19q-1.075 0-1.975.463T14.5 20.7v.8ZM18 18q.625 0 1.063-.438T19.5 16.5q0-.625-.438-1.063T18 15q-.625 0-1.063.438T16.5 16.5q0 .625.438 1.063T18 18Zm-8.75 4l-.4-3.2q-.325-.125-.613-.3t-.562-.375L4.7 19.375l-2.75-4.75l2.575-1.95Q4.5 12.5 4.5 12.337v-.674q0-.163.025-.338L1.95 9.375l2.75-4.75l2.975 1.25q.275-.2.575-.375t.6-.3l.4-3.2h5.5l.4 3.2q.325.125.613.3t.562.375l2.975-1.25l2.75 4.75L19.925 11H15.4q-.35-1.075-1.25-1.788t-2.1-.712q-1.45 0-2.475 1.025T8.55 12q0 1.2.675 2.1T11 15.35V22H9.25Z"></path></svg>
115+
<svg class="w-20 h-20 inline-block text-indigo-600" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M17.478 8h.022a4.5 4.5 0 0 1 2.5 8.242M17.478 8q.021-.247.022-.5a5.5 5.5 0 0 0-10.98-.477M17.478 8a5.5 5.5 0 0 1-.578 2M6.52 7.023a5 5 0 0 0-2.168 9.22m2.168-9.22Q6.757 7 7 7c1.126 0 2.165.372 3 1m3 6h-2c-.943 0-1.414 0-1.707.293S9 15.057 9 16v2c0 .943 0 1.414.293 1.707S10.057 20 11 20h2c.943 0 1.414 0 1.707-.293S15 18.943 15 18v-2c0-.943 0-1.414-.293-1.707S13.943 14 13 14m-2.5 6v2m3-2v2m-3-10v2m3-2v2M9 15.5H7m2 3H7m10-3h-2m2 3h-2" color="currentColor"/></svg>
116116
</div>
117-
<h3 class="text-lg font-semibold leading-7 text-gray-900 dark:text-gray-50">Creator Kit</h3>
117+
<h3 class="text-lg font-semibold leading-7 text-gray-900 dark:text-gray-50">AI Server</h3>
118118
</a>
119119
<p class="text-base leading-7 text-gray-600 dark:text-gray-300">
120-
Add Mailchimp and Disqus features to any website
120+
Unified APIs for LLM APIs, Ollama, ComfyUI & FFmpeg
121121
</p>
122122
</div>
123123

124124
<div class="text-center sm:col-span-6">
125-
<a href="https://razor-press.web-templates.io">
125+
<a href="https://servicestack.net/creatorkit/">
126126
<div class="text-center">
127-
<svg class="w-20 h-20 inline-block text-indigo-600" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0M3 6v13m9-13v13m9-13v13"></path></svg>
127+
<svg class="w-20 h-20 inline-block text-indigo-600" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M13 23V13h10v10H13Zm1.5-1.5h7v-.8q-.625-.775-1.525-1.238T18 19q-1.075 0-1.975.463T14.5 20.7v.8ZM18 18q.625 0 1.063-.438T19.5 16.5q0-.625-.438-1.063T18 15q-.625 0-1.063.438T16.5 16.5q0 .625.438 1.063T18 18Zm-8.75 4l-.4-3.2q-.325-.125-.613-.3t-.562-.375L4.7 19.375l-2.75-4.75l2.575-1.95Q4.5 12.5 4.5 12.337v-.674q0-.163.025-.338L1.95 9.375l2.75-4.75l2.975 1.25q.275-.2.575-.375t.6-.3l.4-3.2h5.5l.4 3.2q.325.125.613.3t.562.375l2.975-1.25l2.75 4.75L19.925 11H15.4q-.35-1.075-1.25-1.788t-2.1-.712q-1.45 0-2.475 1.025T8.55 12q0 1.2.675 2.1T11 15.35V22H9.25Z"></path></svg>
128128
</div>
129-
<h3 class="text-lg font-semibold leading-7 text-gray-900 dark:text-gray-50">Razor Press</h3>
129+
<h3 class="text-lg font-semibold leading-7 text-gray-900 dark:text-gray-50">Creator Kit</h3>
130130
</a>
131131
<p class="text-base leading-7 text-gray-600 dark:text-gray-300">
132-
Static Site Generator for fast Documentation
132+
Add Mailchimp and Disqus features to any website
133133
</p>
134134
</div>
135135

MyApp/Pages/Shared/Header.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
("/ormlite/", "OrmLite"),
99
("/redis/", "Redis"),
1010
("/locode/", "Locode"),
11-
("/grpc/", "gRPC")
11+
("/grpc/", "gRPC"),
12+
("/ai-server/", "AI Server")
1213
};
1314
}
1415
<header id="header" class="top-0 fixed z-50 h-14 bg-white dark:bg-black opacity-90 w-full shadow">

MyApp/_includes/npx-get-dtos.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Alternative (without .NET): npx get-dtos
2+
3+
Alternatively API consumers can use [npx get-dtos](/npx-get-dtos) to Add/Update ServiceStack References without needing .NET installed, where any command starting with:
4+
5+
```txt
6+
x <lang>
7+
```
8+
9+
Can be replaced with:
10+
11+
```txt
12+
npx get-dtos <lang>
13+
```
14+
15+
To instead Add / Update ServiceStack references using the npm get-dtos package.

MyApp/_pages/add-servicestack-reference.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ The [x dotnet tool](/dotnet-tool) provides simple command-line utilities to easi
140140
dotnet tool install --global x
141141
:::
142142

143+
::include npx-get-dtos.md::
144+
143145
This will make the following utilities available from your command-line which will let you download the Server DTO classes for a remote ServiceStack endpoint in your chosen language which you can use with ServiceStack's generic Service clients to be able to make end-to-end API calls.
144146

145147
<table class="table table-bordered">
@@ -390,6 +392,119 @@ in the right-click context menu:
390392

391393
If you're updating references frequently you can save time by [assigning it a keyboard shortcut](https://www.jetbrains.com/help/rider/Configuring_Keyboard_and_Mouse_Shortcuts.html).
392394

395+
396+
## Multiple File Upload Support with API Requests supported in all languages
397+
398+
To be able to call [AI Server](/ai-server/) APIs requiring file uploads we've added multiple file upload support with API Requests to the generic service clients for all our supported languages.
399+
400+
Here's what that looks like for different languages calling AI Server's `SpeechToText` API:
401+
402+
### C# Speech to Text
403+
404+
```csharp
405+
using var fsAudio = File.OpenRead("audio.wav");
406+
var response = client.PostFileWithRequest(new SpeechToText(),
407+
new UploadFile("audio.wav", fsAudio, "audio"));
408+
```
409+
410+
### Dart Speech to Text
411+
412+
```dart
413+
var audioFile = new File('audio.wav');
414+
var uploadFile = new UploadFile(
415+
fieldName: 'audio',
416+
fileName: audioFile.uri.pathSegments.last,
417+
contentType: 'audio/wav',
418+
contents: await audioFile.readAsBytes()
419+
);
420+
421+
var response = await client.postFileWithRequest(new SpeechToText(), uploadFile);
422+
```
423+
424+
### Python Speech to Text
425+
426+
```python
427+
with open("files/audio.wav", "rb") as audio:
428+
response = client.post_file_with_request(SpeechToText(),
429+
UploadFile(field_name="audio", file_name="audio.wav", content_type="audio/wav", stream=audio))
430+
```
431+
432+
### PHP Speech to Text
433+
434+
```php
435+
$audioFile = __DIR__ . '/files/audio.wav';
436+
437+
/** @var GenerationResponse $response */
438+
$response = $client->postFileWithRequest(new SpeechToText(),
439+
new UploadFile(
440+
filePath: $audioFile,
441+
fileName: 'audio.wav',
442+
fieldName: 'audio',
443+
contentType: 'audio/wav'
444+
));
445+
```
446+
447+
### Swift Speech to Text
448+
449+
```swift
450+
guard let audioURL = Bundle.module.url(forResource: "audio.wav", withExtension: nil) else {
451+
return
452+
}
453+
454+
let audioData = try Data(contentsOf: audioURL)
455+
let response: TextGenerationResponse = try await client.postFileWithRequestAsync(
456+
request:SpeechToText(),
457+
file:UploadFile(fileName: "audio.wav", data:audioData, fieldName:"audio"))
458+
```
459+
460+
### Kotlin Speech to Text
461+
462+
```kotlin
463+
val audioBytes = Files.readAllBytes(Paths.get("audio.wav"))
464+
val response = client.postFileWithRequest(SpeechToText(),
465+
UploadFile("audio", "audio.wav", "audio/wav", audioBytes))
466+
```
467+
468+
### Java Speech to Text
469+
470+
```java
471+
byte[] audioBytes = Files.readAllBytes(Paths.get("audio.wav"));
472+
var response = client.postFileWithRequest(request,
473+
new UploadFile("audio", "audio.wav", "audio/wav", audioBytes));
474+
```
475+
476+
### TypeScript Speech to Text
477+
478+
```js
479+
// Create FormData and append the file
480+
const formData = new FormData()
481+
const audioFile = fs.readFileSync('audio.wav')
482+
const blob = new Blob([audioFile], { type: 'audio/wav' })
483+
484+
// Explicitly set the field name as 'audio'
485+
formData.append('audio', blob, 'audio.wav')
486+
487+
const api = await client.apiForm(new SpeechToText(), formData)
488+
```
489+
490+
### Multiple File Uploads
491+
492+
All languages also support a `postFilesWithRequest` variant for uploading multiple files with an API Request.
493+
E.g. here's an example of using `PostFilesWithRequest` to generate a video with a Watermark:
494+
495+
### C# Watermark Video
496+
497+
```csharp
498+
using var fsVideo = File.OpenRead("video.mp4");
499+
using var fsWatermark = File.OpenRead("watermark.png");
500+
var response = client.PostFilesWithRequest(new QueueWatermarkVideo {
501+
Position = WatermarkPosition.BottomRight
502+
}, [
503+
new UploadFile("video.mp4", fsVideo, "video"),
504+
new UploadFile("watermark.png", fsWatermark, "watermark")
505+
]);
506+
```
507+
393508
## Advantages over WCF
394509

395510
- **Simple** Server provides DTOs based on metadata and options provided. No heavy client side tools, just a HTTP request!

0 commit comments

Comments
 (0)