This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marcel Kwiatkowski <[email protected]>
- Loading branch information
1 parent
cd91a74
commit 5f1a414
Showing
1 changed file
with
48 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# FunctionalGPT | ||
Lightweight C#/.NET OpenAI API wrapper with support of GPT function calling via reflection. | ||
> [!NOTE] | ||
> Function calling is not yet supported *(coming soon)*. | ||
## Usage | ||
### Simple Prompt | ||
``` cs | ||
using FunctionalGPT; | ||
|
||
var chatGPT = new ChatGPT("<OPENAI API KEY>", "gpt-3.5-turbo"); | ||
var response = chatGPT.CompleteAsync("Write an article about bitcoin."); | ||
|
||
Console.WriteLine(response); | ||
``` | ||
|
||
### Conversation | ||
```cs | ||
using FunctionalGPT; | ||
|
||
var chatGPT = new ChatGPT("<OPENAI API KEY>", "gpt-3.5-turbo"); | ||
var conversation = new Conversation("You are a helpful assistant [...]"); | ||
|
||
while (true) | ||
{ | ||
var userMessage = Console.ReadLine()!; | ||
conversation.FromUser(userMessage); | ||
|
||
var assistantResponse = await chatGPT.CompleteAsync(conversation); | ||
Console.WriteLine(assistantResponse); | ||
} | ||
``` | ||
> [!IMPORTANT] | ||
> Assistant replies are automatically added to the conversation. | ||
### Conversation with Multiple Users | ||
```cs | ||
using FunctionalGPT; | ||
|
||
var chatGPT = new ChatGPT("<OPENAI API KEY>", "gpt-3.5-turbo"); | ||
var conversation = new Conversation("Decide who is right and explain why."); | ||
|
||
conversation.FromUser("Alice", "I think the egg came first."); | ||
conversation.FromUser("Bob", "Nah, it must have been chicken."); | ||
|
||
var response = await chatGPT.CompleteAsync(conversation); | ||
Console.WriteLine(response); | ||
``` |