From ec57d48ae4c7ee70684c3f4580b2843a9cf23afd Mon Sep 17 00:00:00 2001 From: wozulong <> Date: Thu, 6 Jun 2024 14:55:57 +0800 Subject: [PATCH] a fake api: /models Signed-off-by: wozulong <> --- README.md | 1 + main.go | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/README.md b/README.md index b5e42d7..411a5c6 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ ```json "github.copilot.advanced": { + "debug.overrideCAPIUrl": "http://127.0.0.1:8181", "debug.overrideProxyUrl": "http://127.0.0.1:8181", "debug.chatOverrideProxyUrl": "http://127.0.0.1:8181/v1/chat/completions", "authProvider": "github-enterprise" diff --git a/main.go b/main.go index 27ffbc4..96996c9 100644 --- a/main.go +++ b/main.go @@ -172,6 +172,7 @@ func AuthMiddleware(authToken string) gin.HandlerFunc { func (s *ProxyService) InitRoutes(e *gin.Engine) { e.GET("/_ping", s.pong) + e.GET("/models", s.models) authToken := s.cfg.AuthToken // replace with your dynamic value as needed if authToken != "" { // 鉴权 @@ -200,6 +201,113 @@ func (s *ProxyService) pong(c *gin.Context) { }) } +func (s *ProxyService) models(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{ + "data": []gin.H{ + { + "capabilities": gin.H{ + "family": "gpt-3.5-turbo", + "object": "model_capabilities", + "type": "chat", + }, + "id": "gpt-3.5-turbo", + "name": "GPT 3.5 Turbo", + "object": "model", + "version": "gpt-3.5-turbo-0613", + }, + { + "capabilities": gin.H{ + "family": "gpt-3.5-turbo", + "object": "model_capabilities", + "type": "chat", + }, + "id": "gpt-3.5-turbo-0613", + "name": "GPT 3.5 Turbo (2023-06-13)", + "object": "model", + "version": "gpt-3.5-turbo-0613", + }, + { + "capabilities": gin.H{ + "family": "gpt-4", + "object": "model_capabilities", + "type": "chat", + }, + "id": "gpt-4", + "name": "GPT 4", + "object": "model", + "version": "gpt-4-0613", + }, + { + "capabilities": gin.H{ + "family": "gpt-4", + "object": "model_capabilities", + "type": "chat", + }, + "id": "gpt-4-0613", + "name": "GPT 4 (2023-06-13)", + "object": "model", + "version": "gpt-4-0613", + }, + { + "capabilities": gin.H{ + "family": "gpt-4-turbo", + "object": "model_capabilities", + "type": "chat", + }, + "id": "gpt-4-0125-preview", + "name": "GPT 4 Turbo (2024-01-25 Preview)", + "object": "model", + "version": "gpt-4-0125-preview", + }, + { + "capabilities": gin.H{ + "family": "text-embedding-ada-002", + "object": "model_capabilities", + "type": "embeddings", + }, + "id": "text-embedding-ada-002", + "name": "Embedding V2 Ada", + "object": "model", + "version": "text-embedding-ada-002", + }, + { + "capabilities": gin.H{ + "family": "text-embedding-ada-002", + "object": "model_capabilities", + "type": "embeddings", + }, + "id": "text-embedding-ada-002-index", + "name": "Embedding V2 Ada (Index)", + "object": "model", + "version": "text-embedding-ada-002", + }, + { + "capabilities": gin.H{ + "family": "text-embedding-3-small", + "object": "model_capabilities", + "type": "embeddings", + }, + "id": "text-embedding-3-small", + "name": "Embedding V3 small", + "object": "model", + "version": "text-embedding-3-small", + }, + { + "capabilities": gin.H{ + "family": "text-embedding-3-small", + "object": "model_capabilities", + "type": "embeddings", + }, + "id": "text-embedding-3-small-inference", + "name": "Embedding V3 small (Inference)", + "object": "model", + "version": "text-embedding-3-small", + }, + }, + "object": "list", + }) +} + func (s *ProxyService) completions(c *gin.Context) { ctx := c.Request.Context()