Skip to content

Commit

Permalink
#51: Added the new lang routers API
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-glushko committed Jan 1, 2024
1 parent 96ad317 commit 7229e73
Show file tree
Hide file tree
Showing 13 changed files with 501 additions and 35 deletions.
21 changes: 21 additions & 0 deletions docs/api/[Lang] Router List.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: [Lang] Router List
type: http
seq: 3
}

get {
url: {{base_url}}/v1/language/
body: json
auth: none
}

body:json {
{
"message": {
"role": "user",
"content": "How are you doing?"
},
"messageHistory": []
}
}
155 changes: 155 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ const docTemplate = `{
}
}
},
"/v1/language/": {
"get": {
"description": "Retrieve list of configured language routers and their configurations",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Language"
],
"summary": "Language Router List",
"operationId": "glide-language-routers",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/http.RouterListSchema"
}
}
}
}
},
"/v1/language/{router}/chat": {
"post": {
"description": "Talk to different LLMs Chat API via unified endpoint",
Expand Down Expand Up @@ -117,6 +141,128 @@ const docTemplate = `{
}
}
},
"http.RouterListSchema": {
"type": "object",
"properties": {
"routers": {
"type": "array",
"items": {
"$ref": "#/definitions/routers.LangRouterConfig"
}
}
}
},
"openai.Config": {
"type": "object",
"required": [
"apiKey"
],
"properties": {
"apiKey": {
"type": "string"
},
"baseUrl": {
"type": "string"
},
"chatEndpoint": {
"type": "string"
},
"defaultParams": {
"$ref": "#/definitions/openai.Params"
},
"model": {
"type": "string"
}
}
},
"openai.Params": {
"type": "object",
"properties": {
"frequency_penalty": {
"type": "integer"
},
"logit_bias": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"max_tokens": {
"type": "integer"
},
"n": {
"type": "integer"
},
"presence_penalty": {
"type": "integer"
},
"response_format": {
"description": "TODO: should this be a part of the chat request API?"
},
"seed": {
"type": "integer"
},
"stop": {
"type": "array",
"items": {
"type": "string"
}
},
"temperature": {
"type": "number"
},
"tool_choice": {},
"tools": {
"type": "array",
"items": {
"type": "string"
}
},
"top_p": {
"type": "number"
},
"user": {
"type": "string"
}
}
},
"providers.LangModelConfig": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"id": {
"type": "string"
},
"openai": {
"$ref": "#/definitions/openai.Config"
},
"timeout": {
"type": "integer"
}
}
},
"routers.LangRouterConfig": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"models": {
"type": "array",
"items": {
"$ref": "#/definitions/providers.LangModelConfig"
}
},
"routers": {
"type": "string"
},
"strategy": {
"$ref": "#/definitions/strategy.RoutingStrategy"
}
}
},
"schemas.ChatChoice": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -202,6 +348,15 @@ const docTemplate = `{
"type": "number"
}
}
},
"strategy.RoutingStrategy": {
"type": "string",
"enum": [
"priority"
],
"x-enum-varnames": [
"Priority"
]
}
}
}`
Expand Down
155 changes: 155 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@
}
}
},
"/v1/language/": {
"get": {
"description": "Retrieve list of configured language routers and their configurations",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Language"
],
"summary": "Language Router List",
"operationId": "glide-language-routers",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/http.RouterListSchema"
}
}
}
}
},
"/v1/language/{router}/chat": {
"post": {
"description": "Talk to different LLMs Chat API via unified endpoint",
Expand Down Expand Up @@ -114,6 +138,128 @@
}
}
},
"http.RouterListSchema": {
"type": "object",
"properties": {
"routers": {
"type": "array",
"items": {
"$ref": "#/definitions/routers.LangRouterConfig"
}
}
}
},
"openai.Config": {
"type": "object",
"required": [
"apiKey"
],
"properties": {
"apiKey": {
"type": "string"
},
"baseUrl": {
"type": "string"
},
"chatEndpoint": {
"type": "string"
},
"defaultParams": {
"$ref": "#/definitions/openai.Params"
},
"model": {
"type": "string"
}
}
},
"openai.Params": {
"type": "object",
"properties": {
"frequency_penalty": {
"type": "integer"
},
"logit_bias": {
"type": "object",
"additionalProperties": {
"type": "number"
}
},
"max_tokens": {
"type": "integer"
},
"n": {
"type": "integer"
},
"presence_penalty": {
"type": "integer"
},
"response_format": {
"description": "TODO: should this be a part of the chat request API?"
},
"seed": {
"type": "integer"
},
"stop": {
"type": "array",
"items": {
"type": "string"
}
},
"temperature": {
"type": "number"
},
"tool_choice": {},
"tools": {
"type": "array",
"items": {
"type": "string"
}
},
"top_p": {
"type": "number"
},
"user": {
"type": "string"
}
}
},
"providers.LangModelConfig": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"id": {
"type": "string"
},
"openai": {
"$ref": "#/definitions/openai.Config"
},
"timeout": {
"type": "integer"
}
}
},
"routers.LangRouterConfig": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"models": {
"type": "array",
"items": {
"$ref": "#/definitions/providers.LangModelConfig"
}
},
"routers": {
"type": "string"
},
"strategy": {
"$ref": "#/definitions/strategy.RoutingStrategy"
}
}
},
"schemas.ChatChoice": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -199,6 +345,15 @@
"type": "number"
}
}
},
"strategy.RoutingStrategy": {
"type": "string",
"enum": [
"priority"
],
"x-enum-varnames": [
"Priority"
]
}
}
}
Loading

0 comments on commit 7229e73

Please sign in to comment.