Repository: tmc/langchaingo
Pull request #44 (2023-04-21 10:55:50)

exp: change names of files and start using actual schema
 - Change file names in exp to follow go standard
 - Make exp dependent on the actual schema package
 - Add some comments in exp
 - Change from using reflect.DeepEqual to cmp.Equal in tests in exp
 - Change inputValues and chainValues to map[string]any in exp
 - Remove exp/schema
 - Modify memory interface in schema, changing SaveContext outputs from map[string]string to map[string]any
 - Add doc.go to packages in exp #5 


Patch:
diff --git a/exp/chains/chains.go b/exp/chains/chains.go
index 04de41e1..80c1f2ff 100644
--- a/exp/chains/chains.go
+++ b/exp/chains/chains.go
@@ -1,25 +1,20 @@
 package chains
 
-import "github.com/tmc/langchaingo/exp/memory"
-
-type ChainValues map[string]any
+import "github.com/tmc/langchaingo/schema"
 
 type Chain interface {
-	Call(ChainValues) (ChainValues, error)
-	GetMemory() memory.Memory
+	Call(map[string]any) (map[string]any, error)
+	GetMemory() schema.Memory
 }
 
-func Call(c Chain, inputValues map[string]any) (ChainValues, error) {
-	fullValues := make(ChainValues, 0)
+func Call(c Chain, inputValues map[string]any) (map[string]any, error) {
+	fullValues := make(map[string]any, 0)
 
 	for key, value := range inputValues {
 		fullValues[key] = value
 	}
 
-	newValues, err := c.GetMemory().LoadMemoryVariables(inputValues)
-	if err != nil {
-		return ChainValues{}, err
-	}
+	newValues := c.GetMemory().LoadMemoryVariables(inputValues)
 
 	for key, value := range newValues {
 		fullValues[key] = value
@@ -27,12 +22,12 @@ func Call(c Chain, inputValues map[string]any) (ChainValues, error) {
 
 	outputValues, err := c.Call(fullValues)
 	if err != nil {
-		return ChainValues{}, err
+		return map[string]any{}, err
 	}
 
-	err = c.GetMemory().SaveContext(inputValues, memory.InputValues(outputValues))
+	err = c.GetMemory().SaveContext(inputValues, outputValues)
 	if err != nil {
-		return ChainValues{}, err
+		return map[string]any{}, err
 	}
 
 	return outputValues, nil
diff --git a/exp/chains/doc.go b/exp/chains/doc.go
new file mode 100644
index 00000000..e1c73d97
--- /dev/null
+++ b/exp/chains/doc.go
@@ -0,0 +1,2 @@
+// Package chains contains a standard interface for chains and a number of built in chains
+package chains
diff --git a/exp/chains/llmChain.go b/exp/chains/llm_chain.go
similarity index 64%
rename from exp/chains/llmChain.go
rename to exp/chains/llm_chain.go
index 42b71e6e..43b0cdeb 100644
--- a/exp/chains/llmChain.go
+++ b/exp/chains/llm_chain.go
@@ -2,17 +2,18 @@ package chains
 
 import (
 	"github.com/tmc/langchaingo/exp/memory"
-	"github.com/tmc/langchaingo/exp/outputParsers"
+	"github.com/tmc/langchaingo/exp/output_parsers"
 	"github.com/tmc/langchaingo/exp/prompts"
 	"github.com/tmc/langchaingo/llms"
+	"github.com/tmc/langchaingo/schema"
 )
 
 type LLMChain struct {
 	prompt       prompts.Template
 	llm          llms.LLM
 	OutputKey    string
-	Memory       memory.Memory
-	OutputParser outputParsers.OutputParser
+	Memory       schema.Memory
+	OutputParser output_parsers.OutputParser
 }
 
 func NewLLMChain(llm llms.LLM, prompt prompts.Template) LLMChain {
@@ -20,22 +21,22 @@ func NewLLMChain(llm llms.LLM, prompt prompts.Template) LLMChain {
 		prompt:       prompt,
 		llm:          llm,
 		OutputKey:    "text",
-		OutputParser: outputParsers.NewEmptyOutputParser(),
+		OutputParser: output_parsers.NewEmptyOutputParser(),
 		Memory:       memory.NewEmptyMemory(),
 	}
 
 	return chain
 }
 
-func (c LLMChain) GetMemory() memory.Memory {
+func (c LLMChain) GetMemory() schema.Memory {
 	return c.Memory
 }
 
-func (c LLMChain) Call(values ChainValues) (ChainValues, error) {
+func (c LLMChain) Call(values map[string]any) (map[string]any, error) {
 	var stop []string
 	promptValue, err := c.prompt.FormatPromptValue(values)
 	if err != nil {
-		return ChainValues{}, err
+		return map[string]any{}, err
 	}
 
 	if stopVal, ok := values["stop"].([]string); ok {
@@ -44,13 +45,13 @@ func (c LLMChain) Call(values ChainValues) (ChainValues, error) {
 
 	generations, err := c.llm.Generate([]string{promptValue.String()}, stop)
 	if err != nil {
-		return ChainValues{}, err
+		return map[string]any{}, err
 	}
 
 	finalOutput, err := c.OutputParser.ParseWithPrompt(generations[0].Text, promptValue)
 	if err != nil {
-		return ChainValues{}, err
+		return map[string]any{}, err
 	}
 
-	return ChainValues{c.OutputKey: finalOutput}, nil
+	return map[string]any{c.OutputKey: finalOutput}, nil
 }
diff --git a/exp/chains/llmChain_test.go b/exp/chains/llm_chain_test.go
similarity index 100%
rename from exp/chains/llmChain_test.go
rename to exp/chains/llm_chain_test.go
diff --git a/exp/chains/retrivalQAChain.go b/exp/chains/retrival_qa_chain.go
similarity index 88%
rename from exp/chains/retrivalQAChain.go
rename to exp/chains/retrival_qa_chain.go
index 5f5d9daa..0ade508a 100644
--- a/exp/chains/retrivalQAChain.go
+++ b/exp/chains/retrival_qa_chain.go
@@ -4,8 +4,8 @@ import (
 	"fmt"
 
 	"github.com/tmc/langchaingo/exp/memory"
-	"github.com/tmc/langchaingo/exp/schema"
 	"github.com/tmc/langchaingo/llms"
+	"github.com/tmc/langchaingo/schema"
 )
 
 type RetrievalQAChain struct {
@@ -27,7 +27,7 @@ func NewRetrievalQAChainFromLLM(llm llms.LLM, retriever schema.Retriever) Retrie
 	}
 }
 
-func (c RetrievalQAChain) Call(values ChainValues) (ChainValues, error) {
+func (c RetrievalQAChain) Call(values map[string]any) (map[string]any, error) {
 	queryAny, ok := values[c.InputKey]
 	if !ok {
 		return map[string]any{}, fmt.Errorf("Input key %s not found", c.InputKey)
@@ -60,6 +60,6 @@ func (c RetrievalQAChain) Call(values ChainValues) (ChainValues, error) {
 	return result, nil
 }
 
-func (c RetrievalQAChain) GetMemory() memory.Memory {
+func (c RetrievalQAChain) GetMemory() schema.Memory {
 	return memory.NewEmptyMemory()
 }
diff --git a/exp/chains/stuffDocumentsChain.go b/exp/chains/stuff_documents_chain.go
similarity index 83%
rename from exp/chains/stuffDocumentsChain.go
rename to exp/chains/stuff_documents_chain.go
index c4bbce70..1cdbeedc 100644
--- a/exp/chains/stuffDocumentsChain.go
+++ b/exp/chains/stuff_documents_chain.go
@@ -5,8 +5,8 @@ import (
 
 	"github.com/tmc/langchaingo/exp/memory"
 	"github.com/tmc/langchaingo/exp/prompts"
-	"github.com/tmc/langchaingo/exp/schema"
 	"github.com/tmc/langchaingo/llms"
+	"github.com/tmc/langchaingo/schema"
 )
 
 type StuffDocumentsChain struct {
@@ -25,15 +25,15 @@ func NewStuffDocumentsChain(llmChain LLMChain) StuffDocumentsChain {
 	}
 }
 
-func (c StuffDocumentsChain) Call(values ChainValues) (ChainValues, error) {
+func (c StuffDocumentsChain) Call(values map[string]any) (map[string]any, error) {
 	docsAny, ok := values[c.InputKey]
 	if !ok {
-		return ChainValues{}, fmt.Errorf("Document key %s not found", c.InputKey)
+		return map[string]any{}, fmt.Errorf("Document key %s not found", c.InputKey)
 	}
 
 	docs, ok := docsAny.([]schema.Document)
 	if !ok {
-		return ChainValues{}, fmt.Errorf("Document key %s not of type []Document", c.InputKey)
+		return map[string]any{}, fmt.Errorf("Document key %s not of type []Document", c.InputKey)
 	}
 
 	text := ""
@@ -50,7 +50,7 @@ func (c StuffDocumentsChain) Call(values ChainValues) (ChainValues, error) {
 	return Call(c.llmChain, inputValues)
 }
 
-func (c StuffDocumentsChain) GetMemory() memory.Memory {
+func (c StuffDocumentsChain) GetMemory() schema.Memory {
 	return memory.NewEmptyMemory()
 }
 
diff --git a/exp/documentLoaders/documentLoaders.go b/exp/documentLoaders/documentLoaders.go
deleted file mode 100644
index 33b9d530..00000000
--- a/exp/documentLoaders/documentLoaders.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package documentLoaders
-
-import (
-	"github.com/tmc/langchaingo/exp/schema"
-	"github.com/tmc/langchaingo/exp/textSplitters"
-)
-
-type DocumentLoader interface {
-	Load() ([]schema.Document, error)
-	LoadAndSplit(textSplitters.TextSplitter)
-}
diff --git a/exp/document_loaders/doc.go b/exp/document_loaders/doc.go
new file mode 100644
index 00000000..4a8ab540
--- /dev/null
+++ b/exp/document_loaders/doc.go
@@ -0,0 +1,3 @@
+// Package document loaders includes an interface for loading and splitting documents from a source
+
+package document_loaders
diff --git a/exp/document_loaders/document_loaders.go b/exp/document_loaders/document_loaders.go
new file mode 100644
index 00000000..ad232277
--- /dev/null
+++ b/exp/document_loaders/document_loaders.go
@@ -0,0 +1,14 @@
+package document_loaders
+
+import (
+	"github.com/tmc/langchaingo/exp/text_splitters"
+	"github.com/tmc/langchaingo/schema"
+)
+
+// Document loader is the interface for loading and splitting documents from a source
+type DocumentLoader interface {
+	// Loads from source and returns documents
+	Load() ([]schema.Document, error)
+	// Loads from source and splits using a text splitter
+	LoadAndSplit(text_splitters.TextSplitter)
+}
diff --git a/exp/documentLoaders/testdata/test.txt b/exp/document_loaders/testdata/test.txt
similarity index 100%
rename from exp/documentLoaders/testdata/test.txt
rename to exp/document_loaders/testdata/test.txt
diff --git a/exp/documentLoaders/textLoader.go b/exp/document_loaders/text_loader.go
similarity index 67%
rename from exp/documentLoaders/textLoader.go
rename to exp/document_loaders/text_loader.go
index ffb7e18e..99f7f82d 100644
--- a/exp/documentLoaders/textLoader.go
+++ b/exp/document_loaders/text_loader.go
@@ -1,10 +1,10 @@
-package documentLoaders
+package document_loaders
 
 import (
 	"os"
 
-	"github.com/tmc/langchaingo/exp/schema"
-	"github.com/tmc/langchaingo/exp/textSplitters"
+	"github.com/tmc/langchaingo/exp/text_splitters"
+	"github.com/tmc/langchaingo/schema"
 )
 
 type TextLoader struct {
@@ -32,11 +32,11 @@ func (l TextLoader) Load() ([]schema.Document, error) {
 	}, nil
 }
 
-func (l TextLoader) LoadAndSplit(splitter textSplitters.TextSplitter) ([]schema.Document, error) {
+func (l TextLoader) LoadAndSplit(splitter text_splitters.TextSplitter) ([]schema.Document, error) {
 	docs, err := l.Load()
 	if err != nil {
 		return []schema.Document{}, err
 	}
 
-	return textSplitters.SplitDocuments(splitter, docs)
+	return text_splitters.SplitDocuments(splitter, docs)
 }
diff --git a/exp/embeddings/doc.go b/exp/embeddings/doc.go
new file mode 100644
index 00000000..a5d11239
--- /dev/null
+++ b/exp/embeddings/doc.go
@@ -0,0 +1,2 @@
+// Package embeddings contains a standard interface and implementations for creating numerical representation of textual data
+package embeddings
diff --git a/exp/embeddings/embeddings.go b/exp/embeddings/embeddings.go
index 7aab20a2..018d32e8 100644
--- a/exp/embeddings/embeddings.go
+++ b/exp/embeddings/embeddings.go
@@ -1,6 +1,9 @@
 package embeddings
 
+// Embeddings is the interface for creating vector embeddings from texts
 type Embeddings interface {
+	// Returns vector for each text
 	EmbedDocuments(texts []string) ([][]float64, error)
+	// Embeds a single text
 	EmbedQuery(text string) ([]float64, error)
 }
diff --git a/exp/memory/bufferMemory.go b/exp/memory/buffer_memory.go
similarity index 72%
rename from exp/memory/bufferMemory.go
rename to exp/memory/buffer_memory.go
index 80d01ec2..731d5f6d 100644
--- a/exp/memory/bufferMemory.go
+++ b/exp/memory/buffer_memory.go
@@ -1,5 +1,6 @@
 package memory
 
+// BufferMemory is a simple form of memory that remembers previous conversational back and forths directly.
 type BufferMemory struct {
 	ChatHistory    *ChatMessageHistory
 	ReturnMessages bool
@@ -10,7 +11,7 @@ type BufferMemory struct {
 	MemoryKey      string
 }
 
-func (m BufferMemory) SaveContext(inputValues InputValues, outputValues InputValues) error {
+func (m BufferMemory) SaveContext(inputValues map[string]any, outputValues map[string]any) error {
 	userInputValue, err := getInputValue(inputValues, m.InputKey)
 	if err != nil {
 		return err
@@ -28,16 +29,16 @@ func (m BufferMemory) SaveContext(inputValues InputValues, outputValues InputVal
 	return nil
 }
 
-func (m BufferMemory) LoadMemoryVariables(inputValuesGiven InputValues) (InputValues, error) {
+func (m BufferMemory) LoadMemoryVariables(inputValuesGiven map[string]any) map[string]any {
 	if m.ReturnMessages {
-		return InputValues{
+		return map[string]any{
 			m.MemoryKey: m.ChatHistory.messages,
-		}, nil
+		}
 	}
 
-	return InputValues{
+	return map[string]any{
 		m.MemoryKey: getBufferString(m.ChatHistory.messages, m.HumanPrefix, m.AiPrefix),
-	}, nil
+	}
 }
 
 func NewBufferMemory() BufferMemory {
diff --git a/exp/memory/chatMemory.go b/exp/memory/chat_memory.go
similarity index 89%
rename from exp/memory/chatMemory.go
rename to exp/memory/chat_memory.go
index b52a051d..76146582 100644
--- a/exp/memory/chatMemory.go
+++ b/exp/memory/chat_memory.go
@@ -1,6 +1,6 @@
 package memory
 
-import "github.com/tmc/langchaingo/exp/schema"
+import "github.com/tmc/langchaingo/schema"
 
 type ChatMessageHistory struct {
 	messages []schema.ChatMessage
@@ -8,7 +8,7 @@ type ChatMessageHistory struct {
 
 func (h *ChatMessageHistory) GetMessages() []schema.ChatMessage { return h.messages }
 func (h *ChatMessageHistory) AddAiMessage(text string) {
-	h.messages = append(h.messages, schema.AiChatMessage{Text: text})
+	h.messages = append(h.messages, schema.AIChatMessage{Text: text})
 }
 func (h *ChatMessageHistory) AddUserMessage(text string) {
 	h.messages = append(h.messages, schema.HumanChatMessage{Text: text})
diff --git a/exp/memory/doc.go b/exp/memory/doc.go
new file mode 100644
index 00000000..2df8f9c2
--- /dev/null
+++ b/exp/memory/doc.go
@@ -0,0 +1,4 @@
+// Package memory contains implementations of the memory interface.
+// Memory is used for storing and retrieving data in the process of a conversation.
+
+package memory
diff --git a/exp/memory/memory.go b/exp/memory/memory.go
index 8b1516dc..f6c9c665 100644
--- a/exp/memory/memory.go
+++ b/exp/memory/memory.go
@@ -4,17 +4,10 @@ import (
 	"fmt"
 	"strings"
 
-	"github.com/tmc/langchaingo/exp/schema"
+	"github.com/tmc/langchaingo/schema"
 )
 
-type Memory interface {
-	LoadMemoryVariables(InputValues) (InputValues, error)
-	SaveContext(InputValues, InputValues) error
-}
-
-type InputValues map[string]any
-
-func getInputValue(inputValues InputValues, inputKey string) (string, error) {
+func getInputValue(inputValues map[string]any, inputKey string) (string, error) {
 	if inputKey != "" {
 		inputValue, ok := inputValues[inputKey]
 		if !ok {
@@ -37,7 +30,7 @@ func getInputValue(inputValues InputValues, inputKey string) (string, error) {
 	return "", fmt.Errorf(`input values %v have multiple keys. Specify input key when creating the buffer memory or remove keys`, inputValues)
 }
 
-func getInputValueReturnToString(inputValue interface{}, inputValues InputValues, inputKey string) (string, error) {
+func getInputValueReturnToString(inputValue interface{}, inputValues map[string]any, inputKey string) (string, error) {
 	switch value := inputValue.(type) {
 	case string:
 		return value, nil
@@ -53,12 +46,12 @@ func getBufferString(messages []schema.ChatMessage, humanPrefix, aiPrefix string
 		role := ""
 
 		switch message := messages[i].(type) {
-		case schema.AiChatMessage:
+		case schema.AIChatMessage:
 			role = aiPrefix
 		case schema.HumanChatMessage:
 			role = humanPrefix
 		default:
-			role = message.GetType()
+			role = string(message.GetType())
 
 		}
 
@@ -70,8 +63,19 @@ func getBufferString(messages []schema.ChatMessage, humanPrefix, aiPrefix string
 
 type EmptyMemory struct{}
 
-func (m EmptyMemory) LoadMemoryVariables(InputValues) (InputValues, error) { return InputValues{}, nil }
-func (m EmptyMemory) SaveContext(InputValues, InputValues) error           { return nil }
+func (m EmptyMemory) MemoryVariables() []string {
+	return []string{}
+}
+func (m EmptyMemory) LoadMemoryVariables(map[string]any) map[string]any {
+	return map[string]any{}
+}
+func (m EmptyMemory) SaveContext(inputs map[string]any, outputs map[string]any) error {
+	return nil
+}
+
+func (m EmptyMemory) Clear() error {
+	return nil
+}
 
 func NewEmptyMemory() EmptyMemory {
 	return EmptyMemory{}
diff --git a/exp/outputParsers/commaSeperatedParser.go b/exp/output_parsers/comma_seperated_parser.go
similarity index 97%
rename from exp/outputParsers/commaSeperatedParser.go
rename to exp/output_parsers/comma_seperated_parser.go
index cc3fc463..c43d49ab 100644
--- a/exp/outputParsers/commaSeperatedParser.go
+++ b/exp/output_parsers/comma_seperated_parser.go
@@ -1,4 +1,4 @@
-package outputParsers
+package output_parsers
 
 import (
 	"strings"
diff --git a/exp/output_parsers/doc.go b/exp/output_parsers/doc.go
new file mode 100644
index 00000000..d3166f6f
--- /dev/null
+++ b/exp/output_parsers/doc.go
@@ -0,0 +1,2 @@
+// Package output parser contains utilities for parsing the output of llms
+package output_parsers
diff --git a/exp/outputParsers/emptyParser.go b/exp/output_parsers/empty_parser.go
similarity index 95%
rename from exp/outputParsers/emptyParser.go
rename to exp/output_parsers/empty_parser.go
index 91a414a6..a4d8be3f 100644
--- a/exp/outputParsers/emptyParser.go
+++ b/exp/output_parsers/empty_parser.go
@@ -1,4 +1,4 @@
-package outputParsers
+package output_parsers
 
 import "github.com/tmc/langchaingo/exp/prompts"
 
diff --git a/exp/outputParsers/outputParsers.go b/exp/output_parsers/output_parsers.go
similarity index 93%
rename from exp/outputParsers/outputParsers.go
rename to exp/output_parsers/output_parsers.go
index fc01f371..cec1840b 100644
--- a/exp/outputParsers/outputParsers.go
+++ b/exp/output_parsers/output_parsers.go
@@ -1,4 +1,4 @@
-package outputParsers
+package output_parsers
 
 import "github.com/tmc/langchaingo/exp/prompts"
 
diff --git a/exp/outputParsers/structuredParser.go b/exp/output_parsers/structured_parser.go
similarity index 98%
rename from exp/outputParsers/structuredParser.go
rename to exp/output_parsers/structured_parser.go
index be3e599c..c1a2d762 100644
--- a/exp/outputParsers/structuredParser.go
+++ b/exp/output_parsers/structured_parser.go
@@ -1,4 +1,4 @@
-package outputParsers
+package output_parsers
 
 import (
 	"encoding/json"
diff --git a/exp/schema/chatMessage.go b/exp/schema/chatMessage.go
deleted file mode 100644
index 8deee4d5..00000000
--- a/exp/schema/chatMessage.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package schema
-
-type ChatMessage interface {
-	GetType() string
-	GetText() string
-}
-
-type AiChatMessage struct {
-	Text string
-}
-
-func (m AiChatMessage) GetType() string { return "ai" }
-func (m AiChatMessage) GetText() string { return m.Text }
-
-type HumanChatMessage struct {
-	Text string
-}
-
-func (m HumanChatMessage) GetType() string { return "human" }
-func (m HumanChatMessage) GetText() string { return m.Text }
-
-type SystemChatMessage struct {
-	Text string
-}
-
-func (m SystemChatMessage) GetType() string { return "system" }
-func (m SystemChatMessage) GetText() string { return m.Text }
diff --git a/exp/schema/documents.go b/exp/schema/documents.go
deleted file mode 100644
index e789d062..00000000
--- a/exp/schema/documents.go
+++ /dev/null
@@ -1,6 +0,0 @@
-package schema
-
-type Document struct {
-	PageContent string
-	Metadata    map[string]any
-}
diff --git a/exp/schema/retrivers.go b/exp/schema/retrivers.go
deleted file mode 100644
index c46462ae..00000000
--- a/exp/schema/retrivers.go
+++ /dev/null
@@ -1,5 +0,0 @@
-package schema
-
-type Retriever interface {
-	GetRelevantDocuments(query string) ([]Document, error)
-}
diff --git a/exp/textSplitters/recursiveCharacter.go b/exp/text_splitters/recursive_character.go
similarity index 98%
rename from exp/textSplitters/recursiveCharacter.go
rename to exp/text_splitters/recursive_character.go
index ae872421..c9160d8b 100644
--- a/exp/textSplitters/recursiveCharacter.go
+++ b/exp/text_splitters/recursive_character.go
@@ -1,4 +1,4 @@
-package textSplitters
+package text_splitters
 
 import (
 	"strings"
diff --git a/exp/textSplitters/textSpliters.go b/exp/text_splitters/text_spliters.go
similarity index 98%
rename from exp/textSplitters/textSpliters.go
rename to exp/text_splitters/text_spliters.go
index bc4c7f30..f122dbe7 100644
--- a/exp/textSplitters/textSpliters.go
+++ b/exp/text_splitters/text_spliters.go
@@ -1,11 +1,11 @@
-package textSplitters
+package text_splitters
 
 import (
 	"fmt"
 	"log"
 	"strings"
 
-	"github.com/tmc/langchaingo/exp/schema"
+	"github.com/tmc/langchaingo/schema"
 )
 
 type TextSplitter interface {
diff --git a/exp/vectorStores/vectorStores.go b/exp/vectorStores/vectorStores.go
deleted file mode 100644
index a69de43d..00000000
--- a/exp/vectorStores/vectorStores.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package vectorStores
-
-import "github.com/tmc/langchaingo/exp/schema"
-
-type VectorStore interface {
-	AddDocuments(documents []schema.Document) error
-	SimilaritySearch(query string, numDocuments int) ([]schema.Document, error)
-}
diff --git a/exp/vector_stores/doc.go b/exp/vector_stores/doc.go
new file mode 100644
index 00000000..061ba1b0
--- /dev/null
+++ b/exp/vector_stores/doc.go
@@ -0,0 +1,2 @@
+// Package vector stores includes an interface for saving and querying documents in the form of vector embeddings
+package vector_stores
diff --git a/exp/vector_stores/pinecone/doc.go b/exp/vector_stores/pinecone/doc.go
new file mode 100644
index 00000000..3f4d86c3
--- /dev/null
+++ b/exp/vector_stores/pinecone/doc.go
@@ -0,0 +1,3 @@
+// Package pinecone contains an implementation of the vectorStore interface using the pinecone rest api
+
+package pinecone
diff --git a/exp/vectorStores/pinecone/internal/pineconeClient/query.go b/exp/vector_stores/pinecone/internal/pineconeClient/query.go
similarity index 100%
rename from exp/vectorStores/pinecone/internal/pineconeClient/query.go
rename to exp/vector_stores/pinecone/internal/pineconeClient/query.go
diff --git a/exp/vectorStores/pinecone/internal/pineconeClient/upsert.go b/exp/vector_stores/pinecone/internal/pineconeClient/upsert.go
similarity index 100%
rename from exp/vectorStores/pinecone/internal/pineconeClient/upsert.go
rename to exp/vector_stores/pinecone/internal/pineconeClient/upsert.go
diff --git a/exp/vectorStores/pinecone/pinecone.go b/exp/vector_stores/pinecone/pinecone.go
similarity index 83%
rename from exp/vectorStores/pinecone/pinecone.go
rename to exp/vector_stores/pinecone/pinecone.go
index 81adb24f..6cd6baeb 100644
--- a/exp/vectorStores/pinecone/pinecone.go
+++ b/exp/vector_stores/pinecone/pinecone.go
@@ -8,25 +8,25 @@ import (
 
 	"github.com/google/uuid"
 	"github.com/tmc/langchaingo/exp/embeddings"
-	"github.com/tmc/langchaingo/exp/schema"
-	"github.com/tmc/langchaingo/exp/vectorStores/pinecone/internal/pineconeClient"
+	"github.com/tmc/langchaingo/exp/vector_stores/pinecone/internal/pineconeClient"
+	"github.com/tmc/langchaingo/schema"
 )
 
 const pineconeEnvVrName = "PINECONE_API_KEY"
 
 var ErrMissingToken = errors.New("missing the Pinecone API key, set it in the PINECONE_API_KEY environment variable")
 
-type Pinecone struct {
+type Client struct {
 	client     pineconeClient.Client
 	embeddings embeddings.Embeddings
 	textKey    string
 }
 
 // Environment for project is found in the pinecone console. Index name must not be larger then 45 characters.
-func NewPinecone(embeddings embeddings.Embeddings, environment, indexName string, dimensions int) (Pinecone, error) {
+func NewPinecone(embeddings embeddings.Embeddings, environment, indexName string, dimensions int) (Client, error) {
 	token := os.Getenv(pineconeEnvVrName)
 	if token == "" {
-		return Pinecone{}, ErrMissingToken
+		return Client{}, ErrMissingToken
 	}
 
 	p, err := pineconeClient.New(
@@ -36,7 +36,7 @@ func NewPinecone(embeddings embeddings.Embeddings, environment, indexName string
 		pineconeClient.WithDimensions(dimensions),
 	)
 
-	return Pinecone{
+	return Client{
 		client:     p,
 		embeddings: embeddings,
 		textKey:    "text",
@@ -44,7 +44,7 @@ func NewPinecone(embeddings embeddings.Embeddings, environment, indexName string
 }
 
 // If the length of the documentIds slice is 0 uuids will be used as ids.
-func (p Pinecone) AddDocuments(documents []schema.Document, documentIds []string, nameSpace string) error {
+func (p Client) AddDocuments(documents []schema.Document, documentIds []string, nameSpace string) error {
 	if len(documentIds) == 0 {
 		for i := 0; i < len(documents); i++ {
 			documentIds = append(documentIds, uuid.New().String())
@@ -84,7 +84,7 @@ func (p Pinecone) AddDocuments(documents []schema.Document, documentIds []string
 	return p.client.Upsert(context.Background(), vectors, nameSpace)
 }
 
-func (p Pinecone) SimilaritySearch(query string, numDocuments int, nameSpace string) ([]schema.Document, error) {
+func (p Client) SimilaritySearch(query string, numDocuments int, nameSpace string) ([]schema.Document, error) {
 	vector, err := p.embeddings.EmbedQuery(query)
 	if err != nil {
 		return []schema.Document{}, err
@@ -116,7 +116,7 @@ func (p Pinecone) SimilaritySearch(query string, numDocuments int, nameSpace str
 	return resultDocuments, nil
 }
 
-func (p Pinecone) ToRetriever(numDocs int, nameSpace string) PineconeRetriever {
+func (p Client) ToRetriever(numDocs int, nameSpace string) PineconeRetriever {
 	return PineconeRetriever{
 		p:       p,
 		numDocs: numDocs,
@@ -124,7 +124,7 @@ func (p Pinecone) ToRetriever(numDocs int, nameSpace string) PineconeRetriever {
 }
 
 type PineconeRetriever struct {
-	p         Pinecone
+	p         Client
 	numDocs   int
 	nameSpace string
 }
diff --git a/exp/vector_stores/vector_stores.go b/exp/vector_stores/vector_stores.go
new file mode 100644
index 00000000..620ef02c
--- /dev/null
+++ b/exp/vector_stores/vector_stores.go
@@ -0,0 +1,9 @@
+package vector_stores
+
+import "github.com/tmc/langchaingo/schema"
+
+// VectorStore is the interface for saving and querying documents in the form of vector embeddings
+type VectorStore interface {
+	AddDocuments(documents []schema.Document) error
+	SimilaritySearch(query string, numDocuments int) ([]schema.Document, error)
+}
diff --git a/schema/memory.go b/schema/memory.go
index 1ae2bf0c..48a58bb3 100644
--- a/schema/memory.go
+++ b/schema/memory.go
@@ -8,7 +8,7 @@ type Memory interface {
 	// If None, return all memories
 	LoadMemoryVariables(inputs map[string]any) map[string]any
 	// Save the context of this model run to memory.
-	SaveContext(inputs map[string]any, outputs map[string]string) error
+	SaveContext(inputs map[string]any, outputs map[string]any) error
 	// Clear memory contents.
 	Clear() error
 }


Test patch:
diff --git a/exp/chains/retrivalQAChain_test.go b/exp/chains/retrival_qa_chain_test.go
similarity index 94%
rename from exp/chains/retrivalQAChain_test.go
rename to exp/chains/retrival_qa_chain_test.go
index a33c326a..b2503cc4 100644
--- a/exp/chains/retrivalQAChain_test.go
+++ b/exp/chains/retrival_qa_chain_test.go
@@ -4,8 +4,8 @@ import (
 	"os"
 	"testing"
 
-	"github.com/tmc/langchaingo/exp/schema"
 	"github.com/tmc/langchaingo/llms/openai"
+	"github.com/tmc/langchaingo/schema"
 )
 
 type testRetriever struct{}
diff --git a/exp/chains/stuffDocumentsChain_test.go b/exp/chains/stuff_documents_chain_test.go
similarity index 95%
rename from exp/chains/stuffDocumentsChain_test.go
rename to exp/chains/stuff_documents_chain_test.go
index a2ff776c..ab50eb08 100644
--- a/exp/chains/stuffDocumentsChain_test.go
+++ b/exp/chains/stuff_documents_chain_test.go
@@ -5,8 +5,8 @@ import (
 	"testing"
 
 	"github.com/tmc/langchaingo/exp/prompts"
-	"github.com/tmc/langchaingo/exp/schema"
 	"github.com/tmc/langchaingo/llms/openai"
+	"github.com/tmc/langchaingo/schema"
 )
 
 func TestStuffDocumentsChain(t *testing.T) {
diff --git a/exp/documentLoaders/textLoader_test.go b/exp/document_loaders/text_loader_test.go
similarity index 86%
rename from exp/documentLoaders/textLoader_test.go
rename to exp/document_loaders/text_loader_test.go
index 4a565b6b..ff1f5cd4 100644
--- a/exp/documentLoaders/textLoader_test.go
+++ b/exp/document_loaders/text_loader_test.go
@@ -1,8 +1,9 @@
-package documentLoaders
+package document_loaders
 
 import (
-	"reflect"
 	"testing"
+
+	"github.com/google/go-cmp/cmp"
 )
 
 func TestTextLoader(t *testing.T) {
@@ -26,7 +27,7 @@ func TestTextLoader(t *testing.T) {
 		"source": "./testdata/test.txt",
 	}
 
-	if !reflect.DeepEqual(docs[0].Metadata, expectedMetadata) {
+	if !cmp.Equal(docs[0].Metadata, expectedMetadata) {
 		t.Errorf("Meta data form text loader not the same as expected. Got:\n %s\nExpect:%s\n", docs[0].Metadata, expectedMetadata)
 	}
 }
diff --git a/exp/memory/bufferMemory_test.go b/exp/memory/buffer_memory_test.go
similarity index 54%
rename from exp/memory/bufferMemory_test.go
rename to exp/memory/buffer_memory_test.go
index 0e5ceea9..67988a9d 100644
--- a/exp/memory/bufferMemory_test.go
+++ b/exp/memory/buffer_memory_test.go
@@ -1,38 +1,34 @@
 package memory
 
 import (
-	"reflect"
 	"testing"
 
-	"github.com/tmc/langchaingo/exp/schema"
+	"github.com/google/go-cmp/cmp"
+	"github.com/tmc/langchaingo/schema"
 )
 
 func TestBufferMemory(t *testing.T) {
 	m := NewBufferMemory()
-	result1, err := m.LoadMemoryVariables(InputValues{})
-	if err != nil {
-		t.Errorf("Unexpected error: %e", err)
-	}
+	result1 := m.LoadMemoryVariables(map[string]any{})
+	expected1 := map[string]any{"history": ""}
 
-	expected1 := InputValues{"history": ""}
-
-	if !reflect.DeepEqual(result1, expected1) {
+	if !cmp.Equal(result1, expected1) {
 		t.Errorf("Empty buffer memory loaded memory variables not equal expected. Got: %v, Wanted: %v", result1, expected1)
 	}
 
-	err = m.SaveContext(InputValues{"foo": "bar"}, InputValues{"bar": "foo"})
+	err := m.SaveContext(map[string]any{"foo": "bar"}, map[string]any{"bar": "foo"})
 	if err != nil {
 		t.Errorf("Unexpected error: %e", err)
 	}
 
-	result2, err := m.LoadMemoryVariables(InputValues{})
+	result2 := m.LoadMemoryVariables(map[string]any{})
 	if err != nil {
 		t.Errorf("Unexpected error: %e", err)
 	}
 
-	expected2 := InputValues{"history": "Human: bar\nAI: foo"}
+	expected2 := map[string]any{"history": "Human: bar\nAI: foo"}
 
-	if !reflect.DeepEqual(result2, expected2) {
+	if !cmp.Equal(result2, expected2) {
 		t.Errorf("Buffer memory with messages loaded memory variables not equal expected. Got: %v, Wanted: %v", result2, expected2)
 	}
 }
@@ -40,23 +36,19 @@ func TestBufferMemory(t *testing.T) {
 func TestBufferMemoryReturnMessage(t *testing.T) {
 	m := NewBufferMemory()
 	m.ReturnMessages = true
-	result1, err := m.LoadMemoryVariables(InputValues{})
-	if err != nil {
-		t.Errorf("Unexpected error: %e", err)
-	}
-
-	expected1 := InputValues{"history": []schema.ChatMessage{}}
+	result1 := m.LoadMemoryVariables(map[string]any{})
+	expected1 := map[string]any{"history": []schema.ChatMessage{}}
 
-	if !reflect.DeepEqual(result1, expected1) {
+	if !cmp.Equal(result1, expected1) {
 		t.Errorf("Empty buffer memory with return messages true loaded memory variables not equal expected. Got: %v, Wanted: %v", result1, expected1)
 	}
 
-	err = m.SaveContext(InputValues{"foo": "bar"}, InputValues{"bar": "foo"})
+	err := m.SaveContext(map[string]any{"foo": "bar"}, map[string]any{"bar": "foo"})
 	if err != nil {
 		t.Errorf("Unexpected error: %e", err)
 	}
 
-	result2, err := m.LoadMemoryVariables(InputValues{})
+	result2 := m.LoadMemoryVariables(map[string]any{})
 	if err != nil {
 		t.Errorf("Unexpected error: %e", err)
 	}
@@ -64,13 +56,13 @@ func TestBufferMemoryReturnMessage(t *testing.T) {
 	expectedChatHistory := NewChatMessageHistory(
 		WithPreviousMessages([]schema.ChatMessage{
 			schema.HumanChatMessage{Text: "bar"},
-			schema.AiChatMessage{Text: "foo"},
+			schema.AIChatMessage{Text: "foo"},
 		}),
 	)
 
-	expected2 := InputValues{"history": expectedChatHistory.GetMessages()}
+	expected2 := map[string]any{"history": expectedChatHistory.GetMessages()}
 
-	if !reflect.DeepEqual(result2, expected2) {
+	if !cmp.Equal(result2, expected2) {
 		t.Errorf("Buffer memory with return messages true and messages loaded memory variables not equal expected. Got: %v, Wanted: %v", result2, expected2)
 	}
 }
@@ -80,17 +72,14 @@ func TestBufferMemoryWithPreLoadedHistory(t *testing.T) {
 	m.ChatHistory = NewChatMessageHistory(
 		WithPreviousMessages([]schema.ChatMessage{
 			schema.HumanChatMessage{Text: "bar"},
-			schema.AiChatMessage{Text: "foo"},
+			schema.AIChatMessage{Text: "foo"},
 		}),
 	)
-	result, err := m.LoadMemoryVariables(InputValues{})
-	if err != nil {
-		t.Errorf("Unexpected error: %e", err)
-	}
 
-	expected := InputValues{"history": "Human: bar\nAI: foo"}
+	result := m.LoadMemoryVariables(map[string]any{})
+	expected := map[string]any{"history": "Human: bar\nAI: foo"}
 
-	if !reflect.DeepEqual(result, expected) {
+	if !cmp.Equal(result, expected) {
 		t.Errorf("Buffer memory with messages pre loaded, loaded memory variables not equal expected. Got: %v, Wanted: %v", result, expected)
 	}
 }
diff --git a/exp/outputParsers/commaSeperatedParser_test.go b/exp/output_parsers/comma_seperated_parser_test.go
similarity index 88%
rename from exp/outputParsers/commaSeperatedParser_test.go
rename to exp/output_parsers/comma_seperated_parser_test.go
index c8b825bc..ad11bc54 100644
--- a/exp/outputParsers/commaSeperatedParser_test.go
+++ b/exp/output_parsers/comma_seperated_parser_test.go
@@ -1,8 +1,9 @@
-package outputParsers
+package output_parsers
 
 import (
-	"reflect"
 	"testing"
+
+	"github.com/google/go-cmp/cmp"
 )
 
 type testCase struct {
@@ -34,7 +35,7 @@ func TestCommaSeparatedListOutputParser(t *testing.T) {
 			t.Logf("Unexpected error %s", err.Error())
 		}
 
-		if !reflect.DeepEqual(output, test.expectedOutput) {
+		if !cmp.Equal(output, test.expectedOutput) {
 			t.Logf("Parsing with comma separated list did not get expected. Got: %v. Expected %v", output, test.expectedOutput)
 		}
 	}
diff --git a/exp/outputParsers/structuredParser_test.go b/exp/output_parsers/structured_parser_test.go
similarity index 90%
rename from exp/outputParsers/structuredParser_test.go
rename to exp/output_parsers/structured_parser_test.go
index a2f6bb98..a67a631d 100644
--- a/exp/outputParsers/structuredParser_test.go
+++ b/exp/output_parsers/structured_parser_test.go
@@ -1,8 +1,9 @@
-package outputParsers
+package output_parsers
 
 import (
-	"reflect"
 	"testing"
+
+	"github.com/google/go-cmp/cmp"
 )
 
 func TestStructuredOutputParserFromNameAndDescription(t *testing.T) {
@@ -23,7 +24,7 @@ func TestStructuredOutputParserFromNameAndDescription(t *testing.T) {
 
 	expectedParsed := map[string]string{"url": "https://google.com"}
 
-	if !reflect.DeepEqual(parsed, expectedParsed) {
+	if !cmp.Equal(parsed, expectedParsed) {
 		t.Errorf("StructuredOutputParser parsing result not equal expected: Got: %v. Expected: %v", parsed, expectedParsed)
 	}
 }
diff --git a/exp/textSplitters/recursiveCharacter_test.go b/exp/text_splitters/recursive_character_test.go
similarity index 92%
rename from exp/textSplitters/recursiveCharacter_test.go
rename to exp/text_splitters/recursive_character_test.go
index ca9aab4d..bc7b2201 100644
--- a/exp/textSplitters/recursiveCharacter_test.go
+++ b/exp/text_splitters/recursive_character_test.go
@@ -1,10 +1,10 @@
-package textSplitters
+package text_splitters
 
 import (
-	"reflect"
 	"testing"
 
-	"github.com/tmc/langchaingo/exp/schema"
+	"github.com/google/go-cmp/cmp"
+	"github.com/tmc/langchaingo/schema"
 )
 
 type test struct {
@@ -81,7 +81,7 @@ func TestRecursiveCharacterSplitter(t *testing.T) {
 			t.Errorf("Unexpected error creating documents with recursive character splitter: %s ", err.Error())
 		}
 
-		if !reflect.DeepEqual(docs, test.expectedDocs) {
+		if !cmp.Equal(docs, test.expectedDocs) {
 			t.Logf("Result creating documents with recursive character splitter not equal expected. \n Got:\n %v \nWant:\n %v \n", docs, test.expectedDocs)
 		}
 	}
diff --git a/exp/vectorStores/pinecone/internal/pineconeClient/createIndex.go b/exp/vector_stores/pinecone/internal/pineconeClient/createIndex.go
similarity index 100%
rename from exp/vectorStores/pinecone/internal/pineconeClient/createIndex.go
rename to exp/vector_stores/pinecone/internal/pineconeClient/createIndex.go
diff --git a/exp/vectorStores/pinecone/internal/pineconeClient/pineconeClient.go b/exp/vector_stores/pinecone/internal/pineconeClient/pinecone_client.go
similarity index 100%
rename from exp/vectorStores/pinecone/internal/pineconeClient/pineconeClient.go
rename to exp/vector_stores/pinecone/internal/pineconeClient/pinecone_client.go
diff --git a/exp/vectorStores/pinecone/internal/pineconeClient/pinecone_test.go b/exp/vector_stores/pinecone/internal/pineconeClient/pinecone_test.go
similarity index 95%
rename from exp/vectorStores/pinecone/internal/pineconeClient/pinecone_test.go
rename to exp/vector_stores/pinecone/internal/pineconeClient/pinecone_test.go
index adac0e04..4663e933 100644
--- a/exp/vectorStores/pinecone/internal/pineconeClient/pinecone_test.go
+++ b/exp/vector_stores/pinecone/internal/pineconeClient/pinecone_test.go
@@ -6,7 +6,7 @@ import (
 	"reflect"
 	"testing"
 
-	"github.com/tmc/langchaingo/exp/vectorStores/pinecone/internal/pineconeClient"
+	"github.com/tmc/langchaingo/exp/vector_stores/pinecone/internal/pineconeClient"
 )
 
 func getEnvironmentAndApiKey(t *testing.T) (string, string) {