Skip to content

Commit 1c8a46a

Browse files
committed
#151: Moved specific provider schemas closer to provider's packages & simplified naming for Glide schema
1 parent 20c7fbc commit 1c8a46a

24 files changed

+312
-304
lines changed

Diff for: docs/docs.go

+46-46
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ const docTemplate = `{
9898
"in": "body",
9999
"required": true,
100100
"schema": {
101-
"$ref": "#/definitions/schemas.UnifiedChatRequest"
101+
"$ref": "#/definitions/schemas.ChatRequest"
102102
}
103103
}
104104
],
105105
"responses": {
106106
"200": {
107107
"description": "OK",
108108
"schema": {
109-
"$ref": "#/definitions/schemas.UnifiedChatResponse"
109+
"$ref": "#/definitions/schemas.ChatResponse"
110110
}
111111
},
112112
"400": {
@@ -676,49 +676,7 @@ const docTemplate = `{
676676
}
677677
}
678678
},
679-
"schemas.OverrideChatRequest": {
680-
"type": "object",
681-
"properties": {
682-
"message": {
683-
"$ref": "#/definitions/schemas.ChatMessage"
684-
},
685-
"model_id": {
686-
"type": "string"
687-
}
688-
}
689-
},
690-
"schemas.ProviderResponse": {
691-
"type": "object",
692-
"properties": {
693-
"message": {
694-
"$ref": "#/definitions/schemas.ChatMessage"
695-
},
696-
"responseId": {
697-
"type": "object",
698-
"additionalProperties": {
699-
"type": "string"
700-
}
701-
},
702-
"tokenCount": {
703-
"$ref": "#/definitions/schemas.TokenUsage"
704-
}
705-
}
706-
},
707-
"schemas.TokenUsage": {
708-
"type": "object",
709-
"properties": {
710-
"promptTokens": {
711-
"type": "number"
712-
},
713-
"responseTokens": {
714-
"type": "number"
715-
},
716-
"totalTokens": {
717-
"type": "number"
718-
}
719-
}
720-
},
721-
"schemas.UnifiedChatRequest": {
679+
"schemas.ChatRequest": {
722680
"type": "object",
723681
"properties": {
724682
"message": {
@@ -735,7 +693,7 @@ const docTemplate = `{
735693
}
736694
}
737695
},
738-
"schemas.UnifiedChatResponse": {
696+
"schemas.ChatResponse": {
739697
"type": "object",
740698
"properties": {
741699
"cached": {
@@ -763,6 +721,48 @@ const docTemplate = `{
763721
"type": "string"
764722
}
765723
}
724+
},
725+
"schemas.OverrideChatRequest": {
726+
"type": "object",
727+
"properties": {
728+
"message": {
729+
"$ref": "#/definitions/schemas.ChatMessage"
730+
},
731+
"model_id": {
732+
"type": "string"
733+
}
734+
}
735+
},
736+
"schemas.ProviderResponse": {
737+
"type": "object",
738+
"properties": {
739+
"message": {
740+
"$ref": "#/definitions/schemas.ChatMessage"
741+
},
742+
"responseId": {
743+
"type": "object",
744+
"additionalProperties": {
745+
"type": "string"
746+
}
747+
},
748+
"tokenCount": {
749+
"$ref": "#/definitions/schemas.TokenUsage"
750+
}
751+
}
752+
},
753+
"schemas.TokenUsage": {
754+
"type": "object",
755+
"properties": {
756+
"promptTokens": {
757+
"type": "number"
758+
},
759+
"responseTokens": {
760+
"type": "number"
761+
},
762+
"totalTokens": {
763+
"type": "number"
764+
}
765+
}
766766
}
767767
},
768768
"externalDocs": {

Diff for: docs/swagger.json

+46-46
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@
9595
"in": "body",
9696
"required": true,
9797
"schema": {
98-
"$ref": "#/definitions/schemas.UnifiedChatRequest"
98+
"$ref": "#/definitions/schemas.ChatRequest"
9999
}
100100
}
101101
],
102102
"responses": {
103103
"200": {
104104
"description": "OK",
105105
"schema": {
106-
"$ref": "#/definitions/schemas.UnifiedChatResponse"
106+
"$ref": "#/definitions/schemas.ChatResponse"
107107
}
108108
},
109109
"400": {
@@ -673,49 +673,7 @@
673673
}
674674
}
675675
},
676-
"schemas.OverrideChatRequest": {
677-
"type": "object",
678-
"properties": {
679-
"message": {
680-
"$ref": "#/definitions/schemas.ChatMessage"
681-
},
682-
"model_id": {
683-
"type": "string"
684-
}
685-
}
686-
},
687-
"schemas.ProviderResponse": {
688-
"type": "object",
689-
"properties": {
690-
"message": {
691-
"$ref": "#/definitions/schemas.ChatMessage"
692-
},
693-
"responseId": {
694-
"type": "object",
695-
"additionalProperties": {
696-
"type": "string"
697-
}
698-
},
699-
"tokenCount": {
700-
"$ref": "#/definitions/schemas.TokenUsage"
701-
}
702-
}
703-
},
704-
"schemas.TokenUsage": {
705-
"type": "object",
706-
"properties": {
707-
"promptTokens": {
708-
"type": "number"
709-
},
710-
"responseTokens": {
711-
"type": "number"
712-
},
713-
"totalTokens": {
714-
"type": "number"
715-
}
716-
}
717-
},
718-
"schemas.UnifiedChatRequest": {
676+
"schemas.ChatRequest": {
719677
"type": "object",
720678
"properties": {
721679
"message": {
@@ -732,7 +690,7 @@
732690
}
733691
}
734692
},
735-
"schemas.UnifiedChatResponse": {
693+
"schemas.ChatResponse": {
736694
"type": "object",
737695
"properties": {
738696
"cached": {
@@ -760,6 +718,48 @@
760718
"type": "string"
761719
}
762720
}
721+
},
722+
"schemas.OverrideChatRequest": {
723+
"type": "object",
724+
"properties": {
725+
"message": {
726+
"$ref": "#/definitions/schemas.ChatMessage"
727+
},
728+
"model_id": {
729+
"type": "string"
730+
}
731+
}
732+
},
733+
"schemas.ProviderResponse": {
734+
"type": "object",
735+
"properties": {
736+
"message": {
737+
"$ref": "#/definitions/schemas.ChatMessage"
738+
},
739+
"responseId": {
740+
"type": "object",
741+
"additionalProperties": {
742+
"type": "string"
743+
}
744+
},
745+
"tokenCount": {
746+
"$ref": "#/definitions/schemas.TokenUsage"
747+
}
748+
}
749+
},
750+
"schemas.TokenUsage": {
751+
"type": "object",
752+
"properties": {
753+
"promptTokens": {
754+
"type": "number"
755+
},
756+
"responseTokens": {
757+
"type": "number"
758+
},
759+
"totalTokens": {
760+
"type": "number"
761+
}
762+
}
763763
}
764764
},
765765
"externalDocs": {

Diff for: docs/swagger.yaml

+31-31
Original file line numberDiff line numberDiff line change
@@ -375,34 +375,7 @@ definitions:
375375
or assistant.
376376
type: string
377377
type: object
378-
schemas.OverrideChatRequest:
379-
properties:
380-
message:
381-
$ref: '#/definitions/schemas.ChatMessage'
382-
model_id:
383-
type: string
384-
type: object
385-
schemas.ProviderResponse:
386-
properties:
387-
message:
388-
$ref: '#/definitions/schemas.ChatMessage'
389-
responseId:
390-
additionalProperties:
391-
type: string
392-
type: object
393-
tokenCount:
394-
$ref: '#/definitions/schemas.TokenUsage'
395-
type: object
396-
schemas.TokenUsage:
397-
properties:
398-
promptTokens:
399-
type: number
400-
responseTokens:
401-
type: number
402-
totalTokens:
403-
type: number
404-
type: object
405-
schemas.UnifiedChatRequest:
378+
schemas.ChatRequest:
406379
properties:
407380
message:
408381
$ref: '#/definitions/schemas.ChatMessage'
@@ -413,7 +386,7 @@ definitions:
413386
override:
414387
$ref: '#/definitions/schemas.OverrideChatRequest'
415388
type: object
416-
schemas.UnifiedChatResponse:
389+
schemas.ChatResponse:
417390
properties:
418391
cached:
419392
type: boolean
@@ -432,6 +405,33 @@ definitions:
432405
router:
433406
type: string
434407
type: object
408+
schemas.OverrideChatRequest:
409+
properties:
410+
message:
411+
$ref: '#/definitions/schemas.ChatMessage'
412+
model_id:
413+
type: string
414+
type: object
415+
schemas.ProviderResponse:
416+
properties:
417+
message:
418+
$ref: '#/definitions/schemas.ChatMessage'
419+
responseId:
420+
additionalProperties:
421+
type: string
422+
type: object
423+
tokenCount:
424+
$ref: '#/definitions/schemas.TokenUsage'
425+
type: object
426+
schemas.TokenUsage:
427+
properties:
428+
promptTokens:
429+
type: number
430+
responseTokens:
431+
type: number
432+
totalTokens:
433+
type: number
434+
type: object
435435
externalDocs:
436436
description: Documentation
437437
url: https://glide.einstack.ai/
@@ -497,14 +497,14 @@ paths:
497497
name: payload
498498
required: true
499499
schema:
500-
$ref: '#/definitions/schemas.UnifiedChatRequest'
500+
$ref: '#/definitions/schemas.ChatRequest'
501501
produces:
502502
- application/json
503503
responses:
504504
"200":
505505
description: OK
506506
schema:
507-
$ref: '#/definitions/schemas.UnifiedChatResponse'
507+
$ref: '#/definitions/schemas.ChatResponse'
508508
"400":
509509
description: Bad Request
510510
schema:

Diff for: pkg/api/http/handlers.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ type Handler = func(c *fiber.Ctx) error
2121
// @Description Talk to different LLMs Chat API via unified endpoint
2222
// @tags Language
2323
// @Param router path string true "Router ID"
24-
// @Param payload body schemas.UnifiedChatRequest true "Request Data"
24+
// @Param payload body schemas.ChatRequest true "Request Data"
2525
// @Accept json
2626
// @Produce json
27-
// @Success 200 {object} schemas.UnifiedChatResponse
27+
// @Success 200 {object} schemas.ChatResponse
2828
// @Failure 400 {object} http.ErrorSchema
2929
// @Failure 404 {object} http.ErrorSchema
3030
// @Router /v1/language/{router}/chat [POST]
3131
func LangChatHandler(routerManager *routers.RouterManager) Handler {
3232
return func(c *fiber.Ctx) error {
3333
// Unmarshal request body
34-
var req *schemas.UnifiedChatRequest
34+
var req *schemas.ChatRequest
3535

3636
err := c.BodyParser(&req)
3737
if err != nil {

0 commit comments

Comments
 (0)