generated from NetCoreTemplates/razor-ssg
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
36 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
```csharp | ||
var apiClient = GetLocalApiClient(AiServerUrl); | ||
apiClient.BearerToken = Environment.GetEnvironmentVariable("AI_SERVER_API_KEY"); | ||
var client = GetLocalApiClient(AiServerUrl); | ||
|
||
var request = new OpenAiChatCompletion { | ||
var response = client.Post(new OpenAiChatCompletion { | ||
Model = "llama3.1:8b", | ||
Messages = | ||
[ | ||
new() { Role = "system", Content = "You are a helpful AI assistant." }, | ||
new() { Role = "user", Content = "How do LLMs work?" } | ||
], | ||
MaxTokens = 50 | ||
}; | ||
|
||
var response = await apiClient.PostAsync(request); | ||
var openAiResponse = response; // The same | ||
Console.WriteLine(openAiResponse.Choices[0].Message.Content); | ||
}); | ||
var answer = response.Choices[0].Message.Content; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters