Skip to content

Commit

Permalink
#151: Moved specific provider schemas closer to provider's packages &…
Browse files Browse the repository at this point in the history
… simplified naming for Glide schema
  • Loading branch information
roma-glushko committed Feb 18, 2024
1 parent 20c7fbc commit 1c8a46a
Show file tree
Hide file tree
Showing 24 changed files with 312 additions and 304 deletions.
92 changes: 46 additions & 46 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schemas.UnifiedChatRequest"
"$ref": "#/definitions/schemas.ChatRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/schemas.UnifiedChatResponse"
"$ref": "#/definitions/schemas.ChatResponse"
}
},
"400": {
Expand Down Expand Up @@ -676,49 +676,7 @@ const docTemplate = `{
}
}
},
"schemas.OverrideChatRequest": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/schemas.ChatMessage"
},
"model_id": {
"type": "string"
}
}
},
"schemas.ProviderResponse": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/schemas.ChatMessage"
},
"responseId": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"tokenCount": {
"$ref": "#/definitions/schemas.TokenUsage"
}
}
},
"schemas.TokenUsage": {
"type": "object",
"properties": {
"promptTokens": {
"type": "number"
},
"responseTokens": {
"type": "number"
},
"totalTokens": {
"type": "number"
}
}
},
"schemas.UnifiedChatRequest": {
"schemas.ChatRequest": {
"type": "object",
"properties": {
"message": {
Expand All @@ -735,7 +693,7 @@ const docTemplate = `{
}
}
},
"schemas.UnifiedChatResponse": {
"schemas.ChatResponse": {
"type": "object",
"properties": {
"cached": {
Expand Down Expand Up @@ -763,6 +721,48 @@ const docTemplate = `{
"type": "string"
}
}
},
"schemas.OverrideChatRequest": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/schemas.ChatMessage"
},
"model_id": {
"type": "string"
}
}
},
"schemas.ProviderResponse": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/schemas.ChatMessage"
},
"responseId": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"tokenCount": {
"$ref": "#/definitions/schemas.TokenUsage"
}
}
},
"schemas.TokenUsage": {
"type": "object",
"properties": {
"promptTokens": {
"type": "number"
},
"responseTokens": {
"type": "number"
},
"totalTokens": {
"type": "number"
}
}
}
},
"externalDocs": {
Expand Down
92 changes: 46 additions & 46 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/schemas.UnifiedChatRequest"
"$ref": "#/definitions/schemas.ChatRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/schemas.UnifiedChatResponse"
"$ref": "#/definitions/schemas.ChatResponse"
}
},
"400": {
Expand Down Expand Up @@ -673,49 +673,7 @@
}
}
},
"schemas.OverrideChatRequest": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/schemas.ChatMessage"
},
"model_id": {
"type": "string"
}
}
},
"schemas.ProviderResponse": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/schemas.ChatMessage"
},
"responseId": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"tokenCount": {
"$ref": "#/definitions/schemas.TokenUsage"
}
}
},
"schemas.TokenUsage": {
"type": "object",
"properties": {
"promptTokens": {
"type": "number"
},
"responseTokens": {
"type": "number"
},
"totalTokens": {
"type": "number"
}
}
},
"schemas.UnifiedChatRequest": {
"schemas.ChatRequest": {
"type": "object",
"properties": {
"message": {
Expand All @@ -732,7 +690,7 @@
}
}
},
"schemas.UnifiedChatResponse": {
"schemas.ChatResponse": {
"type": "object",
"properties": {
"cached": {
Expand Down Expand Up @@ -760,6 +718,48 @@
"type": "string"
}
}
},
"schemas.OverrideChatRequest": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/schemas.ChatMessage"
},
"model_id": {
"type": "string"
}
}
},
"schemas.ProviderResponse": {
"type": "object",
"properties": {
"message": {
"$ref": "#/definitions/schemas.ChatMessage"
},
"responseId": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"tokenCount": {
"$ref": "#/definitions/schemas.TokenUsage"
}
}
},
"schemas.TokenUsage": {
"type": "object",
"properties": {
"promptTokens": {
"type": "number"
},
"responseTokens": {
"type": "number"
},
"totalTokens": {
"type": "number"
}
}
}
},
"externalDocs": {
Expand Down
62 changes: 31 additions & 31 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,34 +375,7 @@ definitions:
or assistant.
type: string
type: object
schemas.OverrideChatRequest:
properties:
message:
$ref: '#/definitions/schemas.ChatMessage'
model_id:
type: string
type: object
schemas.ProviderResponse:
properties:
message:
$ref: '#/definitions/schemas.ChatMessage'
responseId:
additionalProperties:
type: string
type: object
tokenCount:
$ref: '#/definitions/schemas.TokenUsage'
type: object
schemas.TokenUsage:
properties:
promptTokens:
type: number
responseTokens:
type: number
totalTokens:
type: number
type: object
schemas.UnifiedChatRequest:
schemas.ChatRequest:
properties:
message:
$ref: '#/definitions/schemas.ChatMessage'
Expand All @@ -413,7 +386,7 @@ definitions:
override:
$ref: '#/definitions/schemas.OverrideChatRequest'
type: object
schemas.UnifiedChatResponse:
schemas.ChatResponse:
properties:
cached:
type: boolean
Expand All @@ -432,6 +405,33 @@ definitions:
router:
type: string
type: object
schemas.OverrideChatRequest:
properties:
message:
$ref: '#/definitions/schemas.ChatMessage'
model_id:
type: string
type: object
schemas.ProviderResponse:
properties:
message:
$ref: '#/definitions/schemas.ChatMessage'
responseId:
additionalProperties:
type: string
type: object
tokenCount:
$ref: '#/definitions/schemas.TokenUsage'
type: object
schemas.TokenUsage:
properties:
promptTokens:
type: number
responseTokens:
type: number
totalTokens:
type: number
type: object
externalDocs:
description: Documentation
url: https://glide.einstack.ai/
Expand Down Expand Up @@ -497,14 +497,14 @@ paths:
name: payload
required: true
schema:
$ref: '#/definitions/schemas.UnifiedChatRequest'
$ref: '#/definitions/schemas.ChatRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/schemas.UnifiedChatResponse'
$ref: '#/definitions/schemas.ChatResponse'
"400":
description: Bad Request
schema:
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/http/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ type Handler = func(c *fiber.Ctx) error
// @Description Talk to different LLMs Chat API via unified endpoint
// @tags Language
// @Param router path string true "Router ID"
// @Param payload body schemas.UnifiedChatRequest true "Request Data"
// @Param payload body schemas.ChatRequest true "Request Data"
// @Accept json
// @Produce json
// @Success 200 {object} schemas.UnifiedChatResponse
// @Success 200 {object} schemas.ChatResponse
// @Failure 400 {object} http.ErrorSchema
// @Failure 404 {object} http.ErrorSchema
// @Router /v1/language/{router}/chat [POST]
func LangChatHandler(routerManager *routers.RouterManager) Handler {
return func(c *fiber.Ctx) error {
// Unmarshal request body
var req *schemas.UnifiedChatRequest
var req *schemas.ChatRequest

err := c.BodyParser(&req)
if err != nil {
Expand Down
Loading

0 comments on commit 1c8a46a

Please sign in to comment.