-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gateway): pass models.ChatCompletion struct from handlers
Signed-off-by: Praveen Yadav <pyadav9678@gmail.com>
- Loading branch information
Showing
18 changed files
with
935 additions
and
479 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package models | ||
|
||
type ResponseFormat struct { | ||
Type string `json:"type,omitempty"` | ||
} | ||
|
||
type ChatCompletion struct { | ||
Model string `json:"model"` | ||
Messages []ChatCompletionMessage `json:"messages"` | ||
Temperature float32 `json:"temperature,omitempty" default:"1"` | ||
Suffix string `json:"suffix,omitempty"` | ||
Seed uint64 `json:"seed,omitempty"` | ||
N uint64 `json:"n,omitempty"` | ||
Echo bool `json:"echo,omitempty"` | ||
BestOf uint64 `json:"best_of,omitempty"` | ||
PresencePenalty float32 `json:"presence_penalty,omitempty"` | ||
FrequencyPenalty float32 `json:"frequency_penalty,omitempty"` | ||
Stream bool `json:"stream,omitempty"` | ||
TopK float32 `json:"top_k,omitempty"` | ||
TopP float32 `json:"top_p,omitempty"` | ||
Stop []string `json:"stop,omitempty"` | ||
MaxTokens uint64 `json:"max_tokens,omitempty"` | ||
LogProbs bool `json:"logprobs,omitempty"` | ||
TopLogprobs uint64 `json:"top_logprobs,omitempty"` | ||
LogitBias map[string]any `json:"logit_bias,omitempty"` | ||
ToolChoice map[string]any `json:"tool_choice,omitempty"` | ||
User string `json:"user,omitempty"` | ||
} | ||
|
||
type Usage struct { | ||
PromptToken int64 `json:"prompt_tokens,omitempty"` | ||
CompletionTokens int64 `json:"completion_tokens,omitempty"` | ||
TotalTokens int64 `json:"total_tokens,omitempty"` | ||
} | ||
|
||
type LogprobResult struct { | ||
Tokens []string `json:"tokens"` | ||
TokenLogprobs []float32 `json:"token_logprobs"` | ||
TopLogprobs []map[string]float32 `json:"top_logprobs"` | ||
TextOffset []int `json:"text_offset"` | ||
} | ||
|
||
type Function struct { | ||
Name string `json:"name"` | ||
Arguments string `json:"arguments"` | ||
} | ||
|
||
type ToolCallMessage struct { | ||
Id string `json:"id"` | ||
Type string `json:"type"` | ||
Function Function `json:"function"` | ||
} | ||
|
||
type ChatCompletionMessage struct { | ||
Role string `json:"role"` | ||
Content string `json:"content"` | ||
LogProbs map[string]any `json:"logprobs,omitempty"` | ||
ToolCalls []ToolCallMessage `json:"tool_calls,omitempty"` | ||
} | ||
|
||
type CompletionChoice struct { | ||
Index int `json:"index"` | ||
Message ChatCompletionMessage `json:"message"` | ||
FinishReason string `json:"finish_reason"` | ||
LogProbs LogprobResult `json:"logprobs"` | ||
} | ||
|
||
type CompletionResponse struct { | ||
ID string `json:"id"` | ||
Object string `json:"object"` | ||
Created int64 `json:"created"` | ||
Model string `json:"model"` | ||
Choices []CompletionChoice `json:"choices"` | ||
Usage Usage `json:"usage"` | ||
SystemFingerprint string `json:"system_fingerprint"` | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package utils | ||
|
||
import "reflect" | ||
|
||
func GetDefaultValue(ptr interface{}, defaultValue interface{}) interface{} { | ||
if ptr == nil || reflect.ValueOf(ptr).IsNil() { | ||
return defaultValue | ||
} | ||
return reflect.ValueOf(ptr).Elem().Interface() | ||
} |
Oops, something went wrong.