-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from KevKibe/cohere-embedding-support
Add Support for embedding, vectorstore initialization and rag retrieval using cohere.
- Loading branch information
Showing
27 changed files
with
884 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name = docindex | |
author = Kevin Kibe | ||
version = 0.5.0 | ||
author_email = [email protected] | ||
description = A package for fast indexing of multiple documents and their metadata on Pinecone. | ||
description = A package for fast persistent storage of multiple document embeddings and their metadata into Pinecone for production-level RAG. | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/KevKibe/docindex | ||
|
@@ -23,8 +23,13 @@ install_requires = | |
langchain-google-genai==1.0.1 | ||
langchain-pinecone==0.1.0 | ||
google.generativeai==0.4.1 | ||
python-dotenv==1.0.1 | ||
python-docx==1.1.0 | ||
markdown==3.6 | ||
langchain-core==0.1.46 | ||
langchain-cohere==0.1.4 | ||
package_dir= | ||
=src | ||
|
||
[options.packages.find] | ||
where=src | ||
where=src |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Config: | ||
template_str = """ | ||
You are very helpful assistant for question answering tasks. Use the pieces of retrieved context to answer question given. If you do not know | ||
the answer, Just say that you do not know the answer instead of making up an answer. | ||
Retrieved context: {context} | ||
Query: {query} | ||
""" | ||
|
||
default_google_model = "gemini-pro" | ||
default_openai_model = "gpt-3.5-turbo-0125" | ||
default_cohere_model = "command" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from .doc_index import CoherePineconeIndexer | ||
import argparse | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser(description="Creates an Index on Pinecone.") | ||
parser.add_argument("--pinecone_api_key", type=str, help="Pinecone API key") | ||
parser.add_argument("--index_name", type=str, help="Name of the Pinecone index") | ||
return parser.parse_args() | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
pinecone_indexer = CoherePineconeIndexer(args.index_name, args.pinecone_api_key) | ||
pinecone_indexer.create_index() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from .doc_index import CoherePineconeIndexer | ||
import argparse | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser(description="Deletes an Index on Pinecone.") | ||
parser.add_argument("--pinecone_api_key", type=str, help="Pinecone API key") | ||
parser.add_argument("--index_name", type=str, help="Name of the Pinecone index") | ||
return parser.parse_args() | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
pinecone_indexer = CoherePineconeIndexer(args.index_name, args.pinecone_api_key) | ||
pinecone_indexer.delete_index() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pydantic import BaseModel, Field | ||
from typing import Dict, Union | ||
|
||
class Page(BaseModel): | ||
page_content: str = Field(..., description="The content of the page") | ||
metadata: Dict[str, Union[str, int]] = Field(..., description="Metadata about the document") | ||
page: int = Field(..., description="The page of the content") | ||
source: Union[str, int] = Field(..., description="The source url of the document") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from .doc_index import CoherePineconeIndexer | ||
import argparse | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser(description="Index documents on Pinecone using OpenAI embeddings.") | ||
parser.add_argument("--pinecone_api_key", type=str, help="Pinecone API key") | ||
parser.add_argument("--index_name", type=str, help="Name of the Pinecone index") | ||
parser.add_argument("--cohere_api_key", type=str, help="OpenAI API key") | ||
parser.add_argument("--docs", nargs="+", help="URLs of the documents to be indexed") | ||
|
||
parser.add_argument("--batch_limit", type=int, default=32, help="Maximum batch size for indexing (default: 100).") | ||
parser.add_argument("--chunk_size", type=int, default=256, help="Size of texts per chunk (default: 1000 characters).") | ||
return parser.parse_args() | ||
|
||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
pinecone_indexer = CoherePineconeIndexer(args.index_name, args.pinecone_api_key, args.cohere_api_key) | ||
pinecone_indexer.index_documents(args.docs, args.batch_limit, args.chunk_size) | ||
pinecone_indexer.initialize_vectorstore(args.index_name) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.