You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MyApp/_pages/ai-server/usage/chat.md
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -13,12 +13,17 @@ To make a chat request to AI Server, you can use the `/api/CreateOpenAiChat` end
13
13
```csharp
14
14
varresponse=client.Post(newCreateOpenAiChat {
15
15
Request=newOpenAiChat {
16
-
Model="gpt-3.5-turbo",
16
+
Model="gpt-4-turbo",
17
17
Messages=newList<OpenAiMessage> {
18
18
newOpenAiMessage { Role="system", Content="You are a helpful AI assistant." },
19
-
newOpenAiMessage { Role="user", Content="How do I ..." }
20
-
}
21
-
}
19
+
newOpenAiMessage { 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
22
27
});
23
28
```
24
29
@@ -28,21 +33,16 @@ Additional optional features on the request to enhance the usage of AI Server in
28
33
-**Provider**: Force the request to use a specific provider, overriding the selection logic.
29
34
-**ReplyTo**: A HTTP URL to send the response to on completion of the request.
30
35
-**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.
31
39
32
40
## Using the AI Server Request DTOs with other OpenAI compatible APIs
33
41
34
42
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.
35
43
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.
36
44
37
-
```csharp
38
-
// Using OpenAI API
39
-
varrequest=newOpenAiChat {
40
-
Model="gpt-3.5-turbo",
41
-
Messages=newList<OpenAiMessage> {
42
-
newOpenAiMessage { Role="system", Content="You are a helpful AI assistant." },
43
-
newOpenAiMessage { Role="user", Content="How do I ..." }
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.
0 commit comments