-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from xbotter/patch/examples
Update examples
- Loading branch information
Showing
20 changed files
with
72 additions
and
131 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
2 changes: 1 addition & 1 deletion
2
...es/NewVersion/ChatSessionStripRoleName.cs → ...ples/Examples/ChatSessionStripRoleName.cs
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
2 changes: 1 addition & 1 deletion
2
...les/NewVersion/ChatSessionWithRoleName.cs → ...mples/Examples/ChatSessionWithRoleName.cs
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
2 changes: 1 addition & 1 deletion
2
LLama.Examples/NewVersion/CodingAssistant.cs → LLama.Examples/Examples/CodingAssistant.cs
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,4 +1,4 @@ | ||
namespace LLama.Examples.NewVersion | ||
namespace LLama.Examples.Examples | ||
{ | ||
using LLama.Common; | ||
using System; | ||
|
2 changes: 1 addition & 1 deletion
2
LLama.Examples/NewVersion/GetEmbeddings.cs → LLama.Examples/Examples/GetEmbeddings.cs
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
2 changes: 1 addition & 1 deletion
2
...xamples/NewVersion/GrammarJsonResponse.cs → ....Examples/Examples/GrammarJsonResponse.cs
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
2 changes: 1 addition & 1 deletion
2
...xamples/NewVersion/InstructModeExecute.cs → ....Examples/Examples/InstructModeExecute.cs
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
2 changes: 1 addition & 1 deletion
2
...ples/NewVersion/InteractiveModeExecute.cs → ...amples/Examples/InteractiveModeExecute.cs
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
2 changes: 1 addition & 1 deletion
2
...Examples/NewVersion/LoadAndSaveSession.cs → ...a.Examples/Examples/LoadAndSaveSession.cs
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
2 changes: 1 addition & 1 deletion
2
...a.Examples/NewVersion/LoadAndSaveState.cs → LLama.Examples/Examples/LoadAndSaveState.cs
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
2 changes: 1 addition & 1 deletion
2
LLama.Examples/NewVersion/QuantizeModel.cs → LLama.Examples/Examples/QuantizeModel.cs
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,4 +1,4 @@ | ||
namespace LLama.Examples.NewVersion | ||
namespace LLama.Examples.Examples | ||
{ | ||
public class QuantizeModel | ||
{ | ||
|
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,53 @@ | ||
using Spectre.Console; | ||
|
||
namespace LLama.Examples.Examples; | ||
|
||
public class Runner | ||
{ | ||
static Dictionary<string, Func<Task>> Examples = new() | ||
{ | ||
{"Run a chat session without stripping the role names.", () => ChatSessionWithRoleName.Run()}, | ||
{"Run a chat session with the role names stripped.",()=> ChatSessionStripRoleName.Run()}, | ||
{"Interactive mode chat by using executor.",()=> InteractiveModeExecute.Run()}, | ||
{"Instruct mode chat by using executor.",()=> InstructModeExecute.Run()}, | ||
{"Stateless mode chat by using executor.",()=> StatelessModeExecute.Run()}, | ||
{"Load and save chat session.",()=> SaveAndLoadSession.Run()}, | ||
{"Load and save state of model and executor.",()=> LoadAndSaveState.Run()}, | ||
{"Get embeddings from LLama model.",()=> Task.Run(GetEmbeddings.Run)}, | ||
{"Quantize the model.",()=> Task.Run(QuantizeModel.Run)}, | ||
{"Automatic conversation.",()=> TalkToYourself.Run()}, | ||
{"Constrain response to json format using grammar.",()=> GrammarJsonResponse.Run()}, | ||
{"Semantic Kernel Prompt.",()=> SemanticKernelPrompt.Run()}, | ||
{"Semantic Kernel Chat.",()=> SemanticKernelChat.Run()}, | ||
{"Semantic Kernel Memory.",()=> SemanticKernelMemory.Run()}, | ||
{"Coding Assistant.",()=> CodingAssistant.Run()}, | ||
{"Batch Decoding.",()=> BatchedDecoding.Run()}, | ||
{"SK Kernel Memory.",()=> KernelMemory.Run()}, | ||
{"Exit", ()=> Task.CompletedTask} | ||
}; | ||
public static async Task Run() | ||
{ | ||
AnsiConsole.Write(new Rule("LLamaSharp Examples")); | ||
|
||
while (true) | ||
{ | ||
var choice = AnsiConsole.Prompt( | ||
new SelectionPrompt<string>() | ||
.Title("Please choose[green] an example[/] to run: ") | ||
.AddChoices(Examples.Keys)); | ||
|
||
|
||
if (Examples.TryGetValue(choice, out var example)) | ||
{ | ||
if (choice == "Exit") | ||
{ | ||
break; | ||
} | ||
AnsiConsole.Write(new Rule(choice)); | ||
await example(); | ||
} | ||
|
||
AnsiConsole.Clear(); | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...amples/NewVersion/StatelessModeExecute.cs → ...Examples/Examples/StatelessModeExecute.cs
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 was deleted.
Oops, something went wrong.
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