Skip to content

Commit

Permalink
Merge pull request #816 from trheyi/main
Browse files Browse the repository at this point in the history
Refactor Neo API and Enhance Assistant Capabilities (Dev)
  • Loading branch information
trheyi authored Jan 13, 2025
2 parents d7fecbf + 627328b commit 9c7b9cf
Show file tree
Hide file tree
Showing 18 changed files with 1,655 additions and 390 deletions.
15 changes: 8 additions & 7 deletions neo/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/yaoapp/gou/connector"
"github.com/yaoapp/gou/process"
"github.com/yaoapp/yao/helper"
chatctx "github.com/yaoapp/yao/neo/context"
"github.com/yaoapp/yao/neo/message"
"github.com/yaoapp/yao/neo/store"
)
Expand Down Expand Up @@ -173,7 +174,7 @@ func (neo *DSL) handleUpload(c *gin.Context) {
}

// Set the context
ctx, cancel := NewContextWithCancel(sid, c.Query("chat_id"), "")
ctx, cancel := chatctx.NewWithCancel(sid, c.Query("chat_id"), "")
defer cancel()

// Upload the file
Expand Down Expand Up @@ -214,7 +215,7 @@ func (neo *DSL) handleChat(c *gin.Context) {
}

// Set the context with validated chat_id
ctx, cancel := NewContextWithCancel(sid, chatID, c.Query("context"))
ctx, cancel := chatctx.NewWithCancel(sid, chatID, c.Query("context"))
defer cancel()

neo.Answer(ctx, content, c)
Expand Down Expand Up @@ -297,7 +298,7 @@ func (neo *DSL) handleDownload(c *gin.Context) {
}

// Set the context
ctx, cancel := NewContextWithCancel(sid, c.Query("chat_id"), "")
ctx, cancel := chatctx.NewWithCancel(sid, c.Query("chat_id"), "")
defer cancel()

// Download the file
Expand Down Expand Up @@ -537,7 +538,7 @@ func (neo *DSL) handleChatUpdate(c *gin.Context) {

// If content is not empty, Generate the chat title
if body.Content != "" {
ctx, cancel := NewContextWithCancel(sid, c.Query("chat_id"), "")
ctx, cancel := chatctx.NewWithCancel(sid, c.Query("chat_id"), "")
defer cancel()

title, err := neo.GenerateChatTitle(ctx, body.Content, c, true)
Expand Down Expand Up @@ -729,7 +730,7 @@ func (neo *DSL) handleGenerateTitle(c *gin.Context) {
return
}

ctx, cancel := NewContextWithCancel(resp.sid, c.Query("chat_id"), "")
ctx, cancel := chatctx.NewWithCancel(resp.sid, c.Query("chat_id"), "")
defer cancel()

// Use silent mode for regular HTTP requests, streaming for SSE
Expand Down Expand Up @@ -780,7 +781,7 @@ func (neo *DSL) handleGeneratePrompts(c *gin.Context) {
return
}

ctx, cancel := NewContextWithCancel(resp.sid, c.Query("chat_id"), "")
ctx, cancel := chatctx.NewWithCancel(resp.sid, c.Query("chat_id"), "")
defer cancel()

// Use silent mode for regular HTTP requests, streaming for SSE
Expand Down Expand Up @@ -831,7 +832,7 @@ func (neo *DSL) handleGenerateCustom(c *gin.Context) {
return
}

ctx, cancel := NewContextWithCancel(resp.sid, c.Query("chat_id"), "")
ctx, cancel := chatctx.NewWithCancel(resp.sid, c.Query("chat_id"), "")
defer cancel()

// Use silent mode for regular HTTP requests, streaming for SSE
Expand Down
Loading

0 comments on commit 9c7b9cf

Please sign in to comment.