Kirai-Kevin commited on
Commit
d1f719e
·
verified ·
1 Parent(s): e413953

Upload 20 files

Browse files
.env ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ PINECONE_API_KEY = "d3c4dd56-1429-48e5-bcb2-2a26b1259092"
2
+ PINECONE_API_ENV = "us-east-1"
.gitignore ADDED
File without changes
0.2.0 ADDED
File without changes
app.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import time
3
+ from flask import Flask, render_template, jsonify, request
4
+ from src.helper import download_hugging_face_embeddings
5
+ from langchain.llms import CTransformers
6
+ from dotenv import load_dotenv
7
+ from PyPDF2 import PdfReader
8
+ from langchain.schema import Document
9
+ from langchain.text_splitter import CharacterTextSplitter
10
+
11
+ # Initialize Flask app
12
+ app = Flask(__name__)
13
+
14
+ # Load environment variables
15
+ load_dotenv()
16
+
17
+ # Define the load_pdf function
18
+ def load_pdf(file_path):
19
+ all_text = ""
20
+ with open(file_path, 'rb') as file:
21
+ reader = PdfReader(file)
22
+ for page in reader.pages:
23
+ all_text += page.extract_text() + "\n"
24
+ return all_text if all_text else None
25
+
26
+ # Define the text_split function
27
+ def text_split(text):
28
+ text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
29
+ document = Document(page_content=text)
30
+ return text_splitter.split_documents([document])
31
+
32
+ # Load and process data
33
+ pdf_file_path = "data/Okelloetal.2008TourismanalysisManka.pdf" # Update this path to your single PDF file
34
+ extracted_data = load_pdf(pdf_file_path)
35
+ if extracted_data is None:
36
+ raise ValueError("The extracted data is None. Please check the load_pdf function.")
37
+
38
+ print(f"Extracted Data: {extracted_data}")
39
+
40
+ # Split the extracted text into chunks
41
+ text_chunks = text_split(extracted_data)
42
+ if not text_chunks:
43
+ raise ValueError("The text_chunks is None or empty. Please check the text_split function.")
44
+
45
+ print(f"Text Chunks: {text_chunks}")
46
+
47
+ embeddings = download_hugging_face_embeddings()
48
+ if embeddings is None:
49
+ raise ValueError("The embeddings is None. Please check the download_hugging_face_embeddings function.")
50
+
51
+ print(f"Embeddings: {embeddings}")
52
+
53
+ # Setup CTransformers LLM
54
+ llm=CTransformers(model="model",
55
+ model_type="llama",
56
+ config={'max_new_tokens':100,
57
+ 'temperature':0.8})
58
+
59
+
60
+ # Flask routes
61
+ @app.route("/")
62
+ def index():
63
+ return render_template('chat.html')
64
+
65
+ @app.route("/get", methods=["GET", "POST"])
66
+ def chat():
67
+ try:
68
+ msg = request.form["msg"]
69
+ input_text = msg
70
+ print(f"Received message: {input_text}")
71
+
72
+ # Display spinner
73
+ result = {"generated_text": "Thinking..."}
74
+
75
+ # Simulate processing delay
76
+ time.sleep(1)
77
+
78
+ # Retrieve response from the model
79
+ result = llm.generate([input_text])
80
+ print(f"LLMResult: {result}")
81
+
82
+ # Access the generated text from the result object
83
+ if result.generations and result.generations[0]:
84
+ generated_text = result.generations[0][0].text
85
+ else:
86
+ generated_text = "No response generated."
87
+
88
+ print(f"Response: {generated_text}")
89
+
90
+ return str(generated_text)
91
+ except Exception as e:
92
+ print(f"Error: {e}")
93
+ return jsonify({"error": str(e)}), 500
94
+
95
+ if __name__ == '__main__':
96
+ app.run(host="0.0.0.0", port=8080, debug=True)
data/Okelloetal.2008TourismanalysisManka.pdf ADDED
Binary file (437 kB). View file
 
