- Raised the `go` directive from 1.24.1 to 1.26.5 to satisfy pgx/v5 and ollama's minimum Go version requirements and to pick up 15 patched standard library CVEs. - Updated `pgx/v5`, `otel`/`otel/sdk`/`otlptracehttp`, `x/net`, and the AWS `eventstream` protocol package to their latest requested versions. - Remediated govulncheck-flagged CVEs in `grpc`, `x/text`, `x/crypto`, `antchfx/xpath`, AWS SDK `bedrock*`/`s3` services, `etcd/server`, and `mongo-driver` v1/v2. - Fixed ollama's `MainGPU` API type change (`int` -> `*int`) in `llms/ollama/options.go` without breaking the public `WithRunnerMainGPU` signature.
Conversational Memory with SQLite in LangChain
Hello there! 👋 This example demonstrates how to create a conversational AI system with memory persistence using SQLite in Go with the LangChain library. Let's break down what this exciting code does!
What Does This Example Do?
-
Sets up an OpenAI Language Model: It initializes an OpenAI language model to power our conversational AI.
-
Creates a SQLite Database: The code sets up a SQLite database to store conversation history.
-
Implements Conversation Memory: It uses SQLite to maintain a persistent memory of the conversation, allowing the AI to remember previous interactions.
-
Prepares Sample Data: If the database is empty, it inserts a sample message to kickstart the conversation.
-
Runs a Conversation: The example runs a conversation chain, asking the AI a question that requires memory of previous interactions.
Key Components
- SQLite Chat Message History: Uses
sqlite3.NewSqliteChatMessageHistoryto create a chat history stored in SQLite. - Conversation Buffer: Implements
memory.NewConversationBufferto manage the conversation memory. - Conversation Chain: Creates a
chains.NewConversationto handle the flow of the conversation.
How It Works
- The code first checks if there's any existing data in the SQLite database.
- If empty, it inserts a sample message: "Hi there, my name is Murilo!"
- It then asks the AI: "What's my name? How many times did I ask this?"
- The AI responds based on the conversation history stored in the SQLite database.
This example showcases how to create a conversational AI system with persistent memory, allowing for more context-aware and personalized interactions over time!
Feel free to run this example and experiment with different questions to see how the AI remembers and uses previous conversation context! 🚀🤖