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

Adding Postgres for the doc and index store #1706

Merged
merged 14 commits into from
Mar 14, 2024
Merged

Conversation

dbzoo
Copy link
Contributor

@dbzoo dbzoo commented Mar 11, 2024

Adding Postgres support for the Doc and Index store.
Provided example using ollama and everything stored in Postgres.

One thing that is a little unusual is that if you are using the same postgres DB for both the Docstore and the Vector store
you need to supply the credentials twice. This is has both benefit and downsides.

Copy link
Contributor

Copy link
Collaborator

@imartinez imartinez left a comment

Choose a reason for hiding this comment

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

Very good addition! Added a couple minor comments.

Also, an important one: we need to update pyproject.toml to include as optional
llama-index-storage-docstore-postgres and llama-index-storage-index-store-postgres; with that update the installation docs, etc. I can help with that if needed.

It'd be great to add specific documentation about this addition, the same way we already have a section about vector stores at https://docs.privategpt.dev/manual/storage/vector-stores

private_gpt/components/node_store/node_store_component.py Outdated Show resolved Hide resolved
private_gpt/components/node_store/node_store_component.py Outdated Show resolved Hide resolved
Copy link
Contributor

Copy link
Contributor

Copy link
Collaborator

@imartinez imartinez left a comment

Choose a reason for hiding this comment

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

It is looking great! I've just noticed one thing about the naming: we should call it nodestore everywhere (instead of docstore or DocIndexStore) for consistency; given the original component is NodeStoreComponent, I'd stick to that name.

pyproject.toml Show resolved Hide resolved
fern/docs/pages/manual/docindexstore.mdx Outdated Show resolved Hide resolved
fern/docs.yml Outdated Show resolved Hide resolved
settings.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@HenrikPedDK
Copy link

Hi guys. I have this version running. There is some typos in the doc and a syntax error in the node_component.py but i got it up and running. Something is very wrong when querying files compared to before. I put an example in a thread in Discord. I don't know if it's the embedding that goes wrong or something else, but if I embed the same document directly in the running Ollama instance i get much better answers (same model / document)

@dbzoo dbzoo mentioned this pull request Mar 12, 2024
Copy link
Contributor

Copy link
Contributor

@dbzoo
Copy link
Contributor Author

dbzoo commented Mar 12, 2024

There is some typos in the doc and a syntax error in the node_component.py

Those should both be fixed now. What discord thread?

@imartinez
Copy link
Collaborator

There is some typos in the doc and a syntax error in the node_component.py

Those should both be fixed now. What discord thread?

Summing up: @HenrikPedDK found that using Postgres for doc and index store makes the Query Docs not work properly. I haven't tested it myself, so it is not a 100% confirmed issue (at least not the direct relation with these changes).

Copying @HenrikPedDK feedback here from Discord (moving the convo to Discord is not a good practice; having said that, happy to also chat in Discord ):

Okay, i have ingested a cook book that i usually test with. Before using Postgres as index/docstore i could query for a specific recipe. It can't do that anymore, it summarizes the book okay but when asking into specific things it gives answers like this:

"I apologize for any confusion earlier, but I cannot directly provide you with the Cassoulet recipe from "Cast Iron Cooking For Dummies" as I don't have access to the actual text of the book. However, I can give you a basic outline and ingredients list for making a traditional French Cassoulet in a cast iron Dutch oven or casserole dish."
If i do the same directly on the same Ollama instance with the same document/mistral i get this answer:

Mistral:Latest 12/03/2024 13:52
Yes, I can provide you with a recipe for Cassoulet. Here it is:

INGREDIENTS

4 tablespoons olive oil

½ pound haricot coverts (green beans), cleaned

1 shallot, sliced

2 cloves garlic, sliced

1 tablespoon butter

¼ cup almonds, sliced

Salt and pepper to taste

Red pepper flakes to taste

1 pound lamb shoulder, medium diced

1 pound pork shoulder, medium diced

Salt and pepper, to taste

2 onions, small diced

4 garlic cloves, minced

2 tablespoons tomato paste

4 Roma tomatoes, small diced

1 teaspoon sugar

1 pound dry white beans, great northern, presoaked overnight

2 quarts chicken stock

4 sprigs thyme

2 bay leaves

3 sprigs parsley, separate leaves (mince) from stems (reserve)

3 slices bacon, medium diced

2 cups panko breadcrumbs

1 lemon zest

COOK TIME: 2 hours PREP TIME: 10 minutes YIELD: 8 servings

Heat the oil in a Dutch oven or large pot. Add the green beans, shallot, and garlic. Cook until tender, about 5 minutes. Remove from the pot and set aside.

Preheat the oven to 375 degrees Fahrenheit.

In the same pot, heat the butter. When it's melted, add the almonds. Cook for 2 minutes, then remove them and set aside with the green beans.

Season the lamb and pork with salt and pepper to taste. In the same pot, cook the meats until browned on all sides. Remove and set aside with the green beans and almonds.

In the same pot, heat 2 tablespoons oil. Add the onions and garlic. Cook for 3 minutes, then remove them and set aside.

Heat 1 more tablepoon of oil in the same pot. Add the tomato paste. Cook for 2 minutes. Then add the Roma tomatoes, sugar, and cooked white beans. Stir well to combine, then add chicken stock, thyme sprigs, bay leaves, and parsley stems.

( i removed the rest)

Copy link
Contributor

Copy link
Contributor

@dbzoo dbzoo requested a review from imartinez March 12, 2024 21:26
Copy link
Contributor

Copy link
Collaborator

@imartinez imartinez left a comment

Choose a reason for hiding this comment

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

Super small doc typos

fern/docs/pages/manual/vectordb.mdx Outdated Show resolved Hide resolved
fern/docs/pages/manual/vectordb.mdx Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
Copy link
Collaborator

@imartinez imartinez left a comment

Choose a reason for hiding this comment

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

Added a comment to fix the only pending linting error.

Forget about the fern error, I'll disable that check in the near future

private_gpt/components/node_store/node_store_component.py Outdated Show resolved Hide resolved
Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

pyproject.toml Outdated Show resolved Hide resolved
@paul-asvb paul-asvb mentioned this pull request Mar 13, 2024
Copy link
Contributor

Copy link
Contributor

Copy link
Collaborator

@imartinez imartinez left a comment

Choose a reason for hiding this comment

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

Great contribution and execution!

@imartinez imartinez merged commit 68b3a34 into zylon-ai:main Mar 14, 2024
7 of 8 checks passed
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.

3 participants