mitulagr2 commited on
Commit
683c59a
·
1 Parent(s): bdc84e2

Update rag.py

Browse files
Files changed (1) hide show
  1. app/rag.py +7 -12
app/rag.py CHANGED
@@ -3,20 +3,18 @@ import logging
3
 
4
  from llama_index.core import (
5
  SimpleDirectoryReader,
6
- # VectorStoreIndex,
7
  StorageContext,
8
  Settings,
9
  get_response_synthesizer)
10
- from llama_index.core.query_engine import RetrieverQueryEngine, TransformQueryEngine
11
  from llama_index.core.node_parser import SentenceSplitter
12
  from llama_index.core.schema import TextNode, MetadataMode
13
- from llama_index.core.retrievers import VectorIndexRetriever
14
- # from llama_index.core.indices.query.query_transform import HyDEQueryTransform
15
 
16
- from llama_index.core.response_synthesizers import ResponseMode
17
  # from transformers import AutoTokenizer
18
  from llama_index.core.vector_stores import VectorStoreQuery
19
- from llama_index.core.indices.vector_store.base import VectorStoreIndex
20
  from llama_index.vector_stores.qdrant import QdrantVectorStore
21
  from qdrant_client import QdrantClient
22
 
@@ -33,7 +31,8 @@ logger = logging.getLogger(__name__)
33
  class ChatPDF:
34
  query_engine = None
35
 
36
- model_url = "https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat-GGUF/resolve/main/qwen1_5-1_8b-chat-q8_0.gguf"
 
37
  # model_url = "https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf/resolve/main/Phi-3-mini-4k-instruct-q4.gguf"
38
 
39
  # def messages_to_prompt(messages):
@@ -58,7 +57,7 @@ class ChatPDF:
58
 
59
 
60
  def __init__(self):
61
- self.text_parser = SentenceSplitter(chunk_size=512, chunk_overlap=20)
62
 
63
  logger.info("initializing the vector store related objects")
64
  # client = QdrantClient(host="localhost", port=6333)
@@ -154,10 +153,6 @@ class ChatPDF:
154
 
155
  self.query_engine = index.as_query_engine()
156
 
157
- # logger.info("creating the HyDEQueryTransform instance")
158
- # hyde = HyDEQueryTransform(include_original=True)
159
- # self.hyde_query_engine = TransformQueryEngine(vector_query_engine, hyde)
160
-
161
  def ask(self, query: str):
162
  if not self.query_engine:
163
  return "Please, add a PDF document first."
 
3
 
4
  from llama_index.core import (
5
  SimpleDirectoryReader,
6
+ VectorStoreIndex,
7
  StorageContext,
8
  Settings,
9
  get_response_synthesizer)
10
+ # from llama_index.core.query_engine import RetrieverQueryEngine, TransformQueryEngine
11
  from llama_index.core.node_parser import SentenceSplitter
12
  from llama_index.core.schema import TextNode, MetadataMode
13
+ # from llama_index.core.retrievers import VectorIndexRetriever
 
14
 
15
+ # from llama_index.core.response_synthesizers import ResponseMode
16
  # from transformers import AutoTokenizer
17
  from llama_index.core.vector_stores import VectorStoreQuery
 
18
  from llama_index.vector_stores.qdrant import QdrantVectorStore
19
  from qdrant_client import QdrantClient
20
 
 
31
  class ChatPDF:
32
  query_engine = None
33
 
34
+ model_url = "https://huggingface.co/Qwen/Qwen2-0.5B-Instruct-GGUF/resolve/main/qwen2-0_5b-instruct-fp16.gguf"
35
+ # model_url = "https://huggingface.co/Qwen/Qwen1.5-1.8B-Chat-GGUF/resolve/main/qwen1_5-1_8b-chat-q8_0.gguf"
36
  # model_url = "https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf/resolve/main/Phi-3-mini-4k-instruct-q4.gguf"
37
 
38
  # def messages_to_prompt(messages):
 
57
 
58
 
59
  def __init__(self):
60
+ self.text_parser = SentenceSplitter(chunk_size=128, chunk_overlap=8)
61
 
62
  logger.info("initializing the vector store related objects")
63
  # client = QdrantClient(host="localhost", port=6333)
 
153
 
154
  self.query_engine = index.as_query_engine()
155
 
 
 
 
 
156
  def ask(self, query: str):
157
  if not self.query_engine:
158
  return "Please, add a PDF document first."