examples/tutorial-basic-chat-app/README.md
This is the complete example implementation for the Basic Chat Application Tutorial. It demonstrates how to build a chat application using LangChainGo, progressing from a simple implementation to an advanced one with conversation memory and chains.
Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY="your-api-key-here"
This example includes implementations of all steps from the tutorial:
Sends a single message to the LLM and prints the response.
go run . step3
# or
go run . basic
Interactive chat session without memory (each message is independent).
go run . step4
# or
go run . interactive
Interactive chat that remembers the conversation history.
go run . step5
# or
go run . memory
Full-featured chat using chains with automatic memory management.
go run . step6
# or
go run . advanced
# or just run without arguments (default)
go run .
main.go - Complete implementation with all stepsstep3_basic.go - Basic chat implementation (build tag: example)step4_interactive.go - Interactive chat implementation (build tag: example)step5_memory.go - Chat with memory implementation (build tag: example)step6_advanced.go - Advanced chat with chains (build tag: example)This example implements the tutorial from: Building a Basic Chat Application
You can customize the behavior by modifying:
openai.New() to use different modelsmemory.NewConversationBuffer() with other memory types$ go run .
=== Step 6: Advanced Chat with Chains ===
Advanced Chat Application (type 'quit' to exit)
----------------------------------------
You: Hello! Who are you?
AI: Hello! I'm an AI assistant created to help answer questions and have conversations. I'm here to provide helpful, accurate, and friendly responses to whatever you'd like to discuss. How can I assist you today?
You: Can you remember what I just asked?
AI: Yes, I can remember our conversation! You just asked me "Hello! Who are you?" and I introduced myself as an AI assistant who is here to help answer questions and have conversations with you.
You: quit
Goodbye!