-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Poetry + precommit * chore: Poetry * feat: Encoders * chore: Clean notebook outputs * feat: Added encoders to query * chore: Added a note to fix delete for Pinecone * chore: Linting fix * fix: Fix Pinecone deletion by file_url * fix: Pinecone delete * feat: Chunk visual
- Loading branch information
Showing
5 changed files
with
121 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ COHERE_API_KEY= | |
# Optional for walkthrough | ||
PINECONE_API_KEY= | ||
PINECONE_HOST= | ||
PINECONE_INDEX= | ||
PINECONE_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,103 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"from models.file import File, FileType\n", | ||
"from service.embedding import EmbeddingService\n", | ||
"from termcolor import colored\n", | ||
"\n", | ||
"PINECONE_INDEX = os.getenv(\"PINECONE_INDEX\", \"\")\n", | ||
"PINECONE_API_KEY = os.getenv(\"PINECONE_API_KEY\", \"\")\n", | ||
"PINECONE_HOST = os.getenv(\"PINECONE_HOST\", \"\")\n", | ||
"\n", | ||
"file = File(\n", | ||
" type=FileType.pdf,\n", | ||
" url=\"https://arxiv.org/pdf/2402.05131.pdf\"\n", | ||
")\n", | ||
"vector_credentials = {\n", | ||
" \"type\": \"pinecone\",\n", | ||
" \"config\": {\n", | ||
" \"api_key\": PINECONE_API_KEY,\n", | ||
" \"host\": PINECONE_HOST,\n", | ||
" }\n", | ||
" },\n", | ||
"\n", | ||
"embedding_service = EmbeddingService(\n", | ||
" files=[file],\n", | ||
" index_name=PINECONE_INDEX,\n", | ||
" vector_credentials=vector_credentials\n", | ||
" )" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"docs = await embedding_service.generate_documents()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"chunks = await embedding_service.generate_chunks(docs)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"colors = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']\n", | ||
"\n", | ||
"concatenated_document = \"\"\n", | ||
"\n", | ||
"for i, chunk in enumerate(chunks):\n", | ||
" color = colors[i % len(colors)]\n", | ||
" colored_text = colored(chunk.text, color)\n", | ||
" print(colored_text)\n", | ||
" concatenated_document += chunk.text + \" \"\n", | ||
"\n", | ||
"print(\"\\nConcatenated Document:\\n\", concatenated_document)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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