Gopikanth123 commited on
Commit
938fd74
·
verified ·
1 Parent(s): 8343e08

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +53 -16
main.py CHANGED
@@ -17,18 +17,31 @@ llm_client = InferenceClient(
17
  token=HF_TOKEN,
18
  )
19
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # Configure Llama index settings
21
  Settings.llm = HuggingFaceInferenceAPI(
22
- model_name=repo_id,
23
- tokenizer_name=repo_id,
24
  context_window=3000,
25
  token=HF_TOKEN,
26
  max_new_tokens=512,
27
  generate_kwargs={"temperature": 0.1},
28
  )
 
29
  Settings.embed_model = HuggingFaceEmbedding(
30
- model_name="BAAI/bge-small-en-v1.5"
31
- )
32
 
33
  PERSIST_DIR = "db"
34
  PDF_DIRECTORY = 'data'
@@ -57,18 +70,42 @@ def data_ingestion_from_directory():
57
  index.storage_context.persist(persist_dir=PERSIST_DIR)
58
 
59
  def handle_query(query):
60
- chat_text_qa_msgs = [
61
- (
62
- "user",
63
- """
64
- You are the Taj Hotel chatbot, known as Taj Hotel Helper. Your goal is to provide accurate and professional answers to user queries based on the information available about the Taj Hotel. Always respond clearly and concisely, ideally within 10-15 words. If you don't know the answer, say so politely.
65
- Context:
66
- {context_str}
67
- User's Question:
68
- {query_str}
69
- """
70
- )
71
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  text_qa_template = ChatPromptTemplate.from_messages(chat_text_qa_msgs)
74
 
 
17
  token=HF_TOKEN,
18
  )
19
 
20
+ # Configure Llama index settings
21
+ # Settings.llm = HuggingFaceInferenceAPI(
22
+ # model_name=repo_id,
23
+ # tokenizer_name=repo_id,
24
+ # context_window=3000,
25
+ # token=HF_TOKEN,
26
+ # max_new_tokens=512,
27
+ # generate_kwargs={"temperature": 0.1},
28
+ # )
29
+ # Settings.embed_model = HuggingFaceEmbedding(
30
+ # model_name="BAAI/bge-small-en-v1.5"
31
+ # )
32
  # Configure Llama index settings
33
  Settings.llm = HuggingFaceInferenceAPI(
34
+ model_name="xlm-roberta-base",
35
+ tokenizer_name="xlm-roberta-base",
36
  context_window=3000,
37
  token=HF_TOKEN,
38
  max_new_tokens=512,
39
  generate_kwargs={"temperature": 0.1},
40
  )
41
+
42
  Settings.embed_model = HuggingFaceEmbedding(
43
+ model_name="sentence-transformers/paraphrase-xlm-r-100langs-v1"
44
+ )
45
 
46
  PERSIST_DIR = "db"
47
  PDF_DIRECTORY = 'data'
 
70
  index.storage_context.persist(persist_dir=PERSIST_DIR)
71
 
72
  def handle_query(query):
73
+ # chat_text_qa_msgs = [
74
+ # (
75
+ # "user",
76
+ # """
77
+ # You are the Taj Hotel chatbot, known as Taj Hotel Helper. Your goal is to provide accurate and professional answers to user queries based on the information available about the Taj Hotel. Always respond clearly and concisely, ideally within 10-15 words. If you don't know the answer, say so politely.
78
+ # Context:
79
+ # {context_str}
80
+ # User's Question:
81
+ # {query_str}
82
+ # """
83
+ # )
84
+ # ]
85
+ chat_text_qa_msgs = [
86
+ (
87
+ "user",
88
+ """
89
+ You are the Taj Hotel chatbot, known as Taj Hotel Helper.
90
+ Your goal is to provide accurate and professional answers to
91
+ user queries about the Taj Hotel in the language they use:
92
+ English, Telugu, or Hindi. Always respond clearly and concisely,
93
+ ideally within 10-15 words. If you don't know the answer, say so politely.
94
+
95
+ Context:
96
+ {context_str}
97
+
98
+ User's Question:
99
+ {query_str}
100
+
101
+ Language-Specific Guidance:
102
+ - For English: Respond in English.
103
+ - For Telugu: తెలుగు లో సమాధానం ఇవ్వండి.
104
+ - For Hindi: हिंदी में उत्तर दें.
105
+ """
106
+ )
107
+ ]
108
+
109
 
110
  text_qa_template = ChatPromptTemplate.from_messages(chat_text_qa_msgs)
111