Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for VectorStoreRetrieverMemory #54

Closed
davidmigloz opened this issue Jun 26, 2023 · 6 comments · Fixed by #75
Closed

Add support for VectorStoreRetrieverMemory #54

davidmigloz opened this issue Jun 26, 2023 · 6 comments · Fixed by #75
Assignees
Labels
c:memory Memory in chain. f:good first issue Good for newcomers t:enhancement New feature or request
Milestone

Comments

@davidmigloz
Copy link
Owner

davidmigloz commented Jun 26, 2023

https://python.langchain.com/docs/modules/memory/how_to/vectorstore_retriever_memory

@davidmigloz davidmigloz added t:enhancement New feature or request c:memory Memory in chain. labels Jun 26, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in LangChain.dart Jun 26, 2023
@davidmigloz davidmigloz added the f:good first issue Good for newcomers label Jun 27, 2023
@davidmigloz
Copy link
Owner Author

@dileep9490 here you have some resources that should help you to implement it:

Dependencies:

  • VectorStoreRetriever (already implemented)
  • BaseMemory(already implemented)

Sample code that we should be able to run when it's implemented:

final embeddings = OpenAIEmbeddings(apiKey: openaiApiKey);
final vectorStore = MemoryVectorStore(embeddings: embeddings);

final memory = VectorStoreRetrieverMemory(retriever: vectorStore.asRetriever());

memory.saveContext(
  inputValues: {
    'foo': 'bar2',
    'bar': 'foo2',
  },
  outputValues: {
    'foo': 'bar',
  },
);

final memories = await memory.loadMemoryVariables();
print(memories);

@dileep9490
Copy link
Contributor

@davidmigloz can you assign me this issue

@davidmigloz davidmigloz moved this from 📋 Backlog to 🏗 In Progress in LangChain.dart Jul 8, 2023
@dileep9490
Copy link
Contributor

@davidmigloz how can i get the test data? the type script tests are using TensorFlow embeddings

@davidmigloz
Copy link
Owner Author

You can use OpenAIEmbeddings instead that it's already implemented.

@dileep9490
Copy link
Contributor

@davidmigloz that requires my OpenAI API key right if so i'm having some issues with it? or is there any data available?

@davidmigloz
Copy link
Owner Author

yes, it requires your OpenAI API key.

To add data to the VectorStoreRetrieverMemory you have to call the saveContext method (you can check the example from the previous comment).

Then when you call memory.loadMemoryVariables(values) it should return the relevant Documents from the vector store.

Another option if you don't want to use OpenAI API is to use a local embedding model using https://www.premai.io/#PremApp. You can still use OpenAIEmbeddings wrapper, but specifying client=OpenAIClient.local('http://localhost:8000') (replace 8000 with the port where your PremApp is running the model).

davidmigloz added a commit that referenced this issue Jul 26, 2023
@davidmigloz davidmigloz added this to the v0.0.3 milestone Jul 26, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In Progress to ✅ Done in LangChain.dart Jul 26, 2023
@davidmigloz davidmigloz linked a pull request Aug 4, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:memory Memory in chain. f:good first issue Good for newcomers t:enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants