### LangGraphGo Quick Start Example Source: https://github.com/0xdezzy/langgraphgo/blob/main/README.md This Go code snippet demonstrates the basic usage of LangGraphGo to build a simple chatbot. It initializes an OpenAI model, defines nodes for an 'oracle' and an end state, sets up the graph's edges and entry point, compiles the graph, and then invokes it with a user's question. The example shows how to add nodes, define their logic using a provided model, and connect them to form a runnable graph. ```go import ( "context" "errors" "fmt" "testing" "github.com/tmc/langchaingo/llms" "github.com/tmc/langchaingo/llms/openai" "github.com/tmc/langchaingo/schema" "github.com/tmc/langgraphgo/graph" ) func main() { model, err := openai.New() if err != nil { panic(err) } g := graph.NewMessageGraph() g.AddNode("oracle", func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) { r, err := model.GenerateContent(ctx, state, llms.WithTemperature(0.0)) if err != nil { return nil, err } return append(state, llms.TextParts(schema.ChatMessageTypeAI, r.Choices[0].Content), ), nil }) g.AddNode(graph.END, func(ctx context.Context, state []llms.MessageContent) ([]llms.MessageContent, error) { return state, nil }) g.AddEdge("oracle", graph.END) g.SetEntryPoint("oracle") runnable, err := g.Compile() if err != nil { panic(err) } ctx := context.Background() // Let's run it! res, err := runnable.Invoke(ctx, []llms.MessageContent{ llms.TextParts(schema.ChatMessageTypeHuman, "What is 1 + 1?"), }) if err != nil { panic(err) } fmt.Println(res) // Output: // [{human [{What is 1 + 1?}]} {ai [{1 + 1 equals 2.}]}] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.