mirror of
https://github.com/langgenius/dify-plugin-daemon.git
synced 2026-07-23 02:05:27 -04:00
00730b67c3
- Introduced baseSSEWithSession to streamline session management across various service functions. - Updated InvokeAgentStrategy, InvokeLLM, InvokeTextEmbedding, InvokeRerank, InvokeTTS, InvokeSpeech2Text, InvokeModeration, ValidateProviderCredentials, ValidateModelCredentials, GetTTSModelVoices, GetTextEmbeddingNumTokens, GetAIModelSchema, and GetLLMNumTokens to utilize the new session handling approach, improving code readability and maintainability.
30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
package service
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_daemon"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/core/plugin_daemon/access_types"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/core/session_manager"
|
|
"github.com/langgenius/dify-plugin-daemon/internal/utils/stream"
|
|
"github.com/langgenius/dify-plugin-daemon/pkg/entities/agent_entities"
|
|
"github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
|
|
"github.com/langgenius/dify-plugin-daemon/pkg/entities/requests"
|
|
)
|
|
|
|
func InvokeAgentStrategy(
|
|
r *plugin_entities.InvokePluginRequest[requests.RequestInvokeAgentStrategy],
|
|
ctx *gin.Context,
|
|
max_timeout_seconds int,
|
|
) {
|
|
baseSSEWithSession(
|
|
func(session *session_manager.Session) (*stream.Stream[agent_entities.AgentStrategyResponseChunk], error) {
|
|
return plugin_daemon.InvokeAgentStrategy(session, &r.Data)
|
|
},
|
|
access_types.PLUGIN_ACCESS_TYPE_AGENT_STRATEGY,
|
|
access_types.PLUGIN_ACCESS_ACTION_INVOKE_AGENT_STRATEGY,
|
|
r,
|
|
ctx,
|
|
max_timeout_seconds,
|
|
)
|
|
}
|