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

Feature/weaviate memory #424

Merged

Conversation

cs0lar
Copy link
Contributor

@cs0lar cs0lar commented Apr 7, 2023

Background

This change allows the use of different vector-based memories for Auto-GPT as long as the Memory interface is implemented. As an example, this change integrates Weaviate as an alternative to Pinecone that can be instantiated locally.

Changes

  • We created a providers directory which is meant to hold the various memory implementations.
  • The original scripts/memory.py file has been moved into the providers module and it declares Memory as an interface to be implemented.
  • A new scripts/factory.py file has been added which declares a factory method for creating the appropriate memory support class. A new environment variable, MEMORY_PROVIDER allows to configure which provider to use.
  • The Pinecone implementation has been moved into the providers module.
  • An Weaviate implementation of the Memory interface has been added.

Test Plan

Added factory tests in tests/memory_tests.py

Change Safety

  • I have added tests to cover my changes
  • I have considered potential risks and mitigations for my changes

…are absent in the latest version of execute_command therefore the corresponding handlers commit_memory, delete_memory and overwrite_memory have been removed also because they assume a memory with a different interface than the proposed one.
@cs0lar
Copy link
Contributor Author

cs0lar commented Apr 8, 2023

I have noticed that the latest commands list in commands.py no longer supports the memory-related command (memory_del, memory_ovr). In this pull request I have removed the associated handlers (delete_memory and overwrite_memory) as well as the original commit_memory in part because they no longer follow the memory interface. Let me know whether these memory commands should be back on the menu and I can implement them.

Bakuutin
Bakuutin previously approved these changes Apr 8, 2023
@dahifi
Copy link

dahifi commented Apr 10, 2023

Thank you so much I was actually working on a similar branch last week! 😃

nponeccop
nponeccop previously approved these changes Apr 10, 2023
@nponeccop nponeccop mentioned this pull request Apr 10, 2023
1 task
@cs0lar
Copy link
Contributor Author

cs0lar commented Apr 11, 2023

I have now merged the memory strategy from the master branch and added weaviate to the supported providers. I have also added tests for the weaviate integration.

Copy link
Contributor

@nponeccop nponeccop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but needs whitespace fixes.

README.md Outdated
@@ -185,13 +185,15 @@ Pinecone enables the storage of vast amounts of vector-based memory, allowing fo
2. Choose the `Starter` plan to avoid being charged.
3. Find your API key and region under the default project in the left sidebar.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the unrelated whitespace changes

README.md Outdated Show resolved Hide resolved
@@ -298,4 +298,4 @@ def delete_agent(key):
result = agents.delete_agent(key)
if not result:
return f"Agent {key} does not exist."
return f"Agent {key} deleted."
return f"Agent {key} deleted."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is optional, but add an extra line feed at the end of file to remove this (-) sign from the diff. I will still approve if you won't

scripts/main.py Outdated Show resolved Hide resolved
@@ -1,4 +1,3 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this

@@ -48,4 +47,4 @@ def get_relevant(self, data, num_relevant=5):
return [str(item['metadata']["raw_text"]) for item in sorted_results]

def get_stats(self):
return self.index.describe_index_stats()
return self.index.describe_index_stats()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you removed the final line feed. Just revert

scripts/memory/weaviate.py Outdated Show resolved Hide resolved
@cs0lar
Copy link
Contributor Author

cs0lar commented Apr 11, 2023

@nponeccop - applied all requests.

nponeccop
nponeccop previously approved these changes Apr 11, 2023
@nponeccop nponeccop mentioned this pull request Apr 11, 2023
1 task
@hsm207
Copy link

hsm207 commented Apr 11, 2023

@cs0lar what are your thoughts on adding support for embedded weaviate too as part of this PR?

@cs0lar
Copy link
Contributor Author

cs0lar commented Apr 12, 2023

@hsm207 Thanks for spotting that. I have added weaviate embedded support now. Please check it out.

.env.template Outdated
OPENAI_AZURE_API_BASE=your-base-url-for-azure
OPENAI_AZURE_API_VERSION=api-version-for-azure
OPENAI_AZURE_DEPLOYMENT_ID=deployment-id-for-azure
IMAGE_PROVIDER=dalle
HUGGINGFACE_API_TOKEN=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo the relocation of the HUGGINGFACE line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! there were also some dupes I have now removed.

@bobvanluijt
Copy link
Contributor

@bobvanluijt it would be great to know what's holding merging this branch (apart from the latest conflicts).

Thanks, @nponeccop, I think it's the merging of other PRs. Seems we are almost there. Your help is appreciated in keeping this PR up-to-date 🙏

Almost there, it seems: #424 (comment)

BTW honour to @nponeccop for relentlessly checking the PRs and conflict fixes!

Yup, thanks @nponeccop

nponeccop
nponeccop previously approved these changes Apr 15, 2023
@bobvanluijt
Copy link
Contributor

Awesome! I think the PR can be merged 🥳


def _build_auth_credentials(self, cfg):
if cfg.weaviate_username and cfg.weaviate_password:
return weaviate_auth.AuthClientPassword(cfg.weaviate_username, cfg.weaviate_password)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cs0lar this line will throw an error as weaviate_auth is not defined anymore in this module

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return weaviate_auth.AuthClientPassword(cfg.weaviate_username, cfg.weaviate_password)
return weaviate.AuthClientPassword(cfg.weaviate_username, cfg.weaviate_password)
```@cs0lar this line will throw an error as `weaviate_auth` is not defined anymore in this module

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cs0lar I think you missed this change

hsm207
hsm207 previously approved these changes Apr 15, 2023
@bobvanluijt
Copy link
Contributor

@cs0lar, I think we need your help again. People on the Auto-GPT Discord are asking for this merge 😂

@bobvanluijt
Copy link
Contributor

Hi @nponeccop and @richbeales. I think the merge conflict is resolved. Would be awesome if you could review and merge. Thanks 🙏

@richbeales richbeales added the potential plugin This may fit better into our plugin system. label Apr 16, 2023
@richbeales
Copy link
Contributor

Thanks for reaching out @bobvanluijt - we'll get to this shortly. I'll ping you when ready.

BillSchumacher
BillSchumacher previously approved these changes Apr 16, 2023
richbeales
richbeales previously approved these changes Apr 16, 2023
@BillSchumacher BillSchumacher merged commit ad4c3e0 into Significant-Gravitas:master Apr 16, 2023
@cs0lar cs0lar deleted the feature/weaviate-memory branch April 16, 2023 07:10
@level20peon
Copy link

level20peon commented Apr 16, 2023

I think Milvus and Weaviate should also be appended here, right? https://github.com/Significant-Gravitas/Auto-GPT/blob/master/.env.template#L53

Weaviate integration is mentioned in its own section, but Milvus doesn't have that mention and rather than being scathered all around the config, they should all be neatly gathered at the top (imho).

@bobvanluijt
Copy link
Contributor

🎉 thanks all for the help and merge 🎉

Added a minor change here: #1813

Basically, so that people don't have to install the Weaviate client manually.

sindlinger pushed a commit to Orgsindlinger/Auto-GPT-WebUI that referenced this pull request Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs discussion To be discussed among maintainers potential plugin This may fit better into our plugin system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.