-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: collection name everywhere #310
feat: collection name everywhere #310
Conversation
…jonasiwnl/embedchain into feat/collection-name-everywhere
Thanks for the PR, I especially appreciate the inclusion of unit tests. In #305, the configs were reworked. Can you resolve that merge conflict by using the new AppConfig, BaseAppConfig and OpenSourceAppConfig. Thank you! |
Sure, I'll get to work on that. |
Hey, I think there is a missing dependency config = OpenSourceAppConfig()
app = OpenSourceApp(config) after adding this dep in, all tests pass and the collection feature works as intended. |
redesign app concept
this is expected behavior, since we support open source models (and will support many more). If we make them a requirement everyone has to download them, even if they're just using OpenAI. |
Okay, fixed |
I did the merge conflicts for you. |
|
This has been thoroughly tested and is ready for production. Here's my test script. Compared to the unit tests, this uses from embedchain import App
from embedchain.config import AppConfig
naval_chat_bot = App()
naval_chat_bot.reset()
print("Reset app to run clean test")
naval_chat_bot = App()
# Embed Online Resources
naval_chat_bot.add("web_page", "https://nav.al/feedback")
naval_chat_bot.add("web_page", "https://nav.al/feedback")
# Embed Local Resources
naval_chat_bot.add_local("qna_pair", ("Who is Naval Ravikant?", "Naval Ravikant is an Indian-American entrepreneur and investor."))
naval_chat_bot.query("What unique capacity does Naval argue humans possess when it comes to understanding explanations or concepts?")
# Answer: Naval argues that humans possess the unique capacity to understand explanations or concepts to the maximum extent possible in this physical reality.
# Test: Add them again, it should show that they are already existing.
naval_chat_bot.add("web_page", "https://nav.al/feedback")
naval_chat_bot.add_local("qna_pair", ("Who is Naval Ravikant?", "Naval Ravikant is an Indian-American entrepreneur and investor."))
# Success
# Test: change database. It should allow to add again.
naval_chat_bot.set_collection('another_collection')
naval_chat_bot.add("web_page", "https://nav.al/feedback")
naval_chat_bot.add_local("qna_pair", ("Who is Naval Ravikant?", "Naval Ravikant is an Indian-American entrepreneur and investor."))
# Success
# Test: One collection should not know anything that's in another collection
naval_chat_bot.set_collection('johns_collection')
naval_chat_bot.add('text','My name is John Doe')
naval_chat_bot.set_collection('janes_collection')
r = naval_chat_bot.query("What is my name?", dry_run=True)
print(r)
# Sucess, shows no context.
# Test: Should allow two apps at the same time. We also test setting a collection through the config.
app1 = App(config=AppConfig(collection_name='first_collection'))
app2 = App(config=AppConfig(collection_name='second_collection'))
# Add data to first collection
app1.add("text", "1")
print("App 1:", app1.count())
# Add data to second collection
app2.add("text", "1")
print("App 2:", app2.count())
# App 1 should be unchanged
print("App 1:", app1.count()) |
@cachho : can we merge this PR? |
good to go |
Description
This change allows the collection of the vectordb to be switched with the
set_collection
method on the Embedchain class. It also allows the initial collection to be specified using InitConfig, e.g.InitConfig(collection_name="collection1")
. No new dependencies are required as this is a built-in feature of Chroma.Fixes # (issue)
Issue 261
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
This feature has been tested through 2 new tests added to
tests/vectordb/test_chroma_db.py
. It tests that the default collection name is correct (if no name is specified), a custom initial collection name, and switching the collection once the app has already been initialized.Checklist:
Maintainer Checklist