model/llama-2-7b-chat.ggmlv3.q4_0 (1).bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8daa9615cce30c259a9555b1cc250d461d1bc69980a274b44d7eda0be78076d8
3
+ size 3791725184
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ ctransformers==0.2.5
2
+ sentence-transformers==2.2.2
3
+ pinecone-client
4
+ langchain==0.0.225
5
+ flask
6
+ pypdf
7
+ python-dotenv
8
+ -e .
research/trials.ipynb ADDED
@@ -0,0 +1,1816 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "Requirement already satisfied: langchain-community in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (0.2.4)\n",
13
+ "Requirement already satisfied: PyYAML>=5.3 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (6.0.1)\n",
14
+ "Requirement already satisfied: SQLAlchemy<3,>=1.4 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (2.0.30)\n",
15
+ "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (3.9.5)\n",
16
+ "Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (0.5.14)\n",
17
+ "Requirement already satisfied: langchain<0.3.0,>=0.2.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (0.2.4)\n",
18
+ "Requirement already satisfied: langchain-core<0.3.0,>=0.2.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (0.2.6)\n",
19
+ "Requirement already satisfied: langsmith<0.2.0,>=0.1.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (0.1.77)\n",
20
+ "Requirement already satisfied: numpy<2,>=1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (1.24.4)\n",
21
+ "Requirement already satisfied: requests<3,>=2 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (2.32.3)\n",
22
+ "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-community) (8.3.0)\n",
23
+ "Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (1.3.1)\n",
24
+ "Requirement already satisfied: attrs>=17.3.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (23.2.0)\n",
25
+ "Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (1.4.1)\n",
26
+ "Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (6.0.5)\n",
27
+ "Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (1.9.4)\n",
28
+ "Requirement already satisfied: async-timeout<5.0,>=4.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain-community) (4.0.3)\n",
29
+ "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from dataclasses-json<0.7,>=0.5.7->langchain-community) (3.21.3)\n",
30
+ "Requirement already satisfied: typing-inspect<1,>=0.4.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from dataclasses-json<0.7,>=0.5.7->langchain-community) (0.9.0)\n",
31
+ "Requirement already satisfied: langchain-text-splitters<0.3.0,>=0.2.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain<0.3.0,>=0.2.0->langchain-community) (0.2.1)\n",
32
+ "Requirement already satisfied: pydantic<3,>=1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain<0.3.0,>=0.2.0->langchain-community) (1.10.16)\n",
33
+ "Requirement already satisfied: jsonpatch<2.0,>=1.33 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-core<0.3.0,>=0.2.0->langchain-community) (1.33)\n",
34
+ "Requirement already satisfied: packaging<25,>=23.2 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-core<0.3.0,>=0.2.0->langchain-community) (23.2)\n",
35
+ "Requirement already satisfied: orjson<4.0.0,>=3.9.14 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langsmith<0.2.0,>=0.1.0->langchain-community) (3.10.4)\n",
36
+ "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from requests<3,>=2->langchain-community) (3.3.2)\n",
37
+ "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from requests<3,>=2->langchain-community) (3.7)\n",
38
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from requests<3,>=2->langchain-community) (2.2.1)\n",
39
+ "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from requests<3,>=2->langchain-community) (2024.6.2)\n",
40
+ "Requirement already satisfied: typing-extensions>=4.6.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from SQLAlchemy<3,>=1.4->langchain-community) (4.12.2)\n",
41
+ "Requirement already satisfied: greenlet!=0.4.17 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from SQLAlchemy<3,>=1.4->langchain-community) (3.0.3)\n",
42
+ "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from jsonpatch<2.0,>=1.33->langchain-core<0.3.0,>=0.2.0->langchain-community) (3.0.0)\n",
43
+ "Requirement already satisfied: mypy-extensions>=0.3.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain-community) (1.0.0)\n",
44
+ "Note: you may need to restart the kernel to use updated packages.\n"
45
+ ]
46
+ }
47
+ ],
48
+ "source": [
49
+ "%pip install -U langchain-community\n",
50
+ "\n"
51
+ ]
52
+ },
53
+ {
54
+ "cell_type": "code",
55
+ "execution_count": 2,
56
+ "metadata": {},
57
+ "outputs": [
58
+ {
59
+ "name": "stderr",
60
+ "output_type": "stream",
61
+ "text": [
62
+ "c:\\Users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages\\pinecone\\data\\index.py:1: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
63
+ " from tqdm.autonotebook import tqdm\n"
64
+ ]
65
+ }
66
+ ],
67
+ "source": [
68
+ "from langchain import PromptTemplate\n",
69
+ "from langchain.chains import RetrievalQA\n",
70
+ "from langchain.embeddings import HuggingFaceEmbeddings\n",
71
+ "from langchain.vectorstores import Pinecone\n",
72
+ "\n",
73
+ "from pinecone import Pinecone\n",
74
+ "from langchain.document_loaders import PyPDFLoader, DirectoryLoader\n",
75
+ "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
76
+ "from langchain.prompts import PromptTemplate\n",
77
+ "from langchain.llms import CTransformers"
78
+ ]
79
+ },
80
+ {
81
+ "cell_type": "code",
82
+ "execution_count": 3,
83
+ "metadata": {},
84
+ "outputs": [],
85
+ "source": [
86
+ "PINECONE_API_KEY = \"d3c4dd56-1429-48e5-bcb2-2a26b1259092\"\n",
87
+ "PINECONE_API_ENV = \"us-east-1\""
88
+ ]
89
+ },
90
+ {
91
+ "cell_type": "code",
92
+ "execution_count": 4,
93
+ "metadata": {},
94
+ "outputs": [
95
+ {
96
+ "name": "stdout",
97
+ "output_type": "stream",
98
+ "text": [
99
+ "Requirement already satisfied: pinecone-client in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (4.1.1)\n",
100
+ "Requirement already satisfied: certifi>=2019.11.17 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client) (2024.6.2)\n",
101
+ "Requirement already satisfied: pinecone-plugin-interface<0.0.8,>=0.0.7 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client) (0.0.7)\n",
102
+ "Requirement already satisfied: tqdm>=4.64.1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client) (4.66.4)\n",
103
+ "Requirement already satisfied: typing-extensions>=3.7.4 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client) (4.12.2)\n",
104
+ "Requirement already satisfied: urllib3>=1.26.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client) (2.2.1)\n",
105
+ "Requirement already satisfied: colorama in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from tqdm>=4.64.1->pinecone-client) (0.4.6)\n",
106
+ "Note: you may need to restart the kernel to use updated packages.\n"
107
+ ]
108
+ }
109
+ ],
110
+ "source": [
111
+ "%pip install pinecone-client"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "code",
116
+ "execution_count": 5,
117
+ "metadata": {},
118
+ "outputs": [],
119
+ "source": [
120
+ "from pinecone import Pinecone\n",
121
+ "\n",
122
+ "pc = Pinecone(api_key=PINECONE_API_KEY)\n",
123
+ "index = pc.Index(\"travel-bot\")"
124
+ ]
125
+ },
126
+ {
127
+ "cell_type": "code",
128
+ "execution_count": 6,
129
+ "metadata": {},
130
+ "outputs": [
131
+ {
132
+ "data": {
133
+ "text/plain": [
134
+ "{'upserted_count': 4}"
135
+ ]
136
+ },
137
+ "execution_count": 6,
138
+ "metadata": {},
139
+ "output_type": "execute_result"
140
+ }
141
+ ],
142
+ "source": [
143
+ "index.upsert(\n",
144
+ " vectors=[\n",
145
+ " {\n",
146
+ " \"id\": \"vec1\", \n",
147
+ " \"values\": [0.1] * 384, \n",
148
+ " \"metadata\": {\"genre\": \"drama\"}\n",
149
+ " }, {\n",
150
+ " \"id\": \"vec2\", \n",
151
+ " \"values\": [0.2] * 384, \n",
152
+ " \"metadata\": {\"genre\": \"action\"}\n",
153
+ " }, {\n",
154
+ " \"id\": \"vec3\", \n",
155
+ " \"values\": [0.3] * 384, \n",
156
+ " \"metadata\": {\"genre\": \"drama\"}\n",
157
+ " }, {\n",
158
+ " \"id\": \"vec4\", \n",
159
+ " \"values\": [0.4] * 384, \n",
160
+ " \"metadata\": {\"genre\": \"action\"}\n",
161
+ " }\n",
162
+ " ],\n",
163
+ " namespace=\"ns1\"\n",
164
+ ")\n"
165
+ ]
166
+ },
167
+ {
168
+ "cell_type": "code",
169
+ "execution_count": 7,
170
+ "metadata": {},
171
+ "outputs": [
172
+ {
173
+ "data": {
174
+ "text/plain": [
175
+ "{'matches': [{'id': 'vec4',\n",
176
+ " 'metadata': {'genre': 'action'},\n",
177
+ " 'score': 0.999999106,\n",
178
+ " 'values': [0.4,\n",
179
+ " 0.4,\n",
180
+ " 0.4,\n",
181
+ " 0.4,\n",
182
+ " 0.4,\n",
183
+ " 0.4,\n",
184
+ " 0.4,\n",
185
+ " 0.4,\n",
186
+ " 0.4,\n",
187
+ " 0.4,\n",
188
+ " 0.4,\n",
189
+ " 0.4,\n",
190
+ " 0.4,\n",
191
+ " 0.4,\n",
192
+ " 0.4,\n",
193
+ " 0.4,\n",
194
+ " 0.4,\n",
195
+ " 0.4,\n",
196
+ " 0.4,\n",
197
+ " 0.4,\n",
198
+ " 0.4,\n",
199
+ " 0.4,\n",
200
+ " 0.4,\n",
201
+ " 0.4,\n",
202
+ " 0.4,\n",
203
+ " 0.4,\n",
204
+ " 0.4,\n",
205
+ " 0.4,\n",
206
+ " 0.4,\n",
207
+ " 0.4,\n",
208
+ " 0.4,\n",
209
+ " 0.4,\n",
210
+ " 0.4,\n",
211
+ " 0.4,\n",
212
+ " 0.4,\n",
213
+ " 0.4,\n",
214
+ " 0.4,\n",
215
+ " 0.4,\n",
216
+ " 0.4,\n",
217
+ " 0.4,\n",
218
+ " 0.4,\n",
219
+ " 0.4,\n",
220
+ " 0.4,\n",
221
+ " 0.4,\n",
222
+ " 0.4,\n",
223
+ " 0.4,\n",
224
+ " 0.4,\n",
225
+ " 0.4,\n",
226
+ " 0.4,\n",
227
+ " 0.4,\n",
228
+ " 0.4,\n",
229
+ " 0.4,\n",
230
+ " 0.4,\n",
231
+ " 0.4,\n",
232
+ " 0.4,\n",
233
+ " 0.4,\n",
234
+ " 0.4,\n",
235
+ " 0.4,\n",
236
+ " 0.4,\n",
237
+ " 0.4,\n",
238
+ " 0.4,\n",
239
+ " 0.4,\n",
240
+ " 0.4,\n",
241
+ " 0.4,\n",
242
+ " 0.4,\n",
243
+ " 0.4,\n",
244
+ " 0.4,\n",
245
+ " 0.4,\n",
246
+ " 0.4,\n",
247
+ " 0.4,\n",
248
+ " 0.4,\n",
249
+ " 0.4,\n",
250
+ " 0.4,\n",
251
+ " 0.4,\n",
252
+ " 0.4,\n",
253
+ " 0.4,\n",
254
+ " 0.4,\n",
255
+ " 0.4,\n",
256
+ " 0.4,\n",
257
+ " 0.4,\n",
258
+ " 0.4,\n",
259
+ " 0.4,\n",
260
+ " 0.4,\n",
261
+ " 0.4,\n",
262
+ " 0.4,\n",
263
+ " 0.4,\n",
264
+ " 0.4,\n",
265
+ " 0.4,\n",
266
+ " 0.4,\n",
267
+ " 0.4,\n",
268
+ " 0.4,\n",
269
+ " 0.4,\n",
270
+ " 0.4,\n",
271
+ " 0.4,\n",
272
+ " 0.4,\n",
273
+ " 0.4,\n",
274
+ " 0.4,\n",
275
+ " 0.4,\n",
276
+ " 0.4,\n",
277
+ " 0.4,\n",
278
+ " 0.4,\n",
279
+ " 0.4,\n",
280
+ " 0.4,\n",
281
+ " 0.4,\n",
282
+ " 0.4,\n",
283
+ " 0.4,\n",
284
+ " 0.4,\n",
285
+ " 0.4,\n",
286
+ " 0.4,\n",
287
+ " 0.4,\n",
288
+ " 0.4,\n",
289
+ " 0.4,\n",
290
+ " 0.4,\n",
291
+ " 0.4,\n",
292
+ " 0.4,\n",
293
+ " 0.4,\n",
294
+ " 0.4,\n",
295
+ " 0.4,\n",
296
+ " 0.4,\n",
297
+ " 0.4,\n",
298
+ " 0.4,\n",
299
+ " 0.4,\n",
300
+ " 0.4,\n",
301
+ " 0.4,\n",
302
+ " 0.4,\n",
303
+ " 0.4,\n",
304
+ " 0.4,\n",
305
+ " 0.4,\n",
306
+ " 0.4,\n",
307
+ " 0.4,\n",
308
+ " 0.4,\n",
309
+ " 0.4,\n",
310
+ " 0.4,\n",
311
+ " 0.4,\n",
312
+ " 0.4,\n",
313
+ " 0.4,\n",
314
+ " 0.4,\n",
315
+ " 0.4,\n",
316
+ " 0.4,\n",
317
+ " 0.4,\n",
318
+ " 0.4,\n",
319
+ " 0.4,\n",
320
+ " 0.4,\n",
321
+ " 0.4,\n",
322
+ " 0.4,\n",
323
+ " 0.4,\n",
324
+ " 0.4,\n",
325
+ " 0.4,\n",
326
+ " 0.4,\n",
327
+ " 0.4,\n",
328
+ " 0.4,\n",
329
+ " 0.4,\n",
330
+ " 0.4,\n",
331
+ " 0.4,\n",
332
+ " 0.4,\n",
333
+ " 0.4,\n",
334
+ " 0.4,\n",
335
+ " 0.4,\n",
336
+ " 0.4,\n",
337
+ " 0.4,\n",
338
+ " 0.4,\n",
339
+ " 0.4,\n",
340
+ " 0.4,\n",
341
+ " 0.4,\n",
342
+ " 0.4,\n",
343
+ " 0.4,\n",
344
+ " 0.4,\n",
345
+ " 0.4,\n",
346
+ " 0.4,\n",
347
+ " 0.4,\n",
348
+ " 0.4,\n",
349
+ " 0.4,\n",
350
+ " 0.4,\n",
351
+ " 0.4,\n",
352
+ " 0.4,\n",
353
+ " 0.4,\n",
354
+ " 0.4,\n",
355
+ " 0.4,\n",
356
+ " 0.4,\n",
357
+ " 0.4,\n",
358
+ " 0.4,\n",
359
+ " 0.4,\n",
360
+ " 0.4,\n",
361
+ " 0.4,\n",
362
+ " 0.4,\n",
363
+ " 0.4,\n",
364
+ " 0.4,\n",
365
+ " 0.4,\n",
366
+ " 0.4,\n",
367
+ " 0.4,\n",
368
+ " 0.4,\n",
369
+ " 0.4,\n",
370
+ " 0.4,\n",
371
+ " 0.4,\n",
372
+ " 0.4,\n",
373
+ " 0.4,\n",
374
+ " 0.4,\n",
375
+ " 0.4,\n",
376
+ " 0.4,\n",
377
+ " 0.4,\n",
378
+ " 0.4,\n",
379
+ " 0.4,\n",
380
+ " 0.4,\n",
381
+ " 0.4,\n",
382
+ " 0.4,\n",
383
+ " 0.4,\n",
384
+ " 0.4,\n",
385
+ " 0.4,\n",
386
+ " 0.4,\n",
387
+ " 0.4,\n",
388
+ " 0.4,\n",
389
+ " 0.4,\n",
390
+ " 0.4,\n",
391
+ " 0.4,\n",
392
+ " 0.4,\n",
393
+ " 0.4,\n",
394
+ " 0.4,\n",
395
+ " 0.4,\n",
396
+ " 0.4,\n",
397
+ " 0.4,\n",
398
+ " 0.4,\n",
399
+ " 0.4,\n",
400
+ " 0.4,\n",
401
+ " 0.4,\n",
402
+ " 0.4,\n",
403
+ " 0.4,\n",
404
+ " 0.4,\n",
405
+ " 0.4,\n",
406
+ " 0.4,\n",
407
+ " 0.4,\n",
408
+ " 0.4,\n",
409
+ " 0.4,\n",
410
+ " 0.4,\n",
411
+ " 0.4,\n",
412
+ " 0.4,\n",
413
+ " 0.4,\n",
414
+ " 0.4,\n",
415
+ " 0.4,\n",
416
+ " 0.4,\n",
417
+ " 0.4,\n",
418
+ " 0.4,\n",
419
+ " 0.4,\n",
420
+ " 0.4,\n",
421
+ " 0.4,\n",
422
+ " 0.4,\n",
423
+ " 0.4,\n",
424
+ " 0.4,\n",
425
+ " 0.4,\n",
426
+ " 0.4,\n",
427
+ " 0.4,\n",
428
+ " 0.4,\n",
429
+ " 0.4,\n",
430
+ " 0.4,\n",
431
+ " 0.4,\n",
432
+ " 0.4,\n",
433
+ " 0.4,\n",
434
+ " 0.4,\n",
435
+ " 0.4,\n",
436
+ " 0.4,\n",
437
+ " 0.4,\n",
438
+ " 0.4,\n",
439
+ " 0.4,\n",
440
+ " 0.4,\n",
441
+ " 0.4,\n",
442
+ " 0.4,\n",
443
+ " 0.4,\n",
444
+ " 0.4,\n",
445
+ " 0.4,\n",
446
+ " 0.4,\n",
447
+ " 0.4,\n",
448
+ " 0.4,\n",
449
+ " 0.4,\n",
450
+ " 0.4,\n",
451
+ " 0.4,\n",
452
+ " 0.4,\n",
453
+ " 0.4,\n",
454
+ " 0.4,\n",
455
+ " 0.4,\n",
456
+ " 0.4,\n",
457
+ " 0.4,\n",
458
+ " 0.4,\n",
459
+ " 0.4,\n",
460
+ " 0.4,\n",
461
+ " 0.4,\n",
462
+ " 0.4,\n",
463
+ " 0.4,\n",
464
+ " 0.4,\n",
465
+ " 0.4,\n",
466
+ " 0.4,\n",
467
+ " 0.4,\n",
468
+ " 0.4,\n",
469
+ " 0.4,\n",
470
+ " 0.4,\n",
471
+ " 0.4,\n",
472
+ " 0.4,\n",
473
+ " 0.4,\n",
474
+ " 0.4,\n",
475
+ " 0.4,\n",
476
+ " 0.4,\n",
477
+ " 0.4,\n",
478
+ " 0.4,\n",
479
+ " 0.4,\n",
480
+ " 0.4,\n",
481
+ " 0.4,\n",
482
+ " 0.4,\n",
483
+ " 0.4,\n",
484
+ " 0.4,\n",
485
+ " 0.4,\n",
486
+ " 0.4,\n",
487
+ " 0.4,\n",
488
+ " 0.4,\n",
489
+ " 0.4,\n",
490
+ " 0.4,\n",
491
+ " 0.4,\n",
492
+ " 0.4,\n",
493
+ " 0.4,\n",
494
+ " 0.4,\n",
495
+ " 0.4,\n",
496
+ " 0.4,\n",
497
+ " 0.4,\n",
498
+ " 0.4,\n",
499
+ " 0.4,\n",
500
+ " 0.4,\n",
501
+ " 0.4,\n",
502
+ " 0.4,\n",
503
+ " 0.4,\n",
504
+ " 0.4,\n",
505
+ " 0.4,\n",
506
+ " 0.4,\n",
507
+ " 0.4,\n",
508
+ " 0.4,\n",
509
+ " 0.4,\n",
510
+ " 0.4,\n",
511
+ " 0.4,\n",
512
+ " 0.4,\n",
513
+ " 0.4,\n",
514
+ " 0.4,\n",
515
+ " 0.4,\n",
516
+ " 0.4,\n",
517
+ " 0.4,\n",
518
+ " 0.4,\n",
519
+ " 0.4,\n",
520
+ " 0.4,\n",
521
+ " 0.4,\n",
522
+ " 0.4,\n",
523
+ " 0.4,\n",
524
+ " 0.4,\n",
525
+ " 0.4,\n",
526
+ " 0.4,\n",
527
+ " 0.4,\n",
528
+ " 0.4,\n",
529
+ " 0.4,\n",
530
+ " 0.4,\n",
531
+ " 0.4,\n",
532
+ " 0.4,\n",
533
+ " 0.4,\n",
534
+ " 0.4,\n",
535
+ " 0.4,\n",
536
+ " 0.4,\n",
537
+ " 0.4,\n",
538
+ " 0.4,\n",
539
+ " 0.4,\n",
540
+ " 0.4,\n",
541
+ " 0.4,\n",
542
+ " 0.4,\n",
543
+ " 0.4,\n",
544
+ " 0.4,\n",
545
+ " 0.4,\n",
546
+ " 0.4,\n",
547
+ " 0.4,\n",
548
+ " 0.4,\n",
549
+ " 0.4,\n",
550
+ " 0.4,\n",
551
+ " 0.4,\n",
552
+ " 0.4,\n",
553
+ " 0.4,\n",
554
+ " 0.4,\n",
555
+ " 0.4,\n",
556
+ " 0.4,\n",
557
+ " 0.4,\n",
558
+ " 0.4,\n",
559
+ " 0.4,\n",
560
+ " 0.4,\n",
561
+ " 0.4]},\n",
562
+ " {'id': 'vec2',\n",
563
+ " 'metadata': {'genre': 'action'},\n",
564
+ " 'score': 0.999999106,\n",
565
+ " 'values': [0.2,\n",
566
+ " 0.2,\n",
567
+ " 0.2,\n",
568
+ " 0.2,\n",
569
+ " 0.2,\n",
570
+ " 0.2,\n",
571
+ " 0.2,\n",
572
+ " 0.2,\n",
573
+ " 0.2,\n",
574
+ " 0.2,\n",
575
+ " 0.2,\n",
576
+ " 0.2,\n",
577
+ " 0.2,\n",
578
+ " 0.2,\n",
579
+ " 0.2,\n",
580
+ " 0.2,\n",
581
+ " 0.2,\n",
582
+ " 0.2,\n",
583
+ " 0.2,\n",
584
+ " 0.2,\n",
585
+ " 0.2,\n",
586
+ " 0.2,\n",
587
+ " 0.2,\n",
588
+ " 0.2,\n",
589
+ " 0.2,\n",
590
+ " 0.2,\n",
591
+ " 0.2,\n",
592
+ " 0.2,\n",
593
+ " 0.2,\n",
594
+ " 0.2,\n",
595
+ " 0.2,\n",
596
+ " 0.2,\n",
597
+ " 0.2,\n",
598
+ " 0.2,\n",
599
+ " 0.2,\n",
600
+ " 0.2,\n",
601
+ " 0.2,\n",
602
+ " 0.2,\n",
603
+ " 0.2,\n",
604
+ " 0.2,\n",
605
+ " 0.2,\n",
606
+ " 0.2,\n",
607
+ " 0.2,\n",
608
+ " 0.2,\n",
609
+ " 0.2,\n",
610
+ " 0.2,\n",
611
+ " 0.2,\n",
612
+ " 0.2,\n",
613
+ " 0.2,\n",
614
+ " 0.2,\n",
615
+ " 0.2,\n",
616
+ " 0.2,\n",
617
+ " 0.2,\n",
618
+ " 0.2,\n",
619
+ " 0.2,\n",
620
+ " 0.2,\n",
621
+ " 0.2,\n",
622
+ " 0.2,\n",
623
+ " 0.2,\n",
624
+ " 0.2,\n",
625
+ " 0.2,\n",
626
+ " 0.2,\n",
627
+ " 0.2,\n",
628
+ " 0.2,\n",
629
+ " 0.2,\n",
630
+ " 0.2,\n",
631
+ " 0.2,\n",
632
+ " 0.2,\n",
633
+ " 0.2,\n",
634
+ " 0.2,\n",
635
+ " 0.2,\n",
636
+ " 0.2,\n",
637
+ " 0.2,\n",
638
+ " 0.2,\n",
639
+ " 0.2,\n",
640
+ " 0.2,\n",
641
+ " 0.2,\n",
642
+ " 0.2,\n",
643
+ " 0.2,\n",
644
+ " 0.2,\n",
645
+ " 0.2,\n",
646
+ " 0.2,\n",
647
+ " 0.2,\n",
648
+ " 0.2,\n",
649
+ " 0.2,\n",
650
+ " 0.2,\n",
651
+ " 0.2,\n",
652
+ " 0.2,\n",
653
+ " 0.2,\n",
654
+ " 0.2,\n",
655
+ " 0.2,\n",
656
+ " 0.2,\n",
657
+ " 0.2,\n",
658
+ " 0.2,\n",
659
+ " 0.2,\n",
660
+ " 0.2,\n",
661
+ " 0.2,\n",
662
+ " 0.2,\n",
663
+ " 0.2,\n",
664
+ " 0.2,\n",
665
+ " 0.2,\n",
666
+ " 0.2,\n",
667
+ " 0.2,\n",
668
+ " 0.2,\n",
669
+ " 0.2,\n",
670
+ " 0.2,\n",
671
+ " 0.2,\n",
672
+ " 0.2,\n",
673
+ " 0.2,\n",
674
+ " 0.2,\n",
675
+ " 0.2,\n",
676
+ " 0.2,\n",
677
+ " 0.2,\n",
678
+ " 0.2,\n",
679
+ " 0.2,\n",
680
+ " 0.2,\n",
681
+ " 0.2,\n",
682
+ " 0.2,\n",
683
+ " 0.2,\n",
684
+ " 0.2,\n",
685
+ " 0.2,\n",
686
+ " 0.2,\n",
687
+ " 0.2,\n",
688
+ " 0.2,\n",
689
+ " 0.2,\n",
690
+ " 0.2,\n",
691
+ " 0.2,\n",
692
+ " 0.2,\n",
693
+ " 0.2,\n",
694
+ " 0.2,\n",
695
+ " 0.2,\n",
696
+ " 0.2,\n",
697
+ " 0.2,\n",
698
+ " 0.2,\n",
699
+ " 0.2,\n",
700
+ " 0.2,\n",
701
+ " 0.2,\n",
702
+ " 0.2,\n",
703
+ " 0.2,\n",
704
+ " 0.2,\n",
705
+ " 0.2,\n",
706
+ " 0.2,\n",
707
+ " 0.2,\n",
708
+ " 0.2,\n",
709
+ " 0.2,\n",
710
+ " 0.2,\n",
711
+ " 0.2,\n",
712
+ " 0.2,\n",
713
+ " 0.2,\n",
714
+ " 0.2,\n",
715
+ " 0.2,\n",
716
+ " 0.2,\n",
717
+ " 0.2,\n",
718
+ " 0.2,\n",
719
+ " 0.2,\n",
720
+ " 0.2,\n",
721
+ " 0.2,\n",
722
+ " 0.2,\n",
723
+ " 0.2,\n",
724
+ " 0.2,\n",
725
+ " 0.2,\n",
726
+ " 0.2,\n",
727
+ " 0.2,\n",
728
+ " 0.2,\n",
729
+ " 0.2,\n",
730
+ " 0.2,\n",
731
+ " 0.2,\n",
732
+ " 0.2,\n",
733
+ " 0.2,\n",
734
+ " 0.2,\n",
735
+ " 0.2,\n",
736
+ " 0.2,\n",
737
+ " 0.2,\n",
738
+ " 0.2,\n",
739
+ " 0.2,\n",
740
+ " 0.2,\n",
741
+ " 0.2,\n",
742
+ " 0.2,\n",
743
+ " 0.2,\n",
744
+ " 0.2,\n",
745
+ " 0.2,\n",
746
+ " 0.2,\n",
747
+ " 0.2,\n",
748
+ " 0.2,\n",
749
+ " 0.2,\n",
750
+ " 0.2,\n",
751
+ " 0.2,\n",
752
+ " 0.2,\n",
753
+ " 0.2,\n",
754
+ " 0.2,\n",
755
+ " 0.2,\n",
756
+ " 0.2,\n",
757
+ " 0.2,\n",
758
+ " 0.2,\n",
759
+ " 0.2,\n",
760
+ " 0.2,\n",
761
+ " 0.2,\n",
762
+ " 0.2,\n",
763
+ " 0.2,\n",
764
+ " 0.2,\n",
765
+ " 0.2,\n",
766
+ " 0.2,\n",
767
+ " 0.2,\n",
768
+ " 0.2,\n",
769
+ " 0.2,\n",
770
+ " 0.2,\n",
771
+ " 0.2,\n",
772
+ " 0.2,\n",
773
+ " 0.2,\n",
774
+ " 0.2,\n",
775
+ " 0.2,\n",
776
+ " 0.2,\n",
777
+ " 0.2,\n",
778
+ " 0.2,\n",
779
+ " 0.2,\n",
780
+ " 0.2,\n",
781
+ " 0.2,\n",
782
+ " 0.2,\n",
783
+ " 0.2,\n",
784
+ " 0.2,\n",
785
+ " 0.2,\n",
786
+ " 0.2,\n",
787
+ " 0.2,\n",
788
+ " 0.2,\n",
789
+ " 0.2,\n",
790
+ " 0.2,\n",
791
+ " 0.2,\n",
792
+ " 0.2,\n",
793
+ " 0.2,\n",
794
+ " 0.2,\n",
795
+ " 0.2,\n",
796
+ " 0.2,\n",
797
+ " 0.2,\n",
798
+ " 0.2,\n",
799
+ " 0.2,\n",
800
+ " 0.2,\n",
801
+ " 0.2,\n",
802
+ " 0.2,\n",
803
+ " 0.2,\n",
804
+ " 0.2,\n",
805
+ " 0.2,\n",
806
+ " 0.2,\n",
807
+ " 0.2,\n",
808
+ " 0.2,\n",
809
+ " 0.2,\n",
810
+ " 0.2,\n",
811
+ " 0.2,\n",
812
+ " 0.2,\n",
813
+ " 0.2,\n",
814
+ " 0.2,\n",
815
+ " 0.2,\n",
816
+ " 0.2,\n",
817
+ " 0.2,\n",
818
+ " 0.2,\n",
819
+ " 0.2,\n",
820
+ " 0.2,\n",
821
+ " 0.2,\n",
822
+ " 0.2,\n",
823
+ " 0.2,\n",
824
+ " 0.2,\n",
825
+ " 0.2,\n",
826
+ " 0.2,\n",
827
+ " 0.2,\n",
828
+ " 0.2,\n",
829
+ " 0.2,\n",
830
+ " 0.2,\n",
831
+ " 0.2,\n",
832
+ " 0.2,\n",
833
+ " 0.2,\n",
834
+ " 0.2,\n",
835
+ " 0.2,\n",
836
+ " 0.2,\n",
837
+ " 0.2,\n",
838
+ " 0.2,\n",
839
+ " 0.2,\n",
840
+ " 0.2,\n",
841
+ " 0.2,\n",
842
+ " 0.2,\n",
843
+ " 0.2,\n",
844
+ " 0.2,\n",
845
+ " 0.2,\n",
846
+ " 0.2,\n",
847
+ " 0.2,\n",
848
+ " 0.2,\n",
849
+ " 0.2,\n",
850
+ " 0.2,\n",
851
+ " 0.2,\n",
852
+ " 0.2,\n",
853
+ " 0.2,\n",
854
+ " 0.2,\n",
855
+ " 0.2,\n",
856
+ " 0.2,\n",
857
+ " 0.2,\n",
858
+ " 0.2,\n",
859
+ " 0.2,\n",
860
+ " 0.2,\n",
861
+ " 0.2,\n",
862
+ " 0.2,\n",
863
+ " 0.2,\n",
864
+ " 0.2,\n",
865
+ " 0.2,\n",
866
+ " 0.2,\n",
867
+ " 0.2,\n",
868
+ " 0.2,\n",
869
+ " 0.2,\n",
870
+ " 0.2,\n",
871
+ " 0.2,\n",
872
+ " 0.2,\n",
873
+ " 0.2,\n",
874
+ " 0.2,\n",
875
+ " 0.2,\n",
876
+ " 0.2,\n",
877
+ " 0.2,\n",
878
+ " 0.2,\n",
879
+ " 0.2,\n",
880
+ " 0.2,\n",
881
+ " 0.2,\n",
882
+ " 0.2,\n",
883
+ " 0.2,\n",
884
+ " 0.2,\n",
885
+ " 0.2,\n",
886
+ " 0.2,\n",
887
+ " 0.2,\n",
888
+ " 0.2,\n",
889
+ " 0.2,\n",
890
+ " 0.2,\n",
891
+ " 0.2,\n",
892
+ " 0.2,\n",
893
+ " 0.2,\n",
894
+ " 0.2,\n",
895
+ " 0.2,\n",
896
+ " 0.2,\n",
897
+ " 0.2,\n",
898
+ " 0.2,\n",
899
+ " 0.2,\n",
900
+ " 0.2,\n",
901
+ " 0.2,\n",
902
+ " 0.2,\n",
903
+ " 0.2,\n",
904
+ " 0.2,\n",
905
+ " 0.2,\n",
906
+ " 0.2,\n",
907
+ " 0.2,\n",
908
+ " 0.2,\n",
909
+ " 0.2,\n",
910
+ " 0.2,\n",
911
+ " 0.2,\n",
912
+ " 0.2,\n",
913
+ " 0.2,\n",
914
+ " 0.2,\n",
915
+ " 0.2,\n",
916
+ " 0.2,\n",
917
+ " 0.2,\n",
918
+ " 0.2,\n",
919
+ " 0.2,\n",
920
+ " 0.2,\n",
921
+ " 0.2,\n",
922
+ " 0.2,\n",
923
+ " 0.2,\n",
924
+ " 0.2,\n",
925
+ " 0.2,\n",
926
+ " 0.2,\n",
927
+ " 0.2,\n",
928
+ " 0.2,\n",
929
+ " 0.2,\n",
930
+ " 0.2,\n",
931
+ " 0.2,\n",
932
+ " 0.2,\n",
933
+ " 0.2,\n",
934
+ " 0.2,\n",
935
+ " 0.2,\n",
936
+ " 0.2,\n",
937
+ " 0.2,\n",
938
+ " 0.2,\n",
939
+ " 0.2,\n",
940
+ " 0.2,\n",
941
+ " 0.2,\n",
942
+ " 0.2,\n",
943
+ " 0.2,\n",
944
+ " 0.2,\n",
945
+ " 0.2,\n",
946
+ " 0.2,\n",
947
+ " 0.2,\n",
948
+ " 0.2]}],\n",
949
+ " 'namespace': 'ns1',\n",
950
+ " 'usage': {'read_units': 6}}"
951
+ ]
952
+ },
953
+ "execution_count": 7,
954
+ "metadata": {},
955
+ "output_type": "execute_result"
956
+ }
957
+ ],
958
+ "source": [
959
+ "index.query(\n",
960
+ " namespace=\"ns1\",\n",
961
+ " vector=[0.3] * 384,\n",
962
+ " top_k=2,\n",
963
+ " include_values=True,\n",
964
+ " include_metadata=True,\n",
965
+ " filter={\"genre\": {\"$eq\": \"action\"}}\n",
966
+ ")"
967
+ ]
968
+ },
969
+ {
970
+ "cell_type": "code",
971
+ "execution_count": 8,
972
+ "metadata": {},
973
+ "outputs": [],
974
+ "source": [
975
+ "# Extract pdf data\n",
976
+ "from unittest import loader\n",
977
+ "\n",
978
+ "\n",
979
+ "def load_pdf(data):\n",
980
+ " directory_loader = DirectoryLoader(data, \n",
981
+ " glob=\"*.pdf\",\n",
982
+ " loader_cls=PyPDFLoader)\n",
983
+ " \n",
984
+ " documents = directory_loader.load()"
985
+ ]
986
+ },
987
+ {
988
+ "cell_type": "code",
989
+ "execution_count": 9,
990
+ "metadata": {},
991
+ "outputs": [],
992
+ "source": [
993
+ "extracted_data = DirectoryLoader(\"data/\")"
994
+ ]
995
+ },
996
+ {
997
+ "cell_type": "code",
998
+ "execution_count": 10,
999
+ "metadata": {},
1000
+ "outputs": [
1001
+ {
1002
+ "data": {
1003
+ "text/plain": [
1004
+ "<langchain_community.document_loaders.directory.DirectoryLoader at 0x23e7f7e5730>"
1005
+ ]
1006
+ },
1007
+ "execution_count": 10,
1008
+ "metadata": {},
1009
+ "output_type": "execute_result"
1010
+ }
1011
+ ],
1012
+ "source": [
1013
+ "extracted_data"
1014
+ ]
1015
+ },
1016
+ {
1017
+ "cell_type": "code",
1018
+ "execution_count": 11,
1019
+ "metadata": {},
1020
+ "outputs": [],
1021
+ "source": [
1022
+ "def text_split(extracted_data):\n",
1023
+ " text_splitter = RecursiveCharacterTextSplitter(chunk_size = 500, chunk_overlap = 20)\n",
1024
+ " text_chunks = text_splitter.split_documents(extracted_data)\n",
1025
+ "\n",
1026
+ " return text_chunks"
1027
+ ]
1028
+ },
1029
+ {
1030
+ "cell_type": "code",
1031
+ "execution_count": 12,
1032
+ "metadata": {},
1033
+ "outputs": [
1034
+ {
1035
+ "name": "stdout",
1036
+ "output_type": "stream",
1037
+ "text": [
1038
+ "Current working directory: c:\\Users\\kirai\\OneDrive\\Desktop\\Travel bot\\research\n",
1039
+ "Current working directory: c:\\Users\\kirai\\OneDrive\\Desktop\\Travel bot\\research\n"
1040
+ ]
1041
+ },
1042
+ {
1043
+ "name": "stdout",
1044
+ "output_type": "stream",
1045
+ "text": [
1046
+ "536\n"
1047
+ ]
1048
+ }
1049
+ ],
1050
+ "source": [
1051
+ "import os\n",
1052
+ "from langchain_community.document_loaders import DirectoryLoader, PyPDFLoader\n",
1053
+ "from langchain_text_splitters import RecursiveCharacterTextSplitter\n",
1054
+ "\n",
1055
+ "def load_pdf(data):\n",
1056
+ " # Print the current working directory\n",
1057
+ " print(\"Current working directory:\", os.getcwd()) \n",
1058
+ " \n",
1059
+ " # Check if the directory exists\n",
1060
+ " if not os.path.exists(data):\n",
1061
+ " raise FileNotFoundError(f\"Directory not found: '{data}'\")\n",
1062
+ " if not os.path.isdir(data):\n",
1063
+ " raise ValueError(f\"Expected a directory, but got: '{data}'\")\n",
1064
+ " \n",
1065
+ " # Load the documents\n",
1066
+ " directory_loader = DirectoryLoader(data, glob=\"*.pdf\", loader_cls=PyPDFLoader)\n",
1067
+ " documents = directory_loader.load()\n",
1068
+ " return documents\n",
1069
+ "\n",
1070
+ "def text_split(extracted_data):\n",
1071
+ " text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=20)\n",
1072
+ " text_chunks = text_splitter.split_documents(extracted_data)\n",
1073
+ " return text_chunks\n",
1074
+ "\n",
1075
+ "# Check current working directory\n",
1076
+ "print(\"Current working directory:\", os.getcwd())\n",
1077
+ "\n",
1078
+ "# Load the PDFs\n",
1079
+ "extracted_data = load_pdf(\"../data/\") # Ensure this path is correct relative to your script\n",
1080
+ "\n",
1081
+ "# Split the text into chunks\n",
1082
+ "text_chunks = text_split(extracted_data)\n",
1083
+ "print(len(text_chunks))"
1084
+ ]
1085
+ },
1086
+ {
1087
+ "cell_type": "code",
1088
+ "execution_count": 13,
1089
+ "metadata": {},
1090
+ "outputs": [],
1091
+ "source": [
1092
+ "def download_hugging_face_embeddings():\n",
1093
+ " embeddings = HuggingFaceEmbeddings(model_name=\"sentence-transformers/all-MiniLM-L6-v2\")\n",
1094
+ " return embeddings"
1095
+ ]
1096
+ },
1097
+ {
1098
+ "cell_type": "code",
1099
+ "execution_count": 14,
1100
+ "metadata": {},
1101
+ "outputs": [
1102
+ {
1103
+ "name": "stderr",
1104
+ "output_type": "stream",
1105
+ "text": [
1106
+ "c:\\Users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages\\langchain_core\\_api\\deprecation.py:119: LangChainDeprecationWarning: The class `HuggingFaceEmbeddings` was deprecated in LangChain 0.2.2 and will be removed in 0.3.0. An updated version of the class exists in the langchain-huggingface package and should be used instead. To use it run `pip install -U langchain-huggingface` and import as `from langchain_huggingface import HuggingFaceEmbeddings`.\n",
1107
+ " warn_deprecated(\n",
1108
+ "c:\\Users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages\\huggingface_hub\\file_download.py:157: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\\Users\\kirai\\.cache\\huggingface\\hub\\models--sentence-transformers--all-MiniLM-L6-v2. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.\n",
1109
+ "To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to see activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development\n",
1110
+ " warnings.warn(message)\n",
1111
+ "c:\\Users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages\\huggingface_hub\\file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
1112
+ " warnings.warn(\n"
1113
+ ]
1114
+ }
1115
+ ],
1116
+ "source": [
1117
+ "embeddings = download_hugging_face_embeddings()"
1118
+ ]
1119
+ },
1120
+ {
1121
+ "cell_type": "code",
1122
+ "execution_count": 15,
1123
+ "metadata": {},
1124
+ "outputs": [
1125
+ {
1126
+ "data": {
1127
+ "text/plain": [
1128
+ "HuggingFaceEmbeddings(client=SentenceTransformer(\n",
1129
+ " (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel \n",
1130
+ " (1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})\n",
1131
+ " (2): Normalize()\n",
1132
+ "), model_name='sentence-transformers/all-MiniLM-L6-v2', cache_folder=None, model_kwargs={}, encode_kwargs={}, multi_process=False, show_progress=False)"
1133
+ ]
1134
+ },
1135
+ "execution_count": 15,
1136
+ "metadata": {},
1137
+ "output_type": "execute_result"
1138
+ }
1139
+ ],
1140
+ "source": [
1141
+ "embeddings"
1142
+ ]
1143
+ },
1144
+ {
1145
+ "cell_type": "code",
1146
+ "execution_count": 16,
1147
+ "metadata": {},
1148
+ "outputs": [
1149
+ {
1150
+ "name": "stdout",
1151
+ "output_type": "stream",
1152
+ "text": [
1153
+ "length 384\n"
1154
+ ]
1155
+ }
1156
+ ],
1157
+ "source": [
1158
+ "query_result = embeddings.embed_query(\"Hello world\")\n",
1159
+ "print(\"length\", len(query_result))"
1160
+ ]
1161
+ },
1162
+ {
1163
+ "cell_type": "code",
1164
+ "execution_count": 17,
1165
+ "metadata": {},
1166
+ "outputs": [
1167
+ {
1168
+ "data": {
1169
+ "text/plain": [
1170
+ "[-0.03447727486491203,\n",
1171
+ " 0.03102317824959755,\n",
1172
+ " 0.006734970025718212,\n",
1173
+ " 0.026108985766768456,\n",
1174
+ " -0.03936202451586723,\n",
1175
+ " -0.16030244529247284,\n",
1176
+ " 0.06692401319742203,\n",
1177
+ " -0.006441489793360233,\n",
1178
+ " -0.0474504791200161,\n",
1179
+ " 0.014758856035768986,\n",
1180
+ " 0.07087527960538864,\n",
1181
+ " 0.05552763119339943,\n",
1182
+ " 0.019193334504961967,\n",
1183
+ " -0.026251312345266342,\n",
1184
+ " -0.01010954286903143,\n",
1185
+ " -0.02694045566022396,\n",
1186
+ " 0.022307461127638817,\n",
1187
+ " -0.022226648405194283,\n",
1188
+ " -0.14969263970851898,\n",
1189
+ " -0.017493007704615593,\n",
1190
+ " 0.00767625542357564,\n",
1191
+ " 0.05435224249958992,\n",
1192
+ " 0.0032543970737606287,\n",
1193
+ " 0.031725890934467316,\n",
1194
+ " -0.0846213847398758,\n",
1195
+ " -0.02940601296722889,\n",
1196
+ " 0.05159561336040497,\n",
1197
+ " 0.04812406003475189,\n",
1198
+ " -0.0033148222137242556,\n",
1199
+ " -0.058279167860746384,\n",
1200
+ " 0.04196927323937416,\n",
1201
+ " 0.022210685536265373,\n",
1202
+ " 0.1281888335943222,\n",
1203
+ " -0.022338971495628357,\n",
1204
+ " -0.011656315997242928,\n",
1205
+ " 0.06292839348316193,\n",
1206
+ " -0.032876335084438324,\n",
1207
+ " -0.09122604131698608,\n",
1208
+ " -0.031175347045063972,\n",
1209
+ " 0.0526994913816452,\n",
1210
+ " 0.04703482985496521,\n",
1211
+ " -0.08420311659574509,\n",
1212
+ " -0.030056199058890343,\n",
1213
+ " -0.02074483036994934,\n",
1214
+ " 0.009517835453152657,\n",
1215
+ " -0.0037217906210571527,\n",
1216
+ " 0.007343285251408815,\n",
1217
+ " 0.03932438790798187,\n",
1218
+ " 0.0932740643620491,\n",
1219
+ " -0.003788596484810114,\n",
1220
+ " -0.052742067724466324,\n",
1221
+ " -0.05805816128849983,\n",
1222
+ " -0.006864361464977264,\n",
1223
+ " 0.005283191800117493,\n",
1224
+ " 0.0828929990530014,\n",
1225
+ " 0.019362755119800568,\n",
1226
+ " 0.0062844837084412575,\n",
1227
+ " -0.010330787859857082,\n",
1228
+ " 0.009032378904521465,\n",
1229
+ " -0.037683695554733276,\n",
1230
+ " -0.04520607739686966,\n",
1231
+ " 0.024016305804252625,\n",
1232
+ " -0.006944137159734964,\n",
1233
+ " 0.013491630554199219,\n",
1234
+ " 0.10005494207143784,\n",
1235
+ " -0.07168391346931458,\n",
1236
+ " -0.021695120260119438,\n",
1237
+ " 0.031618405133485794,\n",
1238
+ " -0.051634665578603745,\n",
1239
+ " -0.08224772661924362,\n",
1240
+ " -0.06569333374500275,\n",
1241
+ " -0.00989533495157957,\n",
1242
+ " 0.005816374905407429,\n",
1243
+ " 0.07355456054210663,\n",
1244
+ " -0.034050311893224716,\n",
1245
+ " 0.0248861201107502,\n",
1246
+ " 0.014488042332231998,\n",
1247
+ " 0.02645738422870636,\n",
1248
+ " 0.009656722657382488,\n",
1249
+ " 0.0302172489464283,\n",
1250
+ " 0.05280393362045288,\n",
1251
+ " -0.07535984367132187,\n",
1252
+ " 0.009897145442664623,\n",
1253
+ " 0.029836809262633324,\n",
1254
+ " 0.01755557768046856,\n",
1255
+ " 0.023091984912753105,\n",
1256
+ " 0.001933806692250073,\n",
1257
+ " 0.0014002545503899455,\n",
1258
+ " -0.04717595875263214,\n",
1259
+ " -0.011194315738976002,\n",
1260
+ " -0.11420144140720367,\n",
1261
+ " -0.019811924546957016,\n",
1262
+ " 0.040266189724206924,\n",
1263
+ " 0.0021929906215518713,\n",
1264
+ " -0.07979220896959305,\n",
1265
+ " -0.02538231760263443,\n",
1266
+ " 0.09448299556970596,\n",
1267
+ " -0.02898104302585125,\n",
1268
+ " -0.14500252902507782,\n",
1269
+ " 0.23097744584083557,\n",
1270
+ " 0.027731187641620636,\n",
1271
+ " 0.03211146965622902,\n",
1272
+ " 0.03106505796313286,\n",
1273
+ " 0.04283284768462181,\n",
1274
+ " 0.06423777341842651,\n",
1275
+ " 0.03216316178441048,\n",
1276
+ " -0.004876770544797182,\n",
1277
+ " 0.055699463933706284,\n",
1278
+ " -0.03753238171339035,\n",
1279
+ " -0.02150554023683071,\n",
1280
+ " -0.028342634439468384,\n",
1281
+ " -0.028846951201558113,\n",
1282
+ " 0.0383530892431736,\n",
1283
+ " -0.017468664795160294,\n",
1284
+ " 0.052485305815935135,\n",
1285
+ " -0.07487601786851883,\n",
1286
+ " -0.03125976398587227,\n",
1287
+ " 0.021841565147042274,\n",
1288
+ " -0.03989570587873459,\n",
1289
+ " -0.008587091229856014,\n",
1290
+ " 0.026956576853990555,\n",
1291
+ " -0.04849553853273392,\n",
1292
+ " 0.011469882912933826,\n",
1293
+ " 0.02961820363998413,\n",
1294
+ " -0.02057218924164772,\n",
1295
+ " 0.013103843666613102,\n",
1296
+ " 0.028833510354161263,\n",
1297
+ " -3.1941990848222185e-33,\n",
1298
+ " 0.06478213518857956,\n",
1299
+ " -0.018130183219909668,\n",
1300
+ " 0.051789961755275726,\n",
1301
+ " 0.12198275327682495,\n",
1302
+ " 0.028780106455087662,\n",
1303
+ " 0.008721951395273209,\n",
1304
+ " -0.07052119821310043,\n",
1305
+ " -0.016907278448343277,\n",
1306
+ " 0.04073973000049591,\n",
1307
+ " 0.042116157710552216,\n",
1308
+ " 0.025447236374020576,\n",
1309
+ " 0.03574628755450249,\n",
1310
+ " -0.04914471507072449,\n",
1311
+ " 0.0021290204022079706,\n",
1312
+ " -0.015546582639217377,\n",
1313
+ " 0.050730545073747635,\n",
1314
+ " -0.0481853261590004,\n",
1315
+ " 0.03588061034679413,\n",
1316
+ " -0.0040670474991202354,\n",
1317
+ " 0.10172472149133682,\n",
1318
+ " -0.05597002059221268,\n",
1319
+ " -0.010681048966944218,\n",
1320
+ " 0.01123578567057848,\n",
1321
+ " 0.09068653732538223,\n",
1322
+ " 0.004234451334923506,\n",
1323
+ " 0.035138655453920364,\n",
1324
+ " -0.009702847339212894,\n",
1325
+ " -0.09386517852544785,\n",
1326
+ " 0.0928555428981781,\n",
1327
+ " 0.008004927076399326,\n",
1328
+ " -0.007705425377935171,\n",
1329
+ " -0.05208674445748329,\n",
1330
+ " -0.012587991543114185,\n",
1331
+ " 0.0032669377978891134,\n",
1332
+ " 0.006013509817421436,\n",
1333
+ " 0.007581559009850025,\n",
1334
+ " 0.01051718182861805,\n",
1335
+ " -0.08634556829929352,\n",
1336
+ " -0.06987880170345306,\n",
1337
+ " -0.0025338928680866957,\n",
1338
+ " -0.09097658842802048,\n",
1339
+ " 0.04688733071088791,\n",
1340
+ " 0.052076540887355804,\n",
1341
+ " 0.007193844299763441,\n",
1342
+ " 0.010903622955083847,\n",
1343
+ " -0.0052295587956905365,\n",
1344
+ " 0.013937311246991158,\n",
1345
+ " 0.021968349814414978,\n",
1346
+ " 0.03420866280794144,\n",
1347
+ " 0.060224682092666626,\n",
1348
+ " 0.00011665470083244145,\n",
1349
+ " 0.014731976203620434,\n",
1350
+ " -0.07008926570415497,\n",
1351
+ " 0.028499048203229904,\n",
1352
+ " -0.02760172076523304,\n",
1353
+ " 0.010768445208668709,\n",
1354
+ " 0.034830961376428604,\n",
1355
+ " -0.02248787134885788,\n",
1356
+ " 0.009769017808139324,\n",
1357
+ " 0.07722785323858261,\n",
1358
+ " 0.021588314324617386,\n",
1359
+ " 0.11495620757341385,\n",
1360
+ " -0.0680011734366417,\n",
1361
+ " 0.02376098558306694,\n",
1362
+ " -0.0159839428961277,\n",
1363
+ " -0.0178269911557436,\n",
1364
+ " 0.06439495831727982,\n",
1365
+ " 0.032025739550590515,\n",
1366
+ " 0.05027025192975998,\n",
1367
+ " -0.005913770757615566,\n",
1368
+ " -0.03370805084705353,\n",
1369
+ " 0.017840256914496422,\n",
1370
+ " 0.016573317348957062,\n",
1371
+ " 0.06329657882452011,\n",
1372
+ " 0.03467721864581108,\n",
1373
+ " 0.046473488211631775,\n",
1374
+ " 0.09790610522031784,\n",
1375
+ " -0.00663550291210413,\n",
1376
+ " 0.02520712837576866,\n",
1377
+ " -0.07798824459314346,\n",
1378
+ " 0.0169264767318964,\n",
1379
+ " -0.000945797364693135,\n",
1380
+ " 0.022471921518445015,\n",
1381
+ " -0.038253191858530045,\n",
1382
+ " 0.09570474177598953,\n",
1383
+ " -0.005350803025066853,\n",
1384
+ " 0.010469110682606697,\n",
1385
+ " -0.11524055153131485,\n",
1386
+ " -0.013262521475553513,\n",
1387
+ " -0.010709455236792564,\n",
1388
+ " -0.08311725407838821,\n",
1389
+ " 0.07327353954315186,\n",
1390
+ " 0.04939225688576698,\n",
1391
+ " -0.008994322270154953,\n",
1392
+ " -0.09584552049636841,\n",
1393
+ " 3.3661485617505796e-33,\n",
1394
+ " 0.12493184208869934,\n",
1395
+ " 0.01934972032904625,\n",
1396
+ " -0.05822571739554405,\n",
1397
+ " -0.03598826378583908,\n",
1398
+ " -0.05074676498770714,\n",
1399
+ " -0.04566238448023796,\n",
1400
+ " -0.08260336518287659,\n",
1401
+ " 0.1481948047876358,\n",
1402
+ " -0.08842118829488754,\n",
1403
+ " 0.06027443706989288,\n",
1404
+ " 0.05103015899658203,\n",
1405
+ " 0.01030314713716507,\n",
1406
+ " 0.14121422171592712,\n",
1407
+ " 0.03081384487450123,\n",
1408
+ " 0.061033159494400024,\n",
1409
+ " -0.052851270884275436,\n",
1410
+ " 0.1366489678621292,\n",
1411
+ " 0.00918989721685648,\n",
1412
+ " -0.01732518896460533,\n",
1413
+ " -0.012848555110394955,\n",
1414
+ " -0.007995282299816608,\n",
1415
+ " -0.0509800985455513,\n",
1416
+ " -0.05235064774751663,\n",
1417
+ " 0.007593012880533934,\n",
1418
+ " -0.015166307799518108,\n",
1419
+ " 0.01696030981838703,\n",
1420
+ " 0.021270520985126495,\n",
1421
+ " 0.020558107644319534,\n",
1422
+ " -0.12002813816070557,\n",
1423
+ " 0.014461833983659744,\n",
1424
+ " 0.02675991877913475,\n",
1425
+ " 0.025330696254968643,\n",
1426
+ " -0.0427546352148056,\n",
1427
+ " 0.006768387276679277,\n",
1428
+ " -0.01445858459919691,\n",
1429
+ " 0.04526195675134659,\n",
1430
+ " -0.09147648513317108,\n",
1431
+ " -0.019439145922660828,\n",
1432
+ " -0.017833467572927475,\n",
1433
+ " -0.05491018295288086,\n",
1434
+ " -0.052641112357378006,\n",
1435
+ " -0.010459048673510551,\n",
1436
+ " -0.052016086876392365,\n",
1437
+ " 0.020891955122351646,\n",
1438
+ " -0.07997036725282669,\n",
1439
+ " -0.012111340649425983,\n",
1440
+ " -0.05773142725229263,\n",
1441
+ " 0.023178234696388245,\n",
1442
+ " -0.008031732402741909,\n",
1443
+ " -0.02598930336534977,\n",
1444
+ " -0.07995671033859253,\n",
1445
+ " -0.020728832110762596,\n",
1446
+ " 0.048817697912454605,\n",
1447
+ " -0.020389137789607048,\n",
1448
+ " -0.04917657747864723,\n",
1449
+ " 0.014159622602164745,\n",
1450
+ " -0.06362202018499374,\n",
1451
+ " -0.007807393092662096,\n",
1452
+ " 0.01643155701458454,\n",
1453
+ " -0.0256824791431427,\n",
1454
+ " 0.013381040655076504,\n",
1455
+ " 0.026248741894960403,\n",
1456
+ " 0.009978413581848145,\n",
1457
+ " 0.06322886794805527,\n",
1458
+ " 0.002672201255336404,\n",
1459
+ " -0.006582767236977816,\n",
1460
+ " 0.01663188263773918,\n",
1461
+ " 0.03236646577715874,\n",
1462
+ " 0.03794245794415474,\n",
1463
+ " -0.036376070231199265,\n",
1464
+ " -0.006910930387675762,\n",
1465
+ " 0.0001596928050275892,\n",
1466
+ " -0.0016335808904841542,\n",
1467
+ " -0.02727821283042431,\n",
1468
+ " -0.02803807333111763,\n",
1469
+ " 0.049681417644023895,\n",
1470
+ " -0.028867173939943314,\n",
1471
+ " -0.0024180689360946417,\n",
1472
+ " 0.014774908311665058,\n",
1473
+ " 0.009764534421265125,\n",
1474
+ " 0.005797638092190027,\n",
1475
+ " 0.013486160896718502,\n",
1476
+ " 0.0055678957141935825,\n",
1477
+ " 0.03722710534930229,\n",
1478
+ " 0.007232527248561382,\n",
1479
+ " 0.04015626385807991,\n",
1480
+ " 0.08150326460599899,\n",
1481
+ " 0.07199167460203171,\n",
1482
+ " -0.013056126423180103,\n",
1483
+ " -0.0428820475935936,\n",
1484
+ " -0.01101123820990324,\n",
1485
+ " 0.004897820297628641,\n",
1486
+ " -0.009229730814695358,\n",
1487
+ " 0.035191506147384644,\n",
1488
+ " -0.05103502422571182,\n",
1489
+ " -1.571437557856825e-08,\n",
1490
+ " -0.08862441033124924,\n",
1491
+ " 0.02390925958752632,\n",
1492
+ " -0.01623876392841339,\n",
1493
+ " 0.031700510531663895,\n",
1494
+ " 0.027284247800707817,\n",
1495
+ " 0.05246882885694504,\n",
1496
+ " -0.047070957720279694,\n",
1497
+ " -0.058847445994615555,\n",
1498
+ " -0.06320822983980179,\n",
1499
+ " 0.04088849574327469,\n",
1500
+ " 0.04982800409197807,\n",
1501
+ " 0.10655171424150467,\n",
1502
+ " -0.07450230419635773,\n",
1503
+ " -0.012495421804487705,\n",
1504
+ " 0.01837071217596531,\n",
1505
+ " 0.03947412595152855,\n",
1506
+ " -0.024797886610031128,\n",
1507
+ " 0.014516262337565422,\n",
1508
+ " -0.03706921637058258,\n",
1509
+ " 0.02001572772860527,\n",
1510
+ " -4.85817035951186e-05,\n",
1511
+ " 0.00986657664179802,\n",
1512
+ " 0.024838753044605255,\n",
1513
+ " -0.05245814099907875,\n",
1514
+ " 0.029314178973436356,\n",
1515
+ " -0.08719190955162048,\n",
1516
+ " -0.01449968758970499,\n",
1517
+ " 0.026019077748060226,\n",
1518
+ " -0.01874636672437191,\n",
1519
+ " -0.07620512694120407,\n",
1520
+ " 0.03504333272576332,\n",
1521
+ " 0.10363949835300446,\n",
1522
+ " -0.028050510212779045,\n",
1523
+ " 0.012718182988464832,\n",
1524
+ " -0.07632549107074738,\n",
1525
+ " -0.01865232177078724,\n",
1526
+ " 0.02497672848403454,\n",
1527
+ " 0.0814453512430191,\n",
1528
+ " 0.06875883787870407,\n",
1529
+ " -0.0640566498041153,\n",
1530
+ " -0.08389385789632797,\n",
1531
+ " 0.06136231869459152,\n",
1532
+ " -0.033545564860105515,\n",
1533
+ " -0.10615336894989014,\n",
1534
+ " -0.040080588310956955,\n",
1535
+ " 0.032530225813388824,\n",
1536
+ " 0.07662483304738998,\n",
1537
+ " -0.0730162113904953,\n",
1538
+ " 0.00033755265758372843,\n",
1539
+ " -0.040871646255254745,\n",
1540
+ " -0.0757884755730629,\n",
1541
+ " 0.027527665719389915,\n",
1542
+ " 0.07462543249130249,\n",
1543
+ " 0.01771726831793785,\n",
1544
+ " 0.09121846407651901,\n",
1545
+ " 0.11022016406059265,\n",
1546
+ " 0.0005697731394320726,\n",
1547
+ " 0.05146336182951927,\n",
1548
+ " -0.014551310800015926,\n",
1549
+ " 0.03323203697800636,\n",
1550
+ " 0.023792240768671036,\n",
1551
+ " -0.02288980595767498,\n",
1552
+ " 0.038937538862228394,\n",
1553
+ " 0.030206844210624695]"
1554
+ ]
1555
+ },
1556
+ "execution_count": 17,
1557
+ "metadata": {},
1558
+ "output_type": "execute_result"
1559
+ }
1560
+ ],
1561
+ "source": [
1562
+ "query_result"
1563
+ ]
1564
+ },
1565
+ {
1566
+ "cell_type": "code",
1567
+ "execution_count": 18,
1568
+ "metadata": {},
1569
+ "outputs": [
1570
+ {
1571
+ "name": "stdout",
1572
+ "output_type": "stream",
1573
+ "text": [
1574
+ "Requirement already satisfied: pinecone.client in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (4.1.1)\n",
1575
+ "Requirement already satisfied: certifi>=2019.11.17 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone.client) (2024.6.2)\n",
1576
+ "Requirement already satisfied: pinecone-plugin-interface<0.0.8,>=0.0.7 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone.client) (0.0.7)\n",
1577
+ "Requirement already satisfied: tqdm>=4.64.1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone.client) (4.66.4)\n",
1578
+ "Requirement already satisfied: typing-extensions>=3.7.4 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone.client) (4.12.2)\n",
1579
+ "Requirement already satisfied: urllib3>=1.26.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone.client) (2.2.1)\n",
1580
+ "Requirement already satisfied: colorama in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from tqdm>=4.64.1->pinecone.client) (0.4.6)\n",
1581
+ "Requirement already satisfied: langchain_pinecone in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (0.1.1)\n",
1582
+ "Requirement already satisfied: langchain-core<0.3,>=0.1.52 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain_pinecone) (0.2.6)\n",
1583
+ "Requirement already satisfied: numpy<2,>=1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain_pinecone) (1.24.4)\n",
1584
+ "Collecting pinecone-client<4.0.0,>=3.2.2 (from langchain_pinecone)\n",
1585
+ " Using cached pinecone_client-3.2.2-py3-none-any.whl.metadata (16 kB)\n",
1586
+ "Requirement already satisfied: PyYAML>=5.3 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-core<0.3,>=0.1.52->langchain_pinecone) (6.0.1)\n",
1587
+ "Requirement already satisfied: jsonpatch<2.0,>=1.33 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-core<0.3,>=0.1.52->langchain_pinecone) (1.33)\n",
1588
+ "Requirement already satisfied: langsmith<0.2.0,>=0.1.75 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-core<0.3,>=0.1.52->langchain_pinecone) (0.1.77)\n",
1589
+ "Requirement already satisfied: packaging<25,>=23.2 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-core<0.3,>=0.1.52->langchain_pinecone) (23.2)\n",
1590
+ "Requirement already satisfied: pydantic<3,>=1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-core<0.3,>=0.1.52->langchain_pinecone) (1.10.16)\n",
1591
+ "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langchain-core<0.3,>=0.1.52->langchain_pinecone) (8.3.0)\n",
1592
+ "Requirement already satisfied: certifi>=2019.11.17 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client<4.0.0,>=3.2.2->langchain_pinecone) (2024.6.2)\n",
1593
+ "Requirement already satisfied: tqdm>=4.64.1 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client<4.0.0,>=3.2.2->langchain_pinecone) (4.66.4)\n",
1594
+ "Requirement already satisfied: typing-extensions>=3.7.4 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client<4.0.0,>=3.2.2->langchain_pinecone) (4.12.2)\n",
1595
+ "Requirement already satisfied: urllib3>=1.26.0 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from pinecone-client<4.0.0,>=3.2.2->langchain_pinecone) (2.2.1)\n",
1596
+ "Requirement already satisfied: jsonpointer>=1.9 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from jsonpatch<2.0,>=1.33->langchain-core<0.3,>=0.1.52->langchain_pinecone) (3.0.0)\n",
1597
+ "Requirement already satisfied: orjson<4.0.0,>=3.9.14 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langsmith<0.2.0,>=0.1.75->langchain-core<0.3,>=0.1.52->langchain_pinecone) (3.10.4)\n",
1598
+ "Requirement already satisfied: requests<3,>=2 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from langsmith<0.2.0,>=0.1.75->langchain-core<0.3,>=0.1.52->langchain_pinecone) (2.32.3)\n",
1599
+ "Requirement already satisfied: colorama in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from tqdm>=4.64.1->pinecone-client<4.0.0,>=3.2.2->langchain_pinecone) (0.4.6)\n",
1600
+ "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from requests<3,>=2->langsmith<0.2.0,>=0.1.75->langchain-core<0.3,>=0.1.52->langchain_pinecone) (3.3.2)\n",
1601
+ "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages (from requests<3,>=2->langsmith<0.2.0,>=0.1.75->langchain-core<0.3,>=0.1.52->langchain_pinecone) (3.7)\n",
1602
+ "Using cached pinecone_client-3.2.2-py3-none-any.whl (215 kB)\n",
1603
+ "Installing collected packages: pinecone-client\n",
1604
+ " Attempting uninstall: pinecone-client\n",
1605
+ " Found existing installation: pinecone-client 4.1.1\n",
1606
+ " Uninstalling pinecone-client-4.1.1:\n",
1607
+ " Successfully uninstalled pinecone-client-4.1.1\n",
1608
+ "Successfully installed pinecone-client-3.2.2\n"
1609
+ ]
1610
+ }
1611
+ ],
1612
+ "source": [
1613
+ "!pip install pinecone.client\n",
1614
+ "!pip install langchain_pinecone"
1615
+ ]
1616
+ },
1617
+ {
1618
+ "cell_type": "code",
1619
+ "execution_count": 19,
1620
+ "metadata": {},
1621
+ "outputs": [],
1622
+ "source": [
1623
+ "import os\n",
1624
+ "from pinecone import Pinecone\n",
1625
+ "\n",
1626
+ "os.environ['PINECONE_API_KEY'] = PINECONE_API_KEY\n",
1627
+ "\n",
1628
+ "pinecone_instance = Pinecone(api_key=PINECONE_API_KEY, environment='us-east-1') #I dont think this line does anything but sijaitoa just incase\n",
1629
+ "\n",
1630
+ "index_name = \"travel-bot\"\n",
1631
+ "\n",
1632
+ "# Create a PineconeVectorStore instance with the Pinecone instance and index\n",
1633
+ "from langchain_pinecone import PineconeVectorStore\n",
1634
+ "\n",
1635
+ "docsearch = PineconeVectorStore.from_texts([t.page_content for t in text_chunks], embeddings, index_name=index_name)"
1636
+ ]
1637
+ },
1638
+ {
1639
+ "cell_type": "code",
1640
+ "execution_count": 20,
1641
+ "metadata": {},
1642
+ "outputs": [
1643
+ {
1644
+ "name": "stdout",
1645
+ "output_type": "stream",
1646
+ "text": [
1647
+ "Result [Document(page_content='sake of recreation and entertainment. Tourism is the \\nlargest industry in the global economy world. This \\npaper presents the development of tourist based \\nproject, a location based tourist guide application \\ncalled Travel book in which we present a \\npersonalized . This application is for supporting \\ntourist. To explore is the aim of the project. The \\napplication recommends the tourist attractions based \\non the tourist preferences. Recommendations are'), Document(page_content='I. INTRODUCTION \\n \\n Travel and tourism is the leading application \\nfield in e -commerce. From the past decade tourism \\nhas achiev ed considerable growth and its role in the \\nworld economy has increased. The tourist -guide plays \\na decisive role in the tourists’ experience of a tour. \\nTourist guide may guide the visitor in the language of \\ntheir choice which may or may not be understood by \\ntourist or visitors. Travel guide may be area specific'), Document(page_content='related the trip (e.g. calculate money spent for the \\ntrip). \\n \\nII. PROBLEM STATEMENT \\n \\n Over past 10 years tourism has achieved \\nconsiderable growth. Role of tourism in the world \\neconomy has increased. Tourism is the strongest \\nindustry in the global economy world. When people \\nvisit a new city, they consult a travel guide to explore. \\nGuide may be area specific so tourist needs to search \\nfor a new guide every time they visit a new corner of')]\n"
1648
+ ]
1649
+ }
1650
+ ],
1651
+ "source": [
1652
+ "import os\n",
1653
+ "from langchain_pinecone import PineconeVectorStore\n",
1654
+ "from langchain_huggingface import HuggingFaceEmbeddings\n",
1655
+ "\n",
1656
+ "# Set environment variables for your API keys\n",
1657
+ "os.environ['PINECONE_API_KEY'] = PINECONE_API_KEY\n",
1658
+ "\n",
1659
+ "# Initialize the Pinecone index name and embeddings\n",
1660
+ "index_name = \"travel-bot\"\n",
1661
+ "embeddings = HuggingFaceEmbeddings(model_name=\"sentence-transformers/all-MiniLM-L6-v2\") # Adjust the model if necessary to ensure it outputs 384-dimensional vectors\n",
1662
+ "\n",
1663
+ "# Initialize the PineconeVectorStore from an existing index\n",
1664
+ "vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)\n",
1665
+ "\n",
1666
+ "# Perform a similarity search with the query\n",
1667
+ "query = \"What is tourism\"\n",
1668
+ "docs = vectorstore.similarity_search(query, k=3)\n",
1669
+ "\n",
1670
+ "# Print the results\n",
1671
+ "print(\"Result\", docs)"
1672
+ ]
1673
+ },
1674
+ {
1675
+ "cell_type": "code",
1676
+ "execution_count": 21,
1677
+ "metadata": {},
1678
+ "outputs": [],
1679
+ "source": [
1680
+ "prompt_template=\"\"\"\n",
1681
+ "Use the following pieces of information to answer the user's question.\n",
1682
+ "If you don't know the answer, just say that you don't know, don't try to make up an answer.\n",
1683
+ "\n",
1684
+ "Context: {context}\n",
1685
+ "Question: {question}\n",
1686
+ "\n",
1687
+ "Only return the helpful answer below and nothing else.\n",
1688
+ "Helpful answer:\n",
1689
+ "\"\"\""
1690
+ ]
1691
+ },
1692
+ {
1693
+ "cell_type": "code",
1694
+ "execution_count": 22,
1695
+ "metadata": {},
1696
+ "outputs": [],
1697
+ "source": [
1698
+ "PROMPT=PromptTemplate(template=prompt_template, input_variables=[\"context\", \"question\"])\n",
1699
+ "chain_type_kwargs={\"prompt\": PROMPT}"
1700
+ ]
1701
+ },
1702
+ {
1703
+ "cell_type": "code",
1704
+ "execution_count": 23,
1705
+ "metadata": {},
1706
+ "outputs": [
1707
+ {
1708
+ "name": "stdout",
1709
+ "output_type": "stream",
1710
+ "text": [
1711
+ "Current working directory: c:\\Users\\kirai\\OneDrive\\Desktop\\Travel bot\\research\n",
1712
+ "Model exists: True\n"
1713
+ ]
1714
+ }
1715
+ ],
1716
+ "source": [
1717
+ "import os\n",
1718
+ "\n",
1719
+ "# Print current working directory\n",
1720
+ "print(\"Current working directory:\", os.getcwd())\n",
1721
+ "\n",
1722
+ "# Check if the file exists\n",
1723
+ "model_path = \"model/llama-2-7b-chat.ggmlv3.q4_0 (1).bin\"\n",
1724
+ "print(\"Model exists:\", os.path.exists(model_path))\n",
1725
+ "\n",
1726
+ "# Load the model if the path is correct\n",
1727
+ "if os.path.exists(model_path):\n",
1728
+ " llm = CTransformers(model=model_path, model_type=\"llama\", config={'max_new_tokens': 512, 'temperature': 0.8})\n",
1729
+ "else:\n",
1730
+ " print(\"Model path is incorrect. Please check the file path.\")\n"
1731
+ ]
1732
+ },
1733
+ {
1734
+ "cell_type": "code",
1735
+ "execution_count": 24,
1736
+ "metadata": {},
1737
+ "outputs": [],
1738
+ "source": [
1739
+ "llm=CTransformers(model=\"model/llama-2-7b-chat.ggmlv3.q4_0 (1).bin\",\n",
1740
+ " model_type=\"llama\",\n",
1741
+ " config={'max_new_tokens':512,\n",
1742
+ " 'temperature':0.8})"
1743
+ ]
1744
+ },
1745
+ {
1746
+ "cell_type": "code",
1747
+ "execution_count": 25,
1748
+ "metadata": {},
1749
+ "outputs": [],
1750
+ "source": [
1751
+ "qa=RetrievalQA.from_chain_type(\n",
1752
+ " llm=llm, \n",
1753
+ " chain_type=\"stuff\", \n",
1754
+ " retriever=docsearch.as_retriever(search_kwargs={'k': 2}),\n",
1755
+ " return_source_documents=True, \n",
1756
+ " chain_type_kwargs=chain_type_kwargs)"
1757
+ ]
1758
+ },
1759
+ {
1760
+ "cell_type": "code",
1761
+ "execution_count": 26,
1762
+ "metadata": {},
1763
+ "outputs": [
1764
+ {
1765
+ "name": "stderr",
1766
+ "output_type": "stream",
1767
+ "text": [
1768
+ "c:\\Users\\kirai\\anaconda3\\envs\\mchatbot\\lib\\site-packages\\langchain_core\\_api\\deprecation.py:119: LangChainDeprecationWarning: The method `Chain.__call__` was deprecated in langchain 0.1.0 and will be removed in 0.3.0. Use invoke instead.\n",
1769
+ " warn_deprecated(\n"
1770
+ ]
1771
+ },
1772
+ {
1773
+ "name": "stdout",
1774
+ "output_type": "stream",
1775
+ "text": [
1776
+ "Response : The report by Okello et al. (2005) suggests that marketing campaigns should introduce other aspects of the park beyond just its natural beauty, such as its unique aesthetics, culture, and Mt. Kili manjaro. This can help abate negative tourist impacts by diversifying the target audience and creating a more sustainable tourism industry.\n"
1777
+ ]
1778
+ }
1779
+ ],
1780
+ "source": [
1781
+ "while True:\n",
1782
+ " user_input=input(f\"Input Prompt:\")\n",
1783
+ " result=qa({\"query\": user_input})\n",
1784
+ " print(\"Response : \", result[\"result\"])"
1785
+ ]
1786
+ },
1787
+ {
1788
+ "cell_type": "code",
1789
+ "execution_count": null,
1790
+ "metadata": {},
1791
+ "outputs": [],
1792
+ "source": []
1793
+ }
1794
+ ],
1795
+ "metadata": {
1796
+ "kernelspec": {
1797
+ "display_name": "mchatbot",
1798
+ "language": "python",
1799
+ "name": "python3"
1800
+ },
1801
+ "language_info": {
1802
+ "codemirror_mode": {
1803
+ "name": "ipython",
1804
+ "version": 3
1805
+ },
1806
+ "file_extension": ".py",
1807
+ "mimetype": "text/x-python",
1808
+ "name": "python",
1809
+ "nbconvert_exporter": "python",
1810
+ "pygments_lexer": "ipython3",
1811
+ "version": "3.8.19"
1812
+ }
1813
+ },
1814
+ "nbformat": 4,
1815
+ "nbformat_minor": 2
1816
+ }
setup.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import find_packages, setup
2
+
3
+ setup(
4
+ name = 'Medical Chatbot',
5
+ version= '0.0.0',
6
+ author= 'Kevin Kirai',
7
+ author_email= '[email protected]',
8
+ packages= find_packages(),
9
+ install_requires = []
10
+
11
+ )
src/__init__.py ADDED
File without changes
src/__pycache__/__init__.cpython-38.pyc ADDED
Binary file (149 Bytes). View file
 
