feat(plugin): append special headers (agentId, userId, conversationId and logId) to plugin http request, which can be used by plugin server (#2191)
This commit is contained in:
@ -19,6 +19,7 @@ package middleware
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -84,7 +85,7 @@ func AccessLogMW() app.HandlerFunc {
|
||||
func SetLogIDMW() app.HandlerFunc {
|
||||
return func(ctx context.Context, c *app.RequestContext) {
|
||||
logID := uuid.New().String()
|
||||
ctx = context.WithValue(ctx, "log-id", logID)
|
||||
ctx = context.WithValue(ctx, consts.CtxLogIDKey, logID)
|
||||
|
||||
c.Header("X-Log-ID", logID)
|
||||
c.Next(ctx)
|
||||
|
||||
@ -24,6 +24,9 @@ type ExecuteToolOption struct {
|
||||
ToolVersion string
|
||||
Operation *Openapi3Operation
|
||||
InvalidRespProcessStrategy InvalidResponseProcessStrategy
|
||||
|
||||
AgentID int64
|
||||
ConversationID int64
|
||||
}
|
||||
|
||||
type ExecuteToolOpt func(o *ExecuteToolOption)
|
||||
@ -65,3 +68,10 @@ func WithAutoGenRespSchema() ExecuteToolOpt {
|
||||
o.AutoGenRespSchema = true
|
||||
}
|
||||
}
|
||||
|
||||
func WithPluginHTTPHeader(agentID, conversationID int64) ExecuteToolOpt {
|
||||
return func(o *ExecuteToolOption) {
|
||||
o.AgentID = agentID
|
||||
o.ConversationID = conversationID
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,6 +112,8 @@ type ExecuteRequest struct {
|
||||
History []*schema.Message
|
||||
ResumeInfo *InterruptInfo
|
||||
PreCallTools []*agentrun.ToolsRetriever
|
||||
|
||||
ConversationID int64
|
||||
}
|
||||
|
||||
type AgentIdentity struct {
|
||||
|
||||
Reference in New Issue
Block a user