Open deweizhang12138 opened 1 month ago
this are correct code
package main
import (
"fmt"
"github.com/tmc/langchaingo/prompts"
)
func main() {
prompt := prompts.NewChatPromptTemplate([]prompts.MessageFormatter{
prompts.NewSystemMessagePromptTemplate(
"你是一个只能翻译的文本引擎,不需要不需要进行解释。", nil),
prompts.NewHumanMessagePromptTemplate(
`翻译这段文字到 {{.outputLang}}: {{.text}}`, []string{"outputLang", "text"}),
})
vals := map[string]any{
"outputLang": "英文", // Corrected key here to match template usage
"text": "今天天气真不错",
}
fmt.Println(vals)
messages, err := prompt.FormatMessages(vals)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(messages)
}
@deweizhang12138 ?
hello, I use code : `package main
import ( "context" "fmt"
)
func main() {
}`
messages, err := prompt.FormatMessages(vals) have a bug:
`panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7a81c7]
goroutine 1 [running]: github.com/tmc/langchaingo/prompts.ChatPromptTemplate.Format({{0xc00003ff18?, 0xc00011c020?, 0xc00003ff08?}, 0x0?}, 0x1?) /home/dewei/go/pkg/mod/github.com/tmc/langchaingo@v0.1.9/prompts/chat_prompt_template.go:45 +0x27 main.main() /home/dewei/workspace/test/gollama/main.go:34 +0x35b exit status 2 `
help me please