src/__pycache__/helper.cpython-38.pyc ADDED
Binary file (1.49 kB). View file
 
src/helper.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain import PromptTemplate
2
+ from langchain.chains import RetrievalQA
3
+ from langchain.embeddings import HuggingFaceEmbeddings
4
+ from langchain.vectorstores import Pinecone
5
+
6
+ from pinecone import Pinecone
7
+ from langchain.document_loaders import PyPDFLoader, DirectoryLoader
8
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
9
+ from langchain.prompts import PromptTemplate
10
+ from langchain.llms import CTransformers
11
+ from dotenv import load_dotenv
12
+ import os
13
+ from unittest import loader
14
+
15
+ load_dotenv()
16
+
17
+ PINECONE_API_KEY = os.environ.get('PINECONE_API_KEY')
18
+ PINECONE_API_ENV = os.environ.get('PINECONE_API_ENV')
19
+
20
+ # Extract pdf data
21
+ from unittest import loader
22
+
23
+
24
+ def load_pdf(data):
25
+ directory_loader = DirectoryLoader(data,
26
+ glob="*.pdf",
27
+ loader_cls=PyPDFLoader)
28
+
29
+ documents = directory_loader.load()
30
+
31
+ def text_split(extracted_data):
32
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size = 500, chunk_overlap = 20)
33
+ text_chunks = text_splitter.split_documents(extracted_data)
34
+
35
+ return text_chunks
36
+
37
+ def download_hugging_face_embeddings():
38
+ embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
39
+ return embeddings
40
+
src/prompt.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ prompt_template="""
2
+ You are a helpful assistant. You should not express yourself as a human or try to be harmful in any way.
3
+
4
+ Use the following pieces of information to answer the user's question. If you don't know the answer, simply state that you don't know; do not attempt to fabricate an answer. Avoid imitating the user's phrasing or style in your response.
5
+
6
+ Context: {context}
7
+ Question: {question}
8
+
9
+ Provide only the helpful answer below:
10
+ Helpful answer:
11
+
12
+ """
13
+
static/.gitkeep ADDED
File without changes
static/style.css ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body,html{
2
+ height: 100%;
3
+ margin: 0;
4
+ background: rgb(44, 47, 59);
5
+ background: -webkit-linear-gradient(to right, rgb(40, 59, 34), rgb(54, 60, 70), rgb(32, 32, 43));
6
+ background: linear-gradient(to right, rgb(38, 51, 61), rgb(50, 55, 65), rgb(33, 33, 78));
7
+ }
8
+
9
+ .chat{
10
+ margin-top: auto;
11
+ margin-bottom: auto;
12
+ }
13
+ .card{
14
+ height: 500px;
15
+ border-radius: 15px !important;
16
+ background-color: rgba(0,0,0,0.4) !important;
17
+ }
18
+ .contacts_body{
19
+ padding: 0.75rem 0 !important;
20
+ overflow-y: auto;
21
+ white-space: nowrap;
22
+ }
23
+ .msg_card_body{
24
+ overflow-y: auto;
25
+ }
26
+ .card-header{
27
+ border-radius: 15px 15px 0 0 !important;
28
+ border-bottom: 0 !important;
29
+ }
30
+ .card-footer{
31
+ border-radius: 0 0 15px 15px !important;
32
+ border-top: 0 !important;
33
+ }
34
+ .container{
35
+ align-content: center;
36
+ }
37
+ .search{
38
+ border-radius: 15px 0 0 15px !important;
39
+ background-color: rgba(0,0,0,0.3) !important;
40
+ border:0 !important;
41
+ color:white !important;
42
+ }
43
+ .search:focus{
44
+ box-shadow:none !important;
45
+ outline:0px !important;
46
+ }
47
+ .type_msg{
48
+ background-color: rgba(0,0,0,0.3) !important;
49
+ border:0 !important;
50
+ color:white !important;
51
+ height: 60px !important;
52
+ overflow-y: auto;
53
+ }
54
+ .type_msg:focus{
55
+ box-shadow:none !important;
56
+ outline:0px !important;
57
+ }
58
+ .attach_btn{
59
+ border-radius: 15px 0 0 15px !important;
60
+ background-color: rgba(0,0,0,0.3) !important;
61
+ border:0 !important;
62
+ color: white !important;
63
+ cursor: pointer;
64
+ }
65
+ .send_btn{
66
+ border-radius: 0 15px 15px 0 !important;
67
+ background-color: rgba(0,0,0,0.3) !important;
68
+ border:0 !important;
69
+ color: white !important;
70
+ cursor: pointer;
71
+ }
72
+ .search_btn{
73
+ border-radius: 0 15px 15px 0 !important;
74
+ background-color: rgba(0,0,0,0.3) !important;
75
+ border:0 !important;
76
+ color: white !important;
77
+ cursor: pointer;
78
+ }
79
+ .contacts{
80
+ list-style: none;
81
+ padding: 0;
82
+ }
83
+ .contacts li{
84
+ width: 100% !important;
85
+ padding: 5px 10px;
86
+ margin-bottom: 15px !important;
87
+ }
88
+ .active{
89
+ background-color: rgba(0,0,0,0.3);
90
+ }
91
+ .user_img{
92
+ height: 70px;
93
+ width: 70px;
94
+ border:1.5px solid #f5f6fa;
95
+
96
+ }
97
+ .user_img_msg{
98
+ height: 40px;
99
+ width: 40px;
100
+ border:1.5px solid #f5f6fa;
101
+
102
+ }
103
+ .img_cont{
104
+ position: relative;
105
+ height: 70px;
106
+ width: 70px;
107
+ }
108
+ .img_cont_msg{
109
+ height: 40px;
110
+ width: 40px;
111
+ }
112
+ .online_icon{
113
+ position: absolute;
114
+ height: 15px;
115
+ width:15px;
116
+ background-color: #4cd137;
117
+ border-radius: 50%;
118
+ bottom: 0.2em;
119
+ right: 0.4em;
120
+ border:1.5px solid white;
121
+ }
122
+ .offline{
123
+ background-color: #c23616 !important;
124
+ }
125
+ .user_info{
126
+ margin-top: auto;
127
+ margin-bottom: auto;
128
+ margin-left: 15px;
129
+ }
130
+ .user_info span{
131
+ font-size: 20px;
132
+ color: white;
133
+ }
134
+ .user_info p{
135
+ font-size: 10px;
136
+ color: rgba(255,255,255,0.6);
137
+ }
138
+ .video_cam{
139
+ margin-left: 50px;
140
+ margin-top: 5px;
141
+ }
142
+ .video_cam span{
143
+ color: white;
144
+ font-size: 20px;
145
+ cursor: pointer;
146
+ margin-right: 20px;
147
+ }
148
+ .msg_cotainer{
149
+ margin-top: auto;
150
+ margin-bottom: auto;
151
+ margin-left: 10px;
152
+ border-radius: 25px;
153
+ background-color: rgb(82, 172, 255);
154
+ padding: 10px;
155
+ position: relative;
156
+ }
157
+ .msg_cotainer_send{
158
+ margin-top: auto;
159
+ margin-bottom: auto;
160
+ margin-right: 10px;
161
+ border-radius: 25px;
162
+ background-color: #58cc71;
163
+ padding: 10px;
164
+ position: relative;
165
+ }
166
+ .msg_time{
167
+ position: absolute;
168
+ left: 0;
169
+ bottom: -15px;
170
+ color: rgba(255,255,255,0.5);
171
+ font-size: 10px;
172
+ }
173
+ .msg_time_send{
174
+ position: absolute;
175
+ right:0;
176
+ bottom: -15px;
177
+ color: rgba(255,255,255,0.5);
178
+ font-size: 10px;
179
+ }
180
+ .msg_head{
181
+ position: relative;
182
+ }
183
+ #action_menu_btn{
184
+ position: absolute;
185
+ right: 10px;
186
+ top: 10px;
187
+ color: white;
188
+ cursor: pointer;
189
+ font-size: 20px;
190
+ }
191
+ .action_menu{
192
+ z-index: 1;
193
+ position: absolute;
194
+ padding: 15px 0;
195
+ background-color: rgba(0,0,0,0.5);
196
+ color: white;
197
+ border-radius: 15px;
198
+ top: 30px;
199
+ right: 15px;
200
+ display: none;
201
+ }
202
+ .action_menu ul{
203
+ list-style: none;
204
+ padding: 0;
205
+ margin: 0;
206
+ }
207
+ .action_menu ul li{
208
+ width: 100%;
209
+ padding: 10px 15px;
210
+ margin-bottom: 5px;
211
+ }
212
+ .action_menu ul li i{
213
+ padding-right: 10px;
214
+ }
215
+ .action_menu ul li:hover{
216
+ cursor: pointer;
217
+ background-color: rgba(0,0,0,0.2);
218
+ }
219
+ @media(max-width: 576px){
220
+ .contacts_card{
221
+ margin-bottom: 15px !important;
222
+ }
223
+ }
store_index.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import time
3
+ from src.helper import PINECONE_API_KEY, text_split, download_hugging_face_embeddings
4
+ from langchain.vectorstores import Pinecone as LangchainPinecone # Alias to avoid confusion
5
+ from dotenv import load_dotenv
6
+ from pinecone import Pinecone, ServerlessSpec
7
+ from langchain_pinecone import PineconeVectorStore
8
+ from PyPDF2 import PdfReader
9
+
10
+ # Define the load_pdf function
11
+ def load_pdf(file_path):
12
+ all_text = ""
13
+ with open(file_path, 'rb') as file:
14
+ reader = PdfReader(file)
15
+ for page in reader.pages:
16
+ all_text += page.extract_text() + "\n"
17
+ return all_text if all_text else None
18
+
19
+ # Define the text_split function
20
+ def text_split(text):
21
+ from langchain.text_splitter import CharacterTextSplitter
22
+ text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
23
+ return text_splitter.split_text(text)
24
+
25
+ # Load environment variables if not already set
26
+ load_dotenv()
27
+
28
+ # Load and process data
29
+ pdf_file_path = "data/Okelloetal.2008TourismanalysisManka.pdf" # Update this path to your single PDF file
30
+ extracted_data = load_pdf(pdf_file_path)
31
+ if extracted_data is None:
32
+ raise ValueError("The extracted data is None. Please check the load_pdf function.")
33
+
34
+ print(f"Extracted Data: {extracted_data}")
35
+
36
+ # Split the extracted text into chunks
37
+ text_chunks = text_split(extracted_data)
38
+ if text_chunks is None:
39
+ raise ValueError("The text_chunks is None. Please check the text_split function.")
40
+
41
+ print(f"Text Chunks: {text_chunks}")
42
+
43
+ embeddings = download_hugging_face_embeddings()
44
+ if embeddings is None:
45
+ raise ValueError("The embeddings is None. Please check the download_hugging_face_embeddings function.")
46
+
47
+ print(f"Embeddings: {embeddings}")
48
+
49
+ # Ensure Pinecone API key is available
50
+ api_key = os.environ.get("PINECONE_API_KEY")
51
+ if not api_key:
52
+ raise ValueError("PINECONE_API_KEY environment variable not set.")
53
+
54
+ # Initialize Pinecone client
55
+ pc = Pinecone(api_key=api_key)
56
+
57
+ # Specify cloud and region for the serverless index
58
+ cloud = os.environ.get('PINECONE_CLOUD') or 'aws'
59
+ region = os.environ.get('PINECONE_REGION') or 'us-east-1'
60
+ spec = ServerlessSpec(cloud=cloud, region=region)
61
+
62
+ # Define the index name
63
+ index_name = "travel-bot"
64
+
65
+ # Create the index if it does not exist
66
+ if index_name not in pc.list_indexes().names():
67
+ pc.create_index(
68
+ name=index_name,
69
+ dimension=384,
70
+ metric="cosine",
71
+ spec=spec
72
+ )
73
+ # Wait for the index to be ready
74
+ while not pc.describe_index(index_name).status['ready']:
75
+ time.sleep(1)
76
+
77
+ # Connect to the created index
78
+ index = pc.Index(index_name)
79
+ time.sleep(1)
80
+
81
+ # Example: Add data to the index with reduced metadata
82
+ # Create a dictionary to simulate external storage of text chunks
83
+ text_chunk_store = {}
84
+
85
+ # Function to simulate storing text chunk and returning a reference ID
86
+ def store_text_chunk(text_chunk):
87
+ chunk_id = f"chunk_{len(text_chunk_store)}"
88
+ text_chunk_store[chunk_id] = text_chunk
89
+ return chunk_id
90
+
91
+ # Add text chunks to Pinecone with reference IDs
92
+ for i, text_chunk in enumerate(text_chunks):
93
+ chunk_id = store_text_chunk(text_chunk)
94
+ embedding = embeddings.embed_query(text_chunk) # Embed the text chunk
95
+ index.upsert(
96
+ vectors=[
97
+ {
98
+ "id": f"vec_{i}",
99
+ "values": embedding,
100
+ "metadata": {"chunk_id": chunk_id} # Only store the reference ID as metadata
101
+ }
102
+ ],
103
+ namespace="ns1"
104
+ )
105
+
106
+ print("Indexing completed successfully.")
template.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os # Import the os module to interact with the operating system
2
+ from pathlib import Path # Import the Path class from pathlib module for handling file paths
3
+ import logging # Import the logging module for logging messages
4
+
5
+ # Configure the logging to display messages with time and message content
6
+ logging.basicConfig(level=logging.INFO, format='[%(asctime)s]: %(message)s')
7
+
8
+ # List of files that we want to create
9
+ list_of_files = [
10
+ "src/__init__.py", # A Python package initialization file
11
+ "src/helper.py", # A helper module
12
+ "src/prompt.py", # A prompt module
13
+ ".env", # Environment configuration file
14
+ "setup.py", # Python setup script
15
+ "research/trials.ipynb", # Jupyter notebook for research
16
+ "app.py", # Main application script
17
+ "store_index.py", # Index script for storage
18
+ "static/.gitkeep", # Directory for static files (e.g., CSS, JS)
19
+ "templates/chat.html" , # HTML template for chat
20
+
21
+ ]
22
+
23
+ # Iterate over each file path in the list
24
+ for filepath in list_of_files:
25
+ filepath = Path(filepath) # Convert the file path to a Path object
26
+ filedir, filename = os.path.split(filepath) # Split the path into directory and file name
27
+
28
+ # Check if the directory part of the path is not empty
29
+ if filedir:
30
+ os.makedirs(filedir, exist_ok=True) # Create the directory if it doesn't exist
31
+ logging.info(f"Creating directory: {filedir} for the file {filename}") # Log directory creation
32
+
33
+ # Check if the file doesn't exist or if it exists but is empty
34
+ if not os.path.exists(filepath) or os.path.getsize(filepath) == 0:
35
+ with open(filepath, 'w') as f: # Open the file in write mode (this creates an empty file)
36
+ pass # Do nothing else inside the with block
37
+ logging.info(f"Creating empty file: {filepath}") # Log file creation
38
+ else:
39
+ logging.info(f"{filename} is already created") # Log that the file already exists
templates/chat.html ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
2
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
3
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
4
+
5
+ <!DOCTYPE html>
6
+ <html>
7
+ <head>
8
+ <title>Chatbot</title>
9
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
10
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
11
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
12
+ <link rel="stylesheet" href="static/style.css"/>
13
+
14
+ </head>
15
+
16
+
17
+ <body>
18
+ <div class="container-fluid h-100">
19
+ <div class="row justify-content-center h-100">
20
+ <div class="col-md-8 col-xl-6 chat">
21
+ <div class="card">
22
+ <div class="card-header msg_head">
23
+ <div class="d-flex bd-highlight">
24
+ <div class="img_cont">
25
+ <!-- <img src="https://i.ibb.co/fSNP7Rz/icons8-chatgpt-512.png" class="rounded-circle user_img"> -->
26
+ <img src="https://www.prdistribution.com/spirit/uploads/pressreleases/2022/10110226.jpeg" class="rounded-circle user_img">
27
+ <span class="online_icon"></span>
28
+ </div>
29
+ <div class="user_info">
30
+ <span>Travel bot</span>
31
+ <p>Ask me anything!</p>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <div id="messageFormeight" class="card-body msg_card_body">
36
+
37
+
38
+ </div>
39
+ <div class="card-footer">
40
+ <form id="messageArea" class="input-group">
41
+ <input type="text" id="text" name="msg" placeholder="Type your message..." autocomplete="off" class="form-control type_msg" required/>
42
+ <div class="input-group-append">
43
+ <button type="submit" id="send" class="input-group-text send_btn"><i class="fas fa-location-arrow"></i></button>
44
+ </div>
45
+ </form>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </div>
51
+
52
+ <script>
53
+ $(document).ready(function() {
54
+ $("#messageArea").on("submit", function(event) {
55
+ const date = new Date();
56
+ const hour = date.getHours();
57
+ const minute = date.getMinutes();
58
+ const str_time = hour+":"+minute;
59
+ var rawText = $("#text").val();
60
+
61
+ var userHtml = '<div class="d-flex justify-content-end mb-4"><div class="msg_cotainer_send">' + rawText + '<span class="msg_time_send">'+ str_time + '</span></div><div class="img_cont_msg"><img src="https://i.ibb.co/d5b84Xw/Untitled-design.png" class="rounded-circle user_img_msg"></div></div>';
62
+
63
+ $("#text").val("");
64
+ $("#messageFormeight").append(userHtml);
65
+
66
+ $.ajax({
67
+ data: {
68
+ msg: rawText,
69
+ },
70
+ type: "POST",
71
+ url: "/get",
72
+ }).done(function(data) {
73
+ var botHtml = '<div class="d-flex justify-content-start mb-4"><div class="img_cont_msg"><img src="https://www.prdistribution.com/spirit/uploads/pressreleases/2019/newsreleases/d83341deb75c4c4f6b113f27b1e42cd8-chatbot-florence-already-helps-thousands-of-patients-to-remember-their-medication.png" class="rounded-circle user_img_msg"></div><div class="msg_cotainer">' + data + '<span class="msg_time">' + str_time + '</span></div></div>';
74
+ $("#messageFormeight").append($.parseHTML(botHtml));
75
+ });
76
+ event.preventDefault();
77
+ });
78
+ });
79
+ </script>
80
+
81
+ </body>
82
+ </html>
test.ipynb ADDED
@@ -0,0 +1,375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "Requirement already satisfied: pypdf in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (4.2.0)\n",
13
+ "Requirement already satisfied: sentence-transformers in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (2.2.2)\n",
14
+ "Requirement already satisfied: transformers<5.0.0,>=4.6.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (4.41.1)\n",
15
+ "Requirement already satisfied: tqdm in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (4.66.4)\n",
16
+ "Requirement already satisfied: torch>=1.6.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (2.3.1)\n",
17
+ "Requirement already satisfied: torchvision in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (0.18.1)\n",
18
+ "Requirement already satisfied: numpy in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (1.26.4)\n",
19
+ "Requirement already satisfied: scikit-learn in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (1.5.0)\n",
20
+ "Requirement already satisfied: scipy in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (1.13.1)\n",
21
+ "Requirement already satisfied: nltk in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (3.8.1)\n",
22
+ "Requirement already satisfied: sentencepiece in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (0.2.0)\n",
23
+ "Requirement already satisfied: huggingface-hub>=0.4.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sentence-transformers) (0.23.1)\n",
24
+ "Requirement already satisfied: filelock in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface-hub>=0.4.0->sentence-transformers) (3.14.0)\n",
25
+ "Requirement already satisfied: fsspec>=2023.5.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface-hub>=0.4.0->sentence-transformers) (2024.5.0)\n",
26
+ "Requirement already satisfied: packaging>=20.9 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface-hub>=0.4.0->sentence-transformers) (23.2)\n",
27
+ "Requirement already satisfied: pyyaml>=5.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface-hub>=0.4.0->sentence-transformers) (6.0.1)\n",
28
+ "Requirement already satisfied: requests in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface-hub>=0.4.0->sentence-transformers) (2.32.2)\n",
29
+ "Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface-hub>=0.4.0->sentence-transformers) (4.11.0)\n",
30
+ "Requirement already satisfied: sympy in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch>=1.6.0->sentence-transformers) (1.12)\n",
31
+ "Requirement already satisfied: networkx in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch>=1.6.0->sentence-transformers) (3.3)\n",
32
+ "Requirement already satisfied: jinja2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch>=1.6.0->sentence-transformers) (3.1.4)\n",
33
+ "Requirement already satisfied: mkl<=2021.4.0,>=2021.1.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch>=1.6.0->sentence-transformers) (2021.4.0)\n",
34
+ "Requirement already satisfied: colorama in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from tqdm->sentence-transformers) (0.4.6)\n",
35
+ "Requirement already satisfied: regex!=2019.12.17 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from transformers<5.0.0,>=4.6.0->sentence-transformers) (2024.5.15)\n",
36
+ "Requirement already satisfied: tokenizers<0.20,>=0.19 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from transformers<5.0.0,>=4.6.0->sentence-transformers) (0.19.1)\n",
37
+ "Requirement already satisfied: safetensors>=0.4.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from transformers<5.0.0,>=4.6.0->sentence-transformers) (0.4.3)\n",
38
+ "Requirement already satisfied: click in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from nltk->sentence-transformers) (8.1.7)\n",
39
+ "Requirement already satisfied: joblib in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from nltk->sentence-transformers) (1.4.2)\n",
40
+ "Requirement already satisfied: threadpoolctl>=3.1.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from scikit-learn->sentence-transformers) (3.5.0)\n",
41
+ "Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torchvision->sentence-transformers) (10.3.0)\n",
42
+ "Requirement already satisfied: intel-openmp==2021.* in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch>=1.6.0->sentence-transformers) (2021.4.0)\n",
43
+ "Requirement already satisfied: tbb==2021.* in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch>=1.6.0->sentence-transformers) (2021.12.0)\n",
44
+ "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from jinja2->torch>=1.6.0->sentence-transformers) (2.1.5)\n",
45
+ "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests->huggingface-hub>=0.4.0->sentence-transformers) (3.3.2)\n",
46
+ "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests->huggingface-hub>=0.4.0->sentence-transformers) (3.7)\n",
47
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests->huggingface-hub>=0.4.0->sentence-transformers) (2.2.1)\n",
48
+ "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests->huggingface-hub>=0.4.0->sentence-transformers) (2024.2.2)\n",
49
+ "Requirement already satisfied: mpmath>=0.19 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sympy->torch>=1.6.0->sentence-transformers) (1.3.0)\n",
50
+ "Collecting llama_index\n",
51
+ " Downloading llama_index-0.10.44-py3-none-any.whl.metadata (11 kB)\n",
52
+ "Collecting llama-index-agent-openai<0.3.0,>=0.1.4 (from llama_index)\n",
53
+ " Downloading llama_index_agent_openai-0.2.7-py3-none-any.whl.metadata (678 bytes)\n",
54
+ "Collecting llama-index-cli<0.2.0,>=0.1.2 (from llama_index)\n",
55
+ " Downloading llama_index_cli-0.1.12-py3-none-any.whl.metadata (1.5 kB)\n",
56
+ "Collecting llama-index-core==0.10.44 (from llama_index)\n",
57
+ " Downloading llama_index_core-0.10.44-py3-none-any.whl.metadata (2.4 kB)\n",
58
+ "Collecting llama-index-embeddings-openai<0.2.0,>=0.1.5 (from llama_index)\n",
59
+ " Downloading llama_index_embeddings_openai-0.1.10-py3-none-any.whl.metadata (604 bytes)\n",
60
+ "Collecting llama-index-indices-managed-llama-cloud<0.2.0,>=0.1.2 (from llama_index)\n",
61
+ " Downloading llama_index_indices_managed_llama_cloud-0.1.6-py3-none-any.whl.metadata (3.8 kB)\n",
62
+ "Collecting llama-index-legacy<0.10.0,>=0.9.48 (from llama_index)\n",
63
+ " Downloading llama_index_legacy-0.9.48-py3-none-any.whl.metadata (8.5 kB)\n",
64
+ "Collecting llama-index-llms-openai<0.2.0,>=0.1.13 (from llama_index)\n",
65
+ " Downloading llama_index_llms_openai-0.1.22-py3-none-any.whl.metadata (559 bytes)\n",
66
+ "Collecting llama-index-multi-modal-llms-openai<0.2.0,>=0.1.3 (from llama_index)\n",
67
+ " Downloading llama_index_multi_modal_llms_openai-0.1.6-py3-none-any.whl.metadata (677 bytes)\n",
68
+ "Collecting llama-index-program-openai<0.2.0,>=0.1.3 (from llama_index)\n",
69
+ " Downloading llama_index_program_openai-0.1.6-py3-none-any.whl.metadata (715 bytes)\n",
70
+ "Collecting llama-index-question-gen-openai<0.2.0,>=0.1.2 (from llama_index)\n",
71
+ " Downloading llama_index_question_gen_openai-0.1.3-py3-none-any.whl.metadata (785 bytes)\n",
72
+ "Collecting llama-index-readers-file<0.2.0,>=0.1.4 (from llama_index)\n",
73
+ " Downloading llama_index_readers_file-0.1.25-py3-none-any.whl.metadata (5.4 kB)\n",
74
+ "Collecting llama-index-readers-llama-parse<0.2.0,>=0.1.2 (from llama_index)\n",
75
+ " Downloading llama_index_readers_llama_parse-0.1.4-py3-none-any.whl.metadata (3.5 kB)\n",
76
+ "Requirement already satisfied: PyYAML>=6.0.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (6.0.1)\n",
77
+ "Requirement already satisfied: SQLAlchemy>=1.4.49 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core==0.10.44->llama_index) (2.0.30)\n",
78
+ "Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (3.9.5)\n",
79
+ "Requirement already satisfied: dataclasses-json in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (0.5.14)\n",
80
+ "Collecting deprecated>=1.2.9.3 (from llama-index-core==0.10.44->llama_index)\n",
81
+ " Downloading Deprecated-1.2.14-py2.py3-none-any.whl.metadata (5.4 kB)\n",
82
+ "Collecting dirtyjson<2.0.0,>=1.0.8 (from llama-index-core==0.10.44->llama_index)\n",
83
+ " Downloading dirtyjson-1.0.8-py3-none-any.whl.metadata (11 kB)\n",
84
+ "Requirement already satisfied: fsspec>=2023.5.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (2024.5.0)\n",
85
+ "Requirement already satisfied: httpx in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (0.27.0)\n",
86
+ "Collecting llamaindex-py-client<0.2.0,>=0.1.18 (from llama-index-core==0.10.44->llama_index)\n",
87
+ " Downloading llamaindex_py_client-0.1.19-py3-none-any.whl.metadata (760 bytes)\n",
88
+ "Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in c:\\users\\kirai\\appdata\\roaming\\python\\python312\\site-packages (from llama-index-core==0.10.44->llama_index) (1.6.0)\n",
89
+ "Requirement already satisfied: networkx>=3.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (3.3)\n",
90
+ "Requirement already satisfied: nltk<4.0.0,>=3.8.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (3.8.1)\n",
91
+ "Requirement already satisfied: numpy in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (1.26.4)\n",
92
+ "Collecting openai>=1.1.0 (from llama-index-core==0.10.44->llama_index)\n",
93
+ " Using cached openai-1.34.0-py3-none-any.whl.metadata (21 kB)\n",
94
+ "Requirement already satisfied: pandas in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (2.2.2)\n",
95
+ "Requirement already satisfied: pillow>=9.0.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (10.3.0)\n",
96
+ "Requirement already satisfied: requests>=2.31.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (2.32.2)\n",
97
+ "Requirement already satisfied: tenacity<9.0.0,>=8.2.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (8.3.0)\n",
98
+ "Collecting tiktoken>=0.3.3 (from llama-index-core==0.10.44->llama_index)\n",
99
+ " Downloading tiktoken-0.7.0-cp312-cp312-win_amd64.whl.metadata (6.8 kB)\n",
100
+ "Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (4.66.4)\n",
101
+ "Requirement already satisfied: typing-extensions>=4.5.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (4.11.0)\n",
102
+ "Requirement already satisfied: typing-inspect>=0.8.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (0.9.0)\n",
103
+ "Requirement already satisfied: wrapt in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-core==0.10.44->llama_index) (1.16.0)\n",
104
+ "Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama_index) (4.12.3)\n",
105
+ "Requirement already satisfied: pypdf<5.0.0,>=4.0.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llama-index-readers-file<0.2.0,>=0.1.4->llama_index) (4.2.0)\n",
106
+ "Collecting striprtf<0.0.27,>=0.0.26 (from llama-index-readers-file<0.2.0,>=0.1.4->llama_index)\n",
107
+ " Downloading striprtf-0.0.26-py3-none-any.whl.metadata (2.1 kB)\n",
108
+ "Collecting llama-parse<0.5.0,>=0.4.0 (from llama-index-readers-llama-parse<0.2.0,>=0.1.2->llama_index)\n",
109
+ " Downloading llama_parse-0.4.4-py3-none-any.whl.metadata (3.5 kB)\n",
110
+ "Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.44->llama_index) (1.3.1)\n",
111
+ "Requirement already satisfied: attrs>=17.3.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.44->llama_index) (23.2.0)\n",
112
+ "Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.44->llama_index) (1.4.1)\n",
113
+ "Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.44->llama_index) (6.0.5)\n",
114
+ "Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core==0.10.44->llama_index) (1.9.4)\n",
115
+ "Requirement already satisfied: soupsieve>1.2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file<0.2.0,>=0.1.4->llama_index) (2.5)\n",
116
+ "Requirement already satisfied: pydantic>=1.10 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from llamaindex-py-client<0.2.0,>=0.1.18->llama-index-core==0.10.44->llama_index) (1.10.16)\n",
117
+ "Requirement already satisfied: anyio in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from httpx->llama-index-core==0.10.44->llama_index) (4.3.0)\n",
118
+ "Requirement already satisfied: certifi in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from httpx->llama-index-core==0.10.44->llama_index) (2024.2.2)\n",
119
+ "Requirement already satisfied: httpcore==1.* in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from httpx->llama-index-core==0.10.44->llama_index) (1.0.5)\n",
120
+ "Requirement already satisfied: idna in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from httpx->llama-index-core==0.10.44->llama_index) (3.7)\n",
121
+ "Requirement already satisfied: sniffio in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from httpx->llama-index-core==0.10.44->llama_index) (1.3.1)\n",
122
+ "Requirement already satisfied: h11<0.15,>=0.13 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from httpcore==1.*->httpx->llama-index-core==0.10.44->llama_index) (0.14.0)\n",
123
+ "Requirement already satisfied: click in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.44->llama_index) (8.1.7)\n",
124
+ "Requirement already satisfied: joblib in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.44->llama_index) (1.4.2)\n",
125
+ "Requirement already satisfied: regex>=2021.8.3 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from nltk<4.0.0,>=3.8.1->llama-index-core==0.10.44->llama_index) (2024.5.15)\n",
126
+ "Collecting distro<2,>=1.7.0 (from openai>=1.1.0->llama-index-core==0.10.44->llama_index)\n",
127
+ " Using cached distro-1.9.0-py3-none-any.whl.metadata (6.8 kB)\n",
128
+ "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests>=2.31.0->llama-index-core==0.10.44->llama_index) (3.3.2)\n",
129
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests>=2.31.0->llama-index-core==0.10.44->llama_index) (2.2.1)\n",
130
+ "Requirement already satisfied: greenlet!=0.4.17 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from SQLAlchemy>=1.4.49->SQLAlchemy[asyncio]>=1.4.49->llama-index-core==0.10.44->llama_index) (3.0.3)\n",
131
+ "Requirement already satisfied: colorama in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from tqdm<5.0.0,>=4.66.1->llama-index-core==0.10.44->llama_index) (0.4.6)\n",
132
+ "Requirement already satisfied: mypy-extensions>=0.3.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from typing-inspect>=0.8.0->llama-index-core==0.10.44->llama_index) (1.0.0)\n",
133
+ "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from dataclasses-json->llama-index-core==0.10.44->llama_index) (3.21.3)\n",
134
+ "Requirement already satisfied: python-dateutil>=2.8.2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from pandas->llama-index-core==0.10.44->llama_index) (2.9.0.post0)\n",
135
+ "Requirement already satisfied: pytz>=2020.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from pandas->llama-index-core==0.10.44->llama_index) (2024.1)\n",
136
+ "Requirement already satisfied: tzdata>=2022.7 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from pandas->llama-index-core==0.10.44->llama_index) (2024.1)\n",
137
+ "Requirement already satisfied: packaging>=17.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core==0.10.44->llama_index) (23.2)\n",
138
+ "Requirement already satisfied: six>=1.5 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from python-dateutil>=2.8.2->pandas->llama-index-core==0.10.44->llama_index) (1.16.0)\n",
139
+ "Downloading llama_index-0.10.44-py3-none-any.whl (6.8 kB)\n",
140
+ "Downloading llama_index_core-0.10.44-py3-none-any.whl (15.4 MB)\n",
141
+ " ---------------------------------------- 0.0/15.4 MB ? eta -:--:--\n",
142
+ " --------------------------------------- 0.3/15.4 MB 2.6 MB/s eta 0:00:06\n",
143
+ " - -------------------------------------- 0.6/15.4 MB 2.5 MB/s eta 0:00:06\n",
144
+ " -- ------------------------------------- 1.0/15.4 MB 2.9 MB/s eta 0:00:05\n",
145
+ " --- ------------------------------------ 1.2/15.4 MB 3.0 MB/s eta 0:00:05\n",
146
+ " ---- ----------------------------------- 1.7/15.4 MB 2.8 MB/s eta 0:00:05\n",
147
+ " ----- ---------------------------------- 2.1/15.4 MB 2.9 MB/s eta 0:00:05\n",
148
+ " ------- -------------------------------- 2.9/15.4 MB 3.1 MB/s eta 0:00:04\n",
149
+ " -------- ------------------------------- 3.2/15.4 MB 3.2 MB/s eta 0:00:04\n",
150
+ " --------- ------------------------------ 3.6/15.4 MB 3.2 MB/s eta 0:00:04\n",
151
+ " ---------- ----------------------------- 3.9/15.4 MB 3.1 MB/s eta 0:00:04\n",
152
+ " ----------- ---------------------------- 4.4/15.4 MB 3.2 MB/s eta 0:00:04\n",
153
+ " ------------ --------------------------- 4.8/15.4 MB 3.3 MB/s eta 0:00:04\n",
154
+ " ------------- -------------------------- 5.1/15.4 MB 3.2 MB/s eta 0:00:04\n",
155
+ " -------------- ------------------------- 5.7/15.4 MB 3.1 MB/s eta 0:00:04\n",
156
+ " ----------------- ---------------------- 6.6/15.4 MB 3.2 MB/s eta 0:00:03\n",
157
+ " ------------------ --------------------- 7.1/15.4 MB 3.3 MB/s eta 0:00:03\n",
158
+ " --------------------- ------------------ 8.2/15.4 MB 3.2 MB/s eta 0:00:03\n",
159
+ " ----------------------- ---------------- 9.1/15.4 MB 3.3 MB/s eta 0:00:02\n",
160
+ " ------------------------ --------------- 9.6/15.4 MB 3.3 MB/s eta 0:00:02\n",
161
+ " ------------------------- -------------- 9.9/15.4 MB 3.2 MB/s eta 0:00:02\n",
162
+ " -------------------------- ------------- 10.3/15.4 MB 3.2 MB/s eta 0:00:02\n",
163
+ " --------------------------- ------------ 10.7/15.4 MB 3.3 MB/s eta 0:00:02\n",
164
+ " ---------------------------- ----------- 11.2/15.4 MB 3.2 MB/s eta 0:00:02\n",
165
+ " ----------------------------- ---------- 11.4/15.4 MB 3.0 MB/s eta 0:00:02\n",
166
+ " ------------------------------ --------- 11.7/15.4 MB 3.0 MB/s eta 0:00:02\n",
167
+ " ------------------------------- -------- 12.1/15.4 MB 2.8 MB/s eta 0:00:02\n",
168
+ " ------------------------------- -------- 12.3/15.4 MB 2.7 MB/s eta 0:00:02\n",
169
+ " -------------------------------- ------- 12.4/15.4 MB 2.7 MB/s eta 0:00:02\n",
170
+ " -------------------------------- ------- 12.5/15.4 MB 2.6 MB/s eta 0:00:02\n",
171
+ " -------------------------------- ------- 12.6/15.4 MB 2.6 MB/s eta 0:00:02\n",
172
+ " --------------------------------- ------ 12.8/15.4 MB 2.5 MB/s eta 0:00:02\n",
173
+ " --------------------------------- ------ 12.9/15.4 MB 2.4 MB/s eta 0:00:02\n",
174
+ " --------------------------------- ------ 13.0/15.4 MB 2.4 MB/s eta 0:00:02\n",
175
+ " --------------------------------- ------ 13.1/15.4 MB 2.3 MB/s eta 0:00:01\n",
176
+ " --------------------------------- ------ 13.1/15.4 MB 2.3 MB/s eta 0:00:01\n",
177
+ " ---------------------------------- ----- 13.4/15.4 MB 2.2 MB/s eta 0:00:01\n",
178
+ " ---------------------------------- ----- 13.5/15.4 MB 2.2 MB/s eta 0:00:01\n",
179
+ " ----------------------------------- ---- 13.6/15.4 MB 2.2 MB/s eta 0:00:01\n",
180
+ " ----------------------------------- ---- 13.8/15.4 MB 2.1 MB/s eta 0:00:01\n",
181
+ " ------------------------------------ --- 13.9/15.4 MB 2.1 MB/s eta 0:00:01\n",
182
+ " ------------------------------------ --- 14.0/15.4 MB 2.0 MB/s eta 0:00:01\n",
183
+ " ------------------------------------ --- 14.2/15.4 MB 2.0 MB/s eta 0:00:01\n",
184
+ " ------------------------------------- -- 14.4/15.4 MB 2.0 MB/s eta 0:00:01\n",
185
+ " ------------------------------------- -- 14.6/15.4 MB 1.9 MB/s eta 0:00:01\n",
186
+ " -------------------------------------- - 14.8/15.4 MB 1.9 MB/s eta 0:00:01\n",
187
+ " -------------------------------------- - 15.0/15.4 MB 1.8 MB/s eta 0:00:01\n",
188
+ " --------------------------------------- 15.3/15.4 MB 1.8 MB/s eta 0:00:01\n",
189
+ " --------------------------------------- 15.4/15.4 MB 1.8 MB/s eta 0:00:01\n",
190
+ " --------------------------------------- 15.4/15.4 MB 1.8 MB/s eta 0:00:01\n",
191
+ " --------------------------------------- 15.4/15.4 MB 1.8 MB/s eta 0:00:01\n",
192
+ " ---------------------------------------- 15.4/15.4 MB 1.7 MB/s eta 0:00:00\n",
193
+ "Downloading llama_index_agent_openai-0.2.7-py3-none-any.whl (12 kB)\n",
194
+ "Downloading llama_index_cli-0.1.12-py3-none-any.whl (26 kB)\n",
195
+ "Downloading llama_index_embeddings_openai-0.1.10-py3-none-any.whl (6.2 kB)\n",
196
+ "Downloading llama_index_indices_managed_llama_cloud-0.1.6-py3-none-any.whl (6.7 kB)\n",
197
+ "Downloading llama_index_legacy-0.9.48-py3-none-any.whl (2.0 MB)\n",
198
+ " ---------------------------------------- 0.0/2.0 MB ? eta -:--:--\n",
199
+ " --------- ------------------------------ 0.5/2.0 MB 4.0 MB/s eta 0:00:01\n",
200
+ " -------------- ------------------------- 0.7/2.0 MB 2.4 MB/s eta 0:00:01\n",
201
+ " ---------------- ----------------------- 0.8/2.0 MB 2.2 MB/s eta 0:00:01\n",
202
+ " ---------------------- ----------------- 1.1/2.0 MB 1.9 MB/s eta 0:00:01\n",
203
+ " ----------------------- ---------------- 1.2/2.0 MB 1.8 MB/s eta 0:00:01\n",
204
+ " --------------------------- ------------ 1.3/2.0 MB 1.7 MB/s eta 0:00:01\n",
205
+ " ----------------------------- ---------- 1.5/2.0 MB 1.5 MB/s eta 0:00:01\n",
206
+ " -------------------------------- ------- 1.6/2.0 MB 1.4 MB/s eta 0:00:01\n",
207
+ " ---------------------------------- ----- 1.7/2.0 MB 1.3 MB/s eta 0:00:01\n",
208
+ " ----------------------------------- ---- 1.8/2.0 MB 1.2 MB/s eta 0:00:01\n",
209
+ " -------------------------------------- - 1.9/2.0 MB 1.2 MB/s eta 0:00:01\n",
210
+ " --------------------------------------- 2.0/2.0 MB 1.2 MB/s eta 0:00:01\n",
211
+ " ---------------------------------------- 2.0/2.0 MB 1.1 MB/s eta 0:00:00\n",
212
+ "Downloading llama_index_llms_openai-0.1.22-py3-none-any.whl (11 kB)\n",
213
+ "Downloading llama_index_multi_modal_llms_openai-0.1.6-py3-none-any.whl (5.8 kB)\n",
214
+ "Downloading llama_index_program_openai-0.1.6-py3-none-any.whl (5.2 kB)\n",
215
+ "Downloading llama_index_question_gen_openai-0.1.3-py3-none-any.whl (2.9 kB)\n",
216
+ "Downloading llama_index_readers_file-0.1.25-py3-none-any.whl (37 kB)\n",
217
+ "Downloading llama_index_readers_llama_parse-0.1.4-py3-none-any.whl (2.5 kB)\n",
218
+ "Downloading Deprecated-1.2.14-py2.py3-none-any.whl (9.6 kB)\n",
219
+ "Downloading dirtyjson-1.0.8-py3-none-any.whl (25 kB)\n",
220
+ "Downloading llama_parse-0.4.4-py3-none-any.whl (8.0 kB)\n",
221
+ "Downloading llamaindex_py_client-0.1.19-py3-none-any.whl (141 kB)\n",
222
+ " ---------------------------------------- 0.0/141.9 kB ? eta -:--:--\n",
223
+ " ---------------------------------------- 141.9/141.9 kB 4.2 MB/s eta 0:00:00\n",
224
+ "Using cached openai-1.34.0-py3-none-any.whl (325 kB)\n",
225
+ "Downloading striprtf-0.0.26-py3-none-any.whl (6.9 kB)\n",
226
+ "Downloading tiktoken-0.7.0-cp312-cp312-win_amd64.whl (799 kB)\n",
227
+ " ---------------------------------------- 0.0/799.3 kB ? eta -:--:--\n",
228
+ " ---------------- ----------------------- 327.7/799.3 kB 3.4 MB/s eta 0:00:01\n",
229
+ " -------------------- ------------------- 409.6/799.3 kB 1.6 MB/s eta 0:00:01\n",
230
+ " ----------------------- ---------------- 471.0/799.3 kB 1.3 MB/s eta 0:00:01\n",
231
+ " -------------------------- ------------- 522.2/799.3 kB 1.2 MB/s eta 0:00:01\n",
232
+ " ----------------------------- ---------- 583.7/799.3 kB 1.1 MB/s eta 0:00:01\n",
233
+ " ------------------------------ ------- 634.9/799.3 kB 952.2 kB/s eta 0:00:01\n",
234
+ " ---------------------------------- --- 716.8/799.3 kB 923.6 kB/s eta 0:00:01\n",
235
+ " ------------------------------------ - 778.2/799.3 kB 877.7 kB/s eta 0:00:01\n",
236
+ " -------------------------------------- 799.3/799.3 kB 855.8 kB/s eta 0:00:00\n",
237
+ "Using cached distro-1.9.0-py3-none-any.whl (20 kB)\n",
238
+ "Installing collected packages: striprtf, dirtyjson, distro, deprecated, tiktoken, openai, llamaindex-py-client, llama-index-legacy, llama-index-core, llama-parse, llama-index-readers-file, llama-index-llms-openai, llama-index-indices-managed-llama-cloud, llama-index-embeddings-openai, llama-index-readers-llama-parse, llama-index-multi-modal-llms-openai, llama-index-cli, llama-index-agent-openai, llama-index-program-openai, llama-index-question-gen-openai, llama_index\n",
239
+ "Successfully installed deprecated-1.2.14 dirtyjson-1.0.8 distro-1.9.0 llama-index-agent-openai-0.2.7 llama-index-cli-0.1.12 llama-index-core-0.10.44 llama-index-embeddings-openai-0.1.10 llama-index-indices-managed-llama-cloud-0.1.6 llama-index-legacy-0.9.48 llama-index-llms-openai-0.1.22 llama-index-multi-modal-llms-openai-0.1.6 llama-index-program-openai-0.1.6 llama-index-question-gen-openai-0.1.3 llama-index-readers-file-0.1.25 llama-index-readers-llama-parse-0.1.4 llama-parse-0.4.4 llama_index-0.10.44 llamaindex-py-client-0.1.19 openai-1.34.0 striprtf-0.0.26 tiktoken-0.7.0\n",
240
+ "Requirement already satisfied: langchain in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (0.0.225)\n",
241
+ "Requirement already satisfied: PyYAML>=5.4.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (6.0.1)\n",
242
+ "Requirement already satisfied: SQLAlchemy<3,>=1.4 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (2.0.30)\n",
243
+ "Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (3.9.5)\n",
244
+ "Requirement already satisfied: dataclasses-json<0.6.0,>=0.5.7 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (0.5.14)\n",
245
+ "Requirement already satisfied: langchainplus-sdk<0.0.21,>=0.0.20 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (0.0.20)\n",
246
+ "Requirement already satisfied: numexpr<3.0.0,>=2.8.4 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (2.10.0)\n",
247
+ "Requirement already satisfied: numpy<2,>=1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (1.26.4)\n",
248
+ "Requirement already satisfied: openapi-schema-pydantic<2.0,>=1.2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (1.2.4)\n",
249
+ "Requirement already satisfied: pydantic<2,>=1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (1.10.16)\n",
250
+ "Requirement already satisfied: requests<3,>=2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (2.32.2)\n",
251
+ "Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from langchain) (8.3.0)\n",
252
+ "Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.1)\n",
253
+ "Requirement already satisfied: attrs>=17.3.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (23.2.0)\n",
254
+ "Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.4.1)\n",
255
+ "Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.5)\n",
256
+ "Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.9.4)\n",
257
+ "Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (3.21.3)\n",
258
+ "Requirement already satisfied: typing-inspect<1,>=0.4.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (0.9.0)\n",
259
+ "Requirement already satisfied: typing-extensions>=4.2.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from pydantic<2,>=1->langchain) (4.11.0)\n",
260
+ "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests<3,>=2->langchain) (3.3.2)\n",
261
+ "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests<3,>=2->langchain) (3.7)\n",
262
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests<3,>=2->langchain) (2.2.1)\n",
263
+ "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests<3,>=2->langchain) (2024.2.2)\n",
264
+ "Requirement already satisfied: greenlet!=0.4.17 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from SQLAlchemy<3,>=1.4->langchain) (3.0.3)\n",
265
+ "Requirement already satisfied: packaging>=17.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (23.2)\n",
266
+ "Requirement already satisfied: mypy-extensions>=0.3.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (1.0.0)\n",
267
+ "Requirement already satisfied: torch in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (2.3.1)\n",
268
+ "Requirement already satisfied: filelock in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch) (3.14.0)\n",
269
+ "Requirement already satisfied: typing-extensions>=4.8.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch) (4.11.0)\n",
270
+ "Requirement already satisfied: sympy in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch) (1.12)\n",
271
+ "Requirement already satisfied: networkx in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch) (3.3)\n",
272
+ "Requirement already satisfied: jinja2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch) (3.1.4)\n",
273
+ "Requirement already satisfied: fsspec in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch) (2024.5.0)\n",
274
+ "Requirement already satisfied: mkl<=2021.4.0,>=2021.1.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from torch) (2021.4.0)\n",
275
+ "Requirement already satisfied: intel-openmp==2021.* in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch) (2021.4.0)\n",
276
+ "Requirement already satisfied: tbb==2021.* in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch) (2021.12.0)\n",
277
+ "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from jinja2->torch) (2.1.5)\n",
278
+ "Requirement already satisfied: mpmath>=0.19 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from sympy->torch) (1.3.0)\n",
279
+ "Requirement already satisfied: huggingface_hub in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (0.23.1)\n",
280
+ "Requirement already satisfied: filelock in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface_hub) (3.14.0)\n",
281
+ "Requirement already satisfied: fsspec>=2023.5.0 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface_hub) (2024.5.0)\n",
282
+ "Requirement already satisfied: packaging>=20.9 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface_hub) (23.2)\n",
283
+ "Requirement already satisfied: pyyaml>=5.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface_hub) (6.0.1)\n",
284
+ "Requirement already satisfied: requests in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface_hub) (2.32.2)\n",
285
+ "Requirement already satisfied: tqdm>=4.42.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface_hub) (4.66.4)\n",
286
+ "Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from huggingface_hub) (4.11.0)\n",
287
+ "Requirement already satisfied: colorama in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from tqdm>=4.42.1->huggingface_hub) (0.4.6)\n",
288
+ "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests->huggingface_hub) (3.3.2)\n",
289
+ "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests->huggingface_hub) (3.7)\n",
290
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests->huggingface_hub) (2.2.1)\n",
291
+ "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\kirai\\appdata\\local\\programs\\python\\python312\\lib\\site-packages (from requests->huggingface_hub) (2024.2.2)\n"
292
+ ]
293
+ }
294
+ ],
295
+ "source": [
296
+ "!pip install pypdf\n",
297
+ "!pip install sentence-transformers\n",
298
+ "!pip install llama_index\n",
299
+ "!pip install langchain\n",
300
+ "!pip install torch\n",
301
+ "!pip install huggingface_hub"
302
+ ]
303
+ },
304
+ {
305
+ "cell_type": "code",
306
+ "execution_count": 2,
307
+ "metadata": {},
308
+ "outputs": [
309
+ {
310
+ "ename": "ModuleNotFoundError",
311
+ "evalue": "No module named 'llama_index'",
312
+ "output_type": "error",
313
+ "traceback": [
314
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
315
+ "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
316
+ "Cell \u001b[1;32mIn[2], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mllama_index\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mllama_index\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mllms\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m HuggingFaceLLM\n\u001b[0;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mllama_index\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mprompts\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mprompts\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m SimpleInputPrompt\n",
317
+ "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'llama_index'"
318
+ ]
319
+ }
320
+ ],
321
+ "source": [
322
+ "from llama_index import VectorStoreIndex, SimpleDirectoryReader, ServiceContext\n",
323
+ "from llama_index.llms import HuggingFaceLLM\n",
324
+ "from llama_index.prompts.prompts import SimpleInputPrompt\n",
325
+ "from langchain.embeddings.huggingface import HuggingFaceEmbeddings\n",
326
+ "from llama_index.embeddings import LangchainEmbedding\n",
327
+ "import torch\n",
328
+ "import chromadb\n",
329
+ "from chromadb.utils import embedding_functions"
330
+ ]
331
+ },
332
+ {
333
+ "cell_type": "code",
334
+ "execution_count": null,
335
+ "metadata": {},
336
+ "outputs": [],
337
+ "source": [
338
+ "documents = SimpleDirectoryReader(\"/content/data\").load_data()"
339
+ ]
340
+ },
341
+ {
342
+ "cell_type": "code",
343
+ "execution_count": null,
344
+ "metadata": {},
345
+ "outputs": [],
346
+ "source": [
347
+ "system_prompt = \"\"\"\n",
348
+ "You are a Q&A assistant. Your goal is to answer questions as\n",
349
+ "accurately as possible based on the instructions and context provided.\n",
350
+ "query_wrapper_prompt = SimpleInputPrompt(\"{query_str}\")"
351
+ ]
352
+ }
353
+ ],
354
+ "metadata": {
355
+ "kernelspec": {
356
+ "display_name": "mchatbot",
357
+ "language": "python",
358
+ "name": "python3"
359
+ },
360
+ "language_info": {
361
+ "codemirror_mode": {
362
+ "name": "ipython",
363
+ "version": 3
364
+ },
365
+ "file_extension": ".py",
366
+ "mimetype": "text/x-python",
367
+ "name": "python",
368
+ "nbconvert_exporter": "python",
369
+ "pygments_lexer": "ipython3",
370
+ "version": "3.8.19"
371
+ }
372
+ },
373
+ "nbformat": 4,
374
+ "nbformat_minor": 2
375
+ }