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

refactor: ChromaDB migration #20

Closed
wants to merge 7 commits into from
Closed

refactor: ChromaDB migration #20

wants to merge 7 commits into from

Conversation

Anush008
Copy link
Member

@Anush008 Anush008 commented Aug 8, 2023

Description

  • This PR intends to migrate the project to use ChromaDB by implementing the RepositoryEmbeddingsDB trait for the ChromaDB client.

    pub trait RepositoryEmbeddingsDB {
    fn insert_repo_embeddings(&self, repo: RepositoryEmbeddings) -> Result<()>;
    fn get_relevant_file_paths(
    &self,
    repository: &Repository,
    query_embeddings: Embeddings,
    limit: usize,
    ) -> Result<RepositoryFilePaths>;
    fn get_file_paths(&self, repository: &Repository) -> Result<RepositoryFilePaths>;
    fn is_indexed(&self, repository: &Repository) -> Result<bool>;
    }

  • The README has been updated with the new local development steps

  • The ChromaDB service has been added to the docker-compose.yaml file.

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation Update
  • 🎨 Style
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • πŸ“¦ Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Resolves #19

Mobile & Desktop Screenshots/Recordings

Added tests?

  • πŸ‘ yes
  • πŸ™… no, because they aren't needed
  • πŸ™‹ no, because I need help

Added to documentation?

  • πŸ“œ README.md
  • πŸ““ docs.opensauced.pizza
  • πŸ• dev.to/opensauced
  • πŸ“• storybook
  • πŸ™… no documentation needed

@Anush008 Anush008 marked this pull request as ready for review August 8, 2023 13:38
@Anush008
Copy link
Member Author

Anush008 commented Aug 8, 2023

@bdougie, @jpmcb, you can try the service now.
Everything should stay the same.
You can set the OPENAI_API_KEY and WEBSERVER_PORT values in a .env file and run make up quickly get this running.

@Anush008 Anush008 requested review from jpmcb and bdougie August 8, 2023 13:47
@jpmcb
Copy link
Member

jpmcb commented Aug 8, 2023

Wow excellent work. I'll review this today and look at getting this deployed on our azure instance. I have some terraform that should make that a quick process.

@Anush008
Copy link
Member Author

Anush008 commented Aug 8, 2023

Hey @jpmcb. The ort lib supports some execution providers that can improve the embedding performance.
https://github.com/pykeio/ort#execution-providers

We are currently using the CPU provider.

.with_execution_providers([ExecutionProvider::CPU(
CPUExecutionProviderOptions::default(),
)])
.

Moving forward, if needed, we can try some of the others if the hardware support is available.

@jpmcb
Copy link
Member

jpmcb commented Aug 8, 2023

if the hardware support is available

GPU support would be cool, but right now, for the way we have it deployed through Container Apps, there aren't GPU instances available. This is essentially their serverless container runtime and doesn't involve alot of infrastructure. We'd need to look at a more intensive deployment strategy, maybe through Container Instances or Azure's Kubernetes service, that would let us deploy GPU instances.

For now, until we need to start scaling up in that way, I think the Container Apps deployment with CPU ort optimization is just fine.

Copy link
Member

@bdougie bdougie left a comment

Choose a reason for hiding this comment

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

Looks like a pretty clean swap. Really appreciate you kicking off the chroma client work as well.

Copy link
Member

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

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

I was having some snags running the image locally on arm64 so i opened: chroma-core/chroma#972

But I was able to rebuild the image and this works well - nice work!

Performance seems slightly worse than qdrant locally for me. But will have to try that on real hardware.

Comment on lines +10 to +21
fn insert_repo_embeddings(&self, repo: RepositoryEmbeddings) -> Result<()>;

async fn get_relevant_files(
fn get_relevant_file_paths(
&self,
repository: &Repository,
query_embeddings: Embeddings,
limit: usize,
) -> Result<RepositoryFilePaths>;

async fn get_file_paths(&self, repository: &Repository) -> Result<RepositoryFilePaths>;
fn get_file_paths(&self, repository: &Repository) -> Result<RepositoryFilePaths>;

async fn is_indexed(&self, repository: &Repository) -> Result<bool>;
fn is_indexed(&self, repository: &Repository) -> Result<bool>;
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense we'd remove async since before we were just await on each call anyways πŸ‘πŸΌ

OPENAI_API_KEY= #REQUIRED
WEBSERVER_PORT= #REQUIRED
CHROMA_URL= #Defaults to http://localhost:8000
Copy link
Member

Choose a reason for hiding this comment

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

Where does this get used to set the Chroma client? I'm not seeing any other references to this in the code. Is it being consumed by the Chroma rust client?

Copy link
Member Author

@Anush008 Anush008 Aug 12, 2023

Choose a reason for hiding this comment

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

Yes. The Chromadb-rs lib uses the CHROMA_URL env by default.

let client = ChromaClient::new(Default::default());

@Anush008
Copy link
Member Author

cc7f606, resolves #21.

@Anush008 Anush008 linked an issue Aug 13, 2023 that may be closed by this pull request
Copy link
Member

@jpmcb jpmcb left a comment

Choose a reason for hiding this comment

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

There are a few non-starters to getting this merged:

Until then, we should hold this migration and stick with Qdrant since it's working out of the box in our container environments.

@Anush008 Anush008 closed this Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Explore chromadb Collection example in the README seems off
3 participants