fix: concurrent map writes due to dig.Container is not thread safe

Signed-off-by: joeyczheng <joeyczheng@tencent.com>
This commit is contained in:
joeyczheng
2026-01-15 17:23:55 +08:00
committed by lyingbug
parent b648bd472c
commit b1633c836a
4 changed files with 52 additions and 63 deletions
+2 -5
View File
@@ -7,7 +7,6 @@ import (
"strings"
"github.com/Tencent/WeKnora/internal/models/utils/ollama"
"github.com/Tencent/WeKnora/internal/runtime"
"github.com/Tencent/WeKnora/internal/types"
)
@@ -87,14 +86,12 @@ type ChatConfig struct {
}
// NewChat 创建聊天实例
func NewChat(config *ChatConfig) (Chat, error) {
func NewChat(config *ChatConfig, ollamaService *ollama.OllamaService) (Chat, error) {
var chat Chat
var err error
switch strings.ToLower(string(config.Source)) {
case string(types.ModelSourceLocal):
runtime.GetContainer().Invoke(func(ollamaService *ollama.OllamaService) {
chat, err = NewOllamaChat(config, ollamaService)
})
chat, err = NewOllamaChat(config, ollamaService)
if err != nil {
return nil, err
}