Skip to content

Commit 5bab69a

Browse files
committed
formatting
1 parent a019ae5 commit 5bab69a

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

MyApp/_pages/ai-server/chat.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This request will generate a response from the `llama3:8b` model using the `syst
2727

2828
Alternatively, you can call the same endpoint asynchronously by using the `/api/QueueOpenAiChatCompletion` endpoint. This will queue the request for processing and return a URL to check the status of the request and download the response when it's ready.
2929

30-
### Async Queue Open AI Chat Completion
30+
### Queued Open AI Chat Completion
3131

3232
::include ai-server/cs/queue-openai-chat-completion-1.cs.md::
3333

@@ -40,6 +40,41 @@ Additional optional features on the request to enhance the usage of AI Server in
4040

4141
- **ReplyTo**: A URL to send a POST request to when the request is complete.
4242

43+
44+
## Open AI Chat with ReplyTo Callback
45+
46+
The Queued API also accepts a **ReplyTo Web Callback** for a more reliable push-based App integration
47+
where responses are posted back to a custom URL Endpoint:
48+
49+
```csharp
50+
var correlationId = Guid.NewGuid().ToString("N");
51+
var response = client.Post(new QueueOpenAiChatCompletion
52+
{
53+
//...
54+
ReplyTo = $"https://example.org/api/OpenAiChatResponseCallback?CorrelationId=${correlationId}"
55+
});
56+
```
57+
58+
Your callback can add any additional metadata on the callback to assist your App in correlating the response with
59+
the initiating request which just needs to contain the properties of the `OpenAiChatResponse` you're interested in
60+
along with any metadata added to the callback URL, e.g:
61+
62+
```csharp
63+
public class OpenAiChatResponseCallback : IPost, OpenAiChatResponse, IReturnVoid
64+
{
65+
public Guid CorrelationId { get; set; }
66+
}
67+
68+
public object Post(OpenAiChatResponseCallback request)
69+
{
70+
// Handle OpenAiChatResponse callabck
71+
}
72+
```
73+
74+
Unless your callback API is restricted to only accept requests from your AI Server, you should include a
75+
unique Id like a `Guid` in the callback URL that can be validated against an initiating request to ensure
76+
the callback can't be spoofed.
77+
4378
## Using the AI Server Request DTOs with other OpenAI compatible APIs
4479

4580
One advantage of using AI Server is that it provides a common set of request DTOs in 11 different languages that are compatible with OpenAI's API. This allows you to switch between OpenAI and AI Server without changing your client code.

MyApp/_pages/ai-server/comfy-extension.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,11 @@ The AI Server has pre-defined workflows to interact with your ComfyUI Agent inst
5555

5656
These workflows are found in the AI Server AppHost project under `workflows`. These are templated JSON versions of workflows you save in the ComfyUI web interface.
5757

58-
You can override these workflows by creating a new JSON file with the same name and path but in the `App_Data/overrides` folder. For example, to override the `text_to_image` workflow, you would create a file at `App_Data/overrides/text_to_image.json`.
59-
This would override all calls that use text-to-image workflow sent to your ComfyUI Agent instance. You can also override just `flux-schnell` by creating a file at `App_Data/overrides/flux1/text_to_image.json`, and Stable Diffusion 3.5 at `App_Data/overrides/sd35/text_to_image.json`.
58+
You can override these workflows by creating a new JSON file with the same name and path but in the `App_Data/overrides` folder.
59+
60+
E.g. to override the `text_to_image` workflow, you would create a file at `App_Data/overrides/text_to_image.json`
61+
62+
This would override all calls that use text-to-image workflow sent to your ComfyUI Agent instance.
63+
64+
You can also override just `flux-schnell` by creating a file at `App_Data/overrides/flux1/text_to_image.json`
65+
and Stable Diffusion 3.5 at `App_Data/overrides/sd35/text_to_image.json`.

0 commit comments

Comments
 (0)