From 3e53ed47530aebb63ac44ba008afc823860a0f0d Mon Sep 17 00:00:00 2001 From: Yaohui Liu Date: Mon, 22 May 2023 19:07:43 +0800 Subject: [PATCH] fix: build error after dropping LLamaModelV1. --- LLama/LLamaSharp.csproj | 8 ++++---- LLama/LLamaTypes.cs | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 LLama/LLamaTypes.cs diff --git a/LLama/LLamaSharp.csproj b/LLama/LLamaSharp.csproj index fd1a31c2..76579153 100644 --- a/LLama/LLamaSharp.csproj +++ b/LLama/LLamaSharp.csproj @@ -8,7 +8,7 @@ AnyCPU;x64 True - 0.2.4 + 0.3.0 Yaohui Liu, Haiping Chen SciSharp STACK true @@ -18,10 +18,10 @@ https://avatars3.githubusercontent.com/u/44989469?s=200&v=4 LLama, LLM, GPT, ChatGPT, NLP, AI, Chat Bot, SciSharp - The .NET binding of LLama.cpp, providing APIs to run the model and deploy it on Web. + The .NET binding of LLama.cpp, providing APIs to run the model and deploy it on Web. For model weights to run, please go to https://github.com/SciSharp/LLamaSharp for more information. - LLama 0.2.4 mainly supports loading and saving session state. + LLamaSharp 0.3.0 supports loading and saving session state, tokenization and detokenization. Besides, since 0.3.0, `LLamaModelV1` is dropped. MIT packages @@ -35,7 +35,7 @@ - + diff --git a/LLama/LLamaTypes.cs b/LLama/LLamaTypes.cs new file mode 100644 index 00000000..cee9338f --- /dev/null +++ b/LLama/LLamaTypes.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace LLama.Types +{ + public enum ChatRole + { + Human, + Assistant + } + public record EmbeddingUsage(int PromptTokens, int TotalTokens); + + public record EmbeddingData(int Index, string Object, float[] Embedding); + + public record Embedding(string Object, string Model, EmbeddingData[] Data, EmbeddingUsage Usage); + + public record CompletionLogprobs(int[] TextOffset, float[] TokenLogProbs, string[] Tokens, Dictionary[] TopLogprobs); + + public record CompletionChoice(string Text, int Index, CompletionLogprobs? Logprobs, string? FinishReason); + + public record CompletionUsage(int PromptTokens, int CompletionTokens, int TotalTokens); + + public record CompletionChunk(string Id, string Object, int Created, string Model, CompletionChoice[] Choices); + + public record Completion(string Id, string Object, int Created, string Model, CompletionChoice[] Choices, CompletionUsage Usage); + + public record ChatCompletionMessage(ChatRole Role, string Content, string? Name = null); + + public record ChatCompletionChoice(int Index, ChatCompletionMessage Message, string? FinishReason); + + public record ChatCompletion(string Id, string Object, int Created, string Model, ChatCompletionChoice[] Choices, CompletionUsage Usage); + + public record ChatCompletionChunkDelta(string? Role, string? Content); + + public record ChatCompletionChunkChoice(int Index, ChatCompletionChunkDelta Delta, string? FinishReason); + + public record ChatCompletionChunk(string Id, string Model, string Object, int Created, ChatCompletionChunkChoice[] Choices); + + public record ChatMessageRecord(ChatCompletionMessage Message, DateTime Time); +}