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

feat: use milvus in chat llamaindex #4

Conversation

thucpn
Copy link
Owner

@thucpn thucpn commented Jul 31, 2024

No description provided.

Copy link

vercel bot commented Jul 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
chat-llamaindex ❌ Failed (Inspect) Aug 1, 2024 10:42am

);
}

return await VectorStoreIndex.fromVectorStore(store);

Choose a reason for hiding this comment

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

Can we move a shared function getIndex to shared.ts?

});
const storageContext = await storageContextFromDefaults({ vectorStore });

Choose a reason for hiding this comment

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

Try using the shared function getIndex here and use is the index directly in fromDocuments below (without storage context)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, we can do:

const index = await getIndex(datasource);
    const documents = await getDocuments(datasource);
    //  Set private=false to mark the document as public (required for filtering)
    documents.forEach((doc) => {
      doc.metadata["private"] = "false";
    });
    await runPipeline(index, documents);

But inside runPipeline function, we are setting private = true (we need to set private = false when generating public documents)
I guess we shouldn't append metadata to documents inside runPipeline function (can move it outside)

Copy link
Owner Author

Choose a reason for hiding this comment

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

I just updated to split the getIndex function. Thank you! That's a cool idea that solves my pain.
Previously, when creating a new bot, users had to manually create a collection to start chatting.
But now, when creating a new bot, they can start by uploading a private file. It will automatically create a collection on Milvus

@thucpn thucpn force-pushed the feat/use-milvus-in-chat-llamaindex branch from 256bd96 to 3175f76 Compare July 31, 2024 14:58
Comment on lines +24 to +31
const isCollectionExist = await getMilvusClient().hasCollection({
collection_name: datasource,
});
if (!isCollectionExist.value) {
throw new Error(
`Collection "${datasource}" does not exist! Run the generate script or try uploading a file.`,
);
}

Choose a reason for hiding this comment

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

how about we move this check into getIndex?

Copy link
Owner Author

Choose a reason for hiding this comment

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

It won't work when running generate (because when generating we will create a new collection)

Choose a reason for hiding this comment

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

how about adding a checkExists parameter to getIndex then?

getIndex({datasource, checkExists: false})

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, let me try

}
}

export async function getIndex(datasource: string) {

Choose a reason for hiding this comment

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

to mimize changes with base branch, call this getDatasource and move it to index.ts

) {
// Update documents with metadata

Choose a reason for hiding this comment

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

good we can also do this in CL directly

@@ -14,6 +14,16 @@ export async function uploadDocument(
const fileBuffer = Buffer.from(content, "base64");
const documents = await loadDocuments(fileBuffer, mimeType);
const { filename } = await saveDocument(fileBuffer, mimeType);
const index = await getDataSource(datasource);
return await runPipeline(index, documents, filename);
const index = await getIndex(datasource);

Choose a reason for hiding this comment

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

good we can also do this in CL directly

@@ -20,7 +20,7 @@ npx -y create-llama@0.1.25 \
--post-install-action none \
--no-llama-parse \
--example-file \
--vector-db none \
--vector-db milvus \

Choose a reason for hiding this comment

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

goal: we just need to change this from none to milvus to use Milvus in chat llamaindex

@thucpn
Copy link
Owner Author

thucpn commented Aug 1, 2024

Open new PR here: #5

@thucpn thucpn closed this Aug 1, 2024
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.

2 participants