-
-
Notifications
You must be signed in to change notification settings - Fork 735
/
Copy pathmain.go
48 lines (42 loc) · 1.13 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"context"
"fmt"
"github.com/getzep/zep-go"
zepClient "github.com/getzep/zep-go/client"
zepOption "github.com/getzep/zep-go/option"
"github.com/tmc/langchaingo/chains"
"github.com/tmc/langchaingo/llms/openai"
zepLangchainMemory "github.com/tmc/langchaingo/memory/zep"
"os"
)
func main() {
ctx := context.Background()
client := zepClient.NewClient(zepOption.WithAPIKey(os.Getenv("ZEP_API_KEY")))
sessionID := os.Getenv("ZEP_SESSION_ID")
llm, err := openai.New()
if err != nil {
fmt.Printf("Error: %s\n", err)
}
c := chains.NewConversation(
llm,
zepLangchainMemory.NewMemory(
client,
sessionID,
zepLangchainMemory.WithMemoryType(zep.MemoryGetRequestMemoryTypePerpetual),
zepLangchainMemory.WithReturnMessages(true),
zepLangchainMemory.WithAIPrefix("Robot"),
zepLangchainMemory.WithHumanPrefix("Joe"),
),
)
res, err := chains.Run(ctx, c, "Hi! I'm John Doe")
if err != nil {
fmt.Printf("Error: %s\n", err)
}
fmt.Printf("Response: %s\n", res)
res, err = chains.Run(ctx, c, "What is my name?")
if err != nil {
fmt.Printf("Error: %s\n", err)
}
fmt.Printf("Response: %s\n", res)
}