Dhritiman Sagar commited on
Commit
59c4803
·
1 Parent(s): c04d432

Update to use finetuned model

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -7,6 +7,7 @@ from typing import List
7
  from chainlit.types import AskFileResponse
8
  from langchain_text_splitters import RecursiveCharacterTextSplitter
9
  from langchain_community.document_loaders import PyMuPDFLoader
 
10
  from langchain_community.vectorstores import Qdrant
11
  from langchain_openai.llms import OpenAI
12
  from langchain_openai.chat_models import ChatOpenAI
@@ -30,8 +31,8 @@ import chainlit as cl
30
  from dotenv import load_dotenv; _ = load_dotenv()
31
 
32
  RAG_PROMPT = """
33
- Please answer the question below using the provided context. If the question cannnot be answered
34
- using the context, politely state that you can't answer that question.
35
 
36
  Question:
37
  {question}
@@ -43,9 +44,12 @@ Context:
43
  def get_rag_chain():
44
  """Fetches a simple RAG chain"""
45
  prompt = ChatPromptTemplate.from_template(RAG_PROMPT)
46
- embedding = OpenAIEmbeddings(model='text-embedding-3-large')
 
 
 
47
  retriever = QdrantVectorStore.from_existing_collection(
48
- collection_name='ai_ethics_te3_large',
49
  embedding=embedding,
50
  url=os.environ.get('QDRANT_DB'),
51
  api_key=os.environ.get('QDRANT_API_KEY')
 
7
  from chainlit.types import AskFileResponse
8
  from langchain_text_splitters import RecursiveCharacterTextSplitter
9
  from langchain_community.document_loaders import PyMuPDFLoader
10
+ from langchain_community.embeddings import HuggingFaceEmbeddings
11
  from langchain_community.vectorstores import Qdrant
12
  from langchain_openai.llms import OpenAI
13
  from langchain_openai.chat_models import ChatOpenAI
 
31
  from dotenv import load_dotenv; _ = load_dotenv()
32
 
33
  RAG_PROMPT = """
34
+ Please answer the question below using the provided context. Be as detailed as you can be based on the contextual information.
35
+ If the question cannnot be answered using the context, politely state that you can't answer that question.
36
 
37
  Question:
38
  {question}
 
44
  def get_rag_chain():
45
  """Fetches a simple RAG chain"""
46
  prompt = ChatPromptTemplate.from_template(RAG_PROMPT)
47
+ embedding = HuggingFaceEmbeddings(
48
+ model_name="deman539/nomic-embed-text-v1",
49
+ model_kwargs={'trust_remote_code': True}
50
+ )
51
  retriever = QdrantVectorStore.from_existing_collection(
52
+ collection_name='ai_ethics_nomicv1_finetuned',
53
  embedding=embedding,
54
  url=os.environ.get('QDRANT_DB'),
55
  api_key=os.environ.get('QDRANT_API_KEY')