Skip to content

Instantly share code, notes, and snippets.

@DayOfThePenguin
Last active June 28, 2023 21:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DayOfThePenguin/1e5400ef3c273eec6489ccaf2fcddb1a to your computer and use it in GitHub Desktop.
Save DayOfThePenguin/1e5400ef3c273eec6489ccaf2fcddb1a to your computer and use it in GitHub Desktop.
Chat Proto
syntax = "proto3";
package chat;
option go_package = "github.com/defenseunicorns/leapfrogai/pkg/client/chat";
// ChatRequest is the payload to Chat creation
message ChatRequest {
repeated string inputs = 1;
}
message Chat {
repeated float chat = 1;
}
// ChatResponse are what's returned by the gRPC service
message ChatResponse {
repeated Chat chat = 1;
}
service ChatsService {
rpc ChatCompletion(ChatRequest) returns (ChatResponse);
rpc ChatCompletionStream(ChatRequest) returns (stream ChatResponse);
}
// Generic OpenAI
enum OpenAIChatRole {
USER = 0;
SYSTEM = 1;
FUNCTION = 2;
ASSISTANT = 3;
}
message OpenAIChatItem {
OpenAIChatRole role = 1;
string content = 2;
}
// OpenAI ChatCompletion Request
message OpenAIChatCompletionRequest {
string model = 1; // added
repeated OpenAIChatItem chat_items = 2; // added
float temperature = 3; // added
float top_p = 4; // added
int32 n = 5; //added
bool stream = 7; // will be used to route to either
repeated string stop = 8; //added
int32 max_tokens = 9; // max_new_tokens
float presence_penalty = 10; // added
float frequency_penalty = 11; // added
map<string, int32> logit_bias = 12; // added
string user = 13; // added
}
// OpenAI ChatCompletion Request
message OpenAICompletionChoice {
int32 index = 1;
OpenAIChatItem chas_item = 2;
string finish_reason = 3;
}
message Usage {
int32 prompt_tokens = 1;
int32 completion_tokens = 2;
int32 total_tokens = 3;
}
message ChatCompletionRequest {
string id = 1;
string object = 2;
int64 created = 3;
repeated OpenAICompletionChoice choices = 4;
Usage usage = 5;
}
syntax = "proto3";
package generate;
option go_package = "github.com/defenseunicorns/leapfrogai/pkg/client/generate";
// CompletionRequest is the payload to request completion
message CompletionRequest {
string prompt = 1; // huggingface `inputs`
optional string suffix = 2;
optional int32 max_new_tokens = 3; // openai `max_tokens`
optional float temperature = 4;
optional int32 top_k = 5;
optional float top_p = 6;
optional bool do_sample = 7;
optional int32 n = 8;
optional int32 logprobs = 9;
optional bool echo = 10;
repeated string stop = 11; // You can only represent Union[str, list] as a string.
optional float repetition_penalty = 12;
optional float presence_penalty = 13;
optional float frequence_penalty = 14;
optional int32 best_of = 15;
map<string, int32> logit_bias = 16; // Maps are represented as a pair of a key type and a value type.
optional bool return_full_text = 17;
optional string truncate = 18;
optional float typical_p = 19;
optional bool watermark = 20;
optional int32 seed = 21;
optional string user = 22;
}
enum CompletionFinishReason {
STOP = 0;
LENGTH = 1;
}
message CompletionChoice {
string text = 1;
int32 index = 2;
CompletionFinishReason finish_reason = 3;
}
message CompletionUsage {
int32 prompt_tokens = 1;
int32 completion_tokens = 2;
int32 total_tokens = 3;
}
// CompletionRespones are what's returned by the gRPC service
message CompletionResponse {
repeated CompletionChoice choices = 1;
CompletionUsage usage = 2;
}
service CompletionService {
rpc Complete (CompletionRequest) returns (CompletionResponse);
rpc CompleteStream (CompletionRequest) returns (stream CompletionResponse);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment