From d1c19fc7efd02a22e7f612c0929443f6fc631cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9B=BE=E5=8D=97?= <615883576@qq.com> Date: Tue, 4 Jun 2024 11:52:57 +0800 Subject: [PATCH 1/2] add simple fake api for _ping (#34) --- main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.go b/main.go index 3bae8fe..27ffbc4 100644 --- a/main.go +++ b/main.go @@ -171,6 +171,7 @@ func AuthMiddleware(authToken string) gin.HandlerFunc { } func (s *ProxyService) InitRoutes(e *gin.Engine) { + e.GET("/_ping", s.pong) authToken := s.cfg.AuthToken // replace with your dynamic value as needed if authToken != "" { // 鉴权 @@ -185,6 +186,20 @@ func (s *ProxyService) InitRoutes(e *gin.Engine) { } } +type Pong struct { + Now int `json:"now"` + Status string `json:"status"` + Ns1 string `json:"ns1"` +} + +func (s *ProxyService) pong(c *gin.Context) { + c.JSON(http.StatusOK, Pong{ + Now: time.Now().Second(), + Status: "ok", + Ns1: "200 OK", + }) +} + func (s *ProxyService) completions(c *gin.Context) { ctx := c.Request.Context() From ec57d48ae4c7ee70684c3f4580b2843a9cf23afd Mon Sep 17 00:00:00 2001 From: wozulong <> Date: Thu, 6 Jun 2024 14:55:57 +0800 Subject: [PATCH 2/2] 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()