Skip to content

Commit 460b06f

Browse files
committed
Update chat usage.
1 parent f3d0d98 commit 460b06f

File tree

1 file changed

+16
-16
lines changed
  • MyApp/_pages/ai-server/usage

1 file changed

+16
-16
lines changed

MyApp/_pages/ai-server/usage/index.md renamed to MyApp/_pages/ai-server/usage/chat.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ To make a chat request to AI Server, you can use the `/api/CreateOpenAiChat` end
1313
```csharp
1414
var response = client.Post(new CreateOpenAiChat {
1515
Request = new OpenAiChat {
16-
Model = "gpt-3.5-turbo",
16+
Model = "gpt-4-turbo",
1717
Messages = new List<OpenAiMessage> {
1818
new OpenAiMessage { Role = "system", Content = "You are a helpful AI assistant." },
19-
new OpenAiMessage { Role = "user", Content = "How do I ..." }
20-
}
21-
}
19+
new OpenAiMessage { Role = "user", Content = "How do LLMs work?" }
20+
},
21+
MaxTokens = 50
22+
},
23+
RefId = "<unique-id>",
24+
Provider = "openai",
25+
ReplyTo = "https://myapp.com/reply",
26+
Sync = true
2227
});
2328
```
2429

@@ -28,21 +33,16 @@ Additional optional features on the request to enhance the usage of AI Server in
2833
- **Provider**: Force the request to use a specific provider, overriding the selection logic.
2934
- **ReplyTo**: A HTTP URL to send the response to on completion of the request.
3035
- **Tag**: A tag to help categorize the request for easier tracking.
36+
- **Sync**: A boolean value to determine if the request should be processed synchronously (default is asynchronous returning job info).
37+
38+
These additional request properties are consistent across all AI Server endpoints, providing a common interface for all AI services.
3139

3240
## Using the AI Server Request DTOs with other OpenAI compatible APIs
3341

3442
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.
3543
This means you can switch to using typed APIs in your preferred language with your existing service providers OpenAI compatible APIs, and optionally switch to AI Server when you're ready to self-host your AI services for better value.
3644

37-
```csharp
38-
// Using OpenAI API
39-
var request = new OpenAiChat {
40-
Model = "gpt-3.5-turbo",
41-
Messages = new List<OpenAiMessage> {
42-
new OpenAiMessage { Role = "system", Content = "You are a helpful AI assistant." },
43-
new OpenAiMessage { Role = "user", Content = "How do I ..." }
44-
}
45-
};
46-
47-
var response = await client.PostAsync("https://api.openai.com/v1/", request);
48-
```
45+
::include ai-server/cs/open-ai-requests-1.cs.md::
46+
47+
This shows usage of the `OpenAiChat` request DTO directly with OpenAI's API. The same request DTO can be used with AI Server's `/api/CreateOpenAiChat` endpoint, populated the same way.
48+

0 commit comments

Comments
 (0)