cauto 1 年之前
父節點
當前提交
9638ac6182
共有 4 個文件被更改,包括 15 次插入9 次删除
  1. 3 3
      api/v1/Chat.go
  2. 3 3
      internal/controller/chat.go
  3. 7 1
      internal/controller/hello.go
  4. 2 2
      router/router.go

+ 3 - 3
api/v1/Chat.go

@@ -7,14 +7,14 @@ type ChatReq struct {
 	Role           string `json:"role" v:"required"`
 	Content        string `json:"content" v:"required"`
 	ConversationID string `json:"conversation_id"`
-	MessageId      string `json:"message_id,omitempty"`
+	MessageId      string `json:"message_id"`
 }
 
 type ChatRes struct {
 	g.Meta         `mime:"application/json" example:"json"`
-	Text           string `json:"text" `
+	Text           string `json:"text"`
 	ConversationID string `json:"conversation_id"`
-	MessageId      string `json:"message_id,omitempty"`
+	MessageId      string `json:"message_id"`
 }
 
 type ChatStreamReq struct {

+ 3 - 3
internal/controller/chat.go

@@ -21,7 +21,7 @@ type Message struct {
 
 var (
 	Chat     = sChat{}
-	key      = "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"
+	key      = "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"
 	proxyUrl = "127.0.0.1:6153"
 )
 
@@ -34,8 +34,8 @@ func (c *sChat) Chat(ctx context.Context, req *v1.ChatReq) (res *v1.ChatRes, err
 	var chatMessage []gpt.ChatCompletionRequestMessage
 
 	re := g.RequestFromCtx(ctx)
-	ConversationID := res.ConversationID
-	MessageId := res.MessageId
+	ConversationID := req.ConversationID
+	MessageId := req.MessageId
 	chatRequst.Model = gpt.GPT3Dot5Turbo
 	chatRequst.MaxTokens = 1024
 	chatRequst.Temperature = 0

+ 7 - 1
internal/controller/hello.go

@@ -2,6 +2,7 @@ package controller
 
 import (
 	"context"
+	"github.com/gogf/gf/v2/frame/g"
 	"go-gpt/api/v1"
 )
 
@@ -12,6 +13,11 @@ var (
 type cHello struct{}
 
 func (c *cHello) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) {
-
+	re := g.RequestFromCtx(ctx)
+	re.Response.WriteJsonExit(g.Map{
+		"status": 200,
+		"data":   "测试",
+		"msg":    "",
+	})
 	return
 }

+ 2 - 2
router/router.go

@@ -134,14 +134,14 @@ func DomeRouter(group *ghttp.RouterGroup) {
 }
 
 func ChatRouter(group *ghttp.RouterGroup) {
-	group.Middleware(MiddlewareHandlerResponse)
+	//group.Middleware(MiddlewareHandlerResponse)
 	group.Bind(
 		controller.Chat,
 	)
 }
 
 func SessionRouter(group *ghttp.RouterGroup) {
-	group.Middleware(MiddlewareHandlerResponse)
+	//group.Middleware(MiddlewareHandlerResponse)
 	group.Group("/session", func(group *ghttp.RouterGroup) {
 		group.Bind(
 			controller.Session,