Skip to content

Commit

Permalink
#61: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger12 committed Jan 5, 2024
1 parent f463344 commit 79e4f45
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 50 deletions.
95 changes: 46 additions & 49 deletions pkg/api/schemas/language.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ type UnifiedChatRequest struct {

// UnifiedChatResponse defines Glide's Chat Response Schema unified across all language models
type UnifiedChatResponse struct {
ID string `json:"id,omitempty"`
Created int `json:"created,omitempty"`
Provider string `json:"provider,omitempty"`
Router string `json:"router,omitempty"`
Model string `json:"model,omitempty"`
Cached bool `json:"cached,omitempty"`
ID string `json:"id,omitempty"`
Created int `json:"created,omitempty"`
Provider string `json:"provider,omitempty"`
Router string `json:"router,omitempty"`
Model string `json:"model,omitempty"`
Cached bool `json:"cached,omitempty"`
ModelResponse ProviderResponse `json:"modelResponse,omitempty"`
}

Expand All @@ -26,9 +26,9 @@ type ProviderResponse struct {
}

type TokenCount struct {
PromptTokens float64 `json:"promptTokens"`
ResponseTokens float64 `json:"responseTokens"`
TotalTokens float64 `json:"totalTokens"`
PromptTokens float64 `json:"promptTokens"`
ResponseTokens float64 `json:"responseTokens"`
TotalTokens float64 `json:"totalTokens"`
}

// ChatMessage is a message in a chat request.
Expand All @@ -45,47 +45,47 @@ type ChatMessage struct {
// OpenAI Chat Response
// TODO: Should this live here?
type OpenAIChatCompletion struct {
ID string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
SystemFingerprint string `json:"system_fingerprint"`
Choices []Choice `json:"choices"`
Usage Usage `json:"usage"`
ID string `json:"id"`
Object string `json:"object"`
Created int `json:"created"`
Model string `json:"model"`
SystemFingerprint string `json:"system_fingerprint"`
Choices []Choice `json:"choices"`
Usage Usage `json:"usage"`
}

type Choice struct {
Index int `json:"index"`
Message ChatMessage `json:"message"`
Logprobs interface{} `json:"logprobs"`
FinishReason string `json:"finish_reason"`
Index int `json:"index"`
Message ChatMessage `json:"message"`
Logprobs interface{} `json:"logprobs"`
FinishReason string `json:"finish_reason"`
}

type Usage struct {
PromptTokens float64 `json:"prompt_tokens"`
CompletionTokens float64 `json:"completion_tokens"`
TotalTokens float64 `json:"total_tokens"`
PromptTokens float64 `json:"prompt_tokens"`
CompletionTokens float64 `json:"completion_tokens"`
TotalTokens float64 `json:"total_tokens"`
}

// Cohere Chat Response
type CohereChatCompletion struct {
Text string `json:"text"`
GenerationID string `json:"generation_id"`
ResponseID string `json:"response_id"`
TokenCount CohereTokenCount `json:"token_count"`
Citations []Citation `json:"citations"`
Documents []Documents `json:"documents"`
SearchQueries []SearchQuery `json:"search_queries"`
SearchResults []SearchResults `json:"search_results"`
Meta Meta `json:"meta"`
ToolInputs map[string]interface{} `json:"tool_inputs"`
Text string `json:"text"`
GenerationID string `json:"generation_id"`
ResponseID string `json:"response_id"`
TokenCount CohereTokenCount `json:"token_count"`
Citations []Citation `json:"citations"`
Documents []Documents `json:"documents"`
SearchQueries []SearchQuery `json:"search_queries"`
SearchResults []SearchResults `json:"search_results"`
Meta Meta `json:"meta"`
ToolInputs map[string]interface{} `json:"tool_inputs"`
}

type CohereTokenCount struct {
PromptTokens float64 `json:"prompt_tokens"`
ResponseTokens float64 `json:"response_tokens"`
TotalTokens float64 `json:"total_tokens"`
BilledTokens float64 `json:"billed_tokens"`
PromptTokens float64 `json:"prompt_tokens"`
ResponseTokens float64 `json:"response_tokens"`
TotalTokens float64 `json:"total_tokens"`
BilledTokens float64 `json:"billed_tokens"`
}

type Meta struct {
Expand All @@ -99,33 +99,30 @@ type Meta struct {
}

type Citation struct {
Start int `json:"start"`
End int `json:"end"`
Text string `json:"text"`
Start int `json:"start"`
End int `json:"end"`
Text string `json:"text"`
DocumentID []string `json:"documentId"`

}

type Documents struct {
ID string `json:"id"`
ID string `json:"id"`
Data map[string]string `json:"data"` // TODO: This needs to be updated
}

type SearchQuery struct {
Text string `json:"text"`
Text string `json:"text"`
GenerationID string `json:"generationId"`
}

type SearchResults struct {
SearchQuery []SearchQueryObject `json:"searchQuery"`
Connectors []ConnectorsResponse `json:"connectors"`
DocumentID []string `json:"documentId"`


SearchQuery []SearchQueryObject `json:"searchQuery"`
Connectors []ConnectorsResponse `json:"connectors"`
DocumentID []string `json:"documentId"`
}

type SearchQueryObject struct {
Text string `json:"text"`
Text string `json:"text"`
GenerationID string `json:"generationId"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/openai/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (c *Client) doChatRequest(ctx context.Context, payload *ChatRequest) (*sche
c.telemetry.Logger.Error("failed to parse openai chat response", zap.Error(err))
return nil, err
}

// Map response to UnifiedChatResponse schema
response := schemas.UnifiedChatResponse{
ID: openAICompletion.ID,
Expand Down

0 comments on commit 79e4f45

Please sign in to comment.