abhinand2 commited on
Commit
d962703
·
verified ·
1 Parent(s): 678c780

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -31
app.py CHANGED
@@ -7,35 +7,35 @@ import logging
7
  logger = logging.getLogger(__name__)
8
 
9
 
10
- #logger.info('Instantiating vectordb')
11
- #vectordb = get_db(
12
- # chunk_size=1000,
13
- # chunk_overlap=200,
14
- # model_name = 'intfloat/multilingual-e5-large-instruct',
15
- #)
 
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- #logger.info('Instantiating chain')
19
- #chain = get_chain(
20
- # vectordb,
21
- # repo_id="HuggingFaceH4/zephyr-7b-beta",
22
- # task="text-generation",
23
- # max_new_tokens=512,
24
- # top_k=30,
25
- # temperature=0.1,
26
- # repetition_penalty=1.03,
27
- # search_type="mmr",
28
- # k=3,
29
- # fetch_k=5,
30
- # template="""Use the following sentences of context to answer the question at the end.
31
- #If you don't know the answer, that is if the answer is not in the context, then just say that you don't know, don't try to make up an answer.
32
- #Always say "Thanks for asking!" at the end of the answer.
33
- #
34
- #{context}
35
- #
36
- #Question: {question}
37
- #Helpful Answer:"""
38
- #)
39
 
40
  def respond(
41
  question,
@@ -45,9 +45,8 @@ def respond(
45
  temperature,
46
  top_p,
47
  ):
48
- print(f'respond called by Gradio ChatInterface with question={question}')
49
- #return chain.invoke({'question': question})
50
- return "hello!"
51
 
52
 
53
  demo = gr.ChatInterface(
@@ -68,4 +67,7 @@ demo = gr.ChatInterface(
68
 
69
 
70
  if __name__ == "__main__":
71
- demo.launch()
 
 
 
 
7
  logger = logging.getLogger(__name__)
8
 
9
 
10
+ logger.info('Instantiating vectordb')
11
+ vectordb = get_db(
12
+ chunk_size=1000,
13
+ chunk_overlap=200,
14
+ model_name = 'intfloat/multilingual-e5-large-instruct',
15
+ )
16
+
17
 
18
+ logger.info('Instantiating chain')
19
+ chain = get_chain(
20
+ vectordb,
21
+ repo_id="HuggingFaceH4/zephyr-7b-beta",
22
+ task="text-generation",
23
+ max_new_tokens=512,
24
+ top_k=30,
25
+ temperature=0.1,
26
+ repetition_penalty=1.03,
27
+ search_type="mmr",
28
+ k=3,
29
+ fetch_k=5,
30
+ template="""Use the following sentences of context to answer the question at the end.
31
+ If you don't know the answer, that is if the answer is not in the context, then just say that you don't know, don't try to make up an answer.
32
+ Always say "Thanks for asking!" at the end of the answer.
33
 
34
+ {context}
35
+
36
+ Question: {question}
37
+ Helpful Answer:"""
38
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  def respond(
41
  question,
 
45
  temperature,
46
  top_p,
47
  ):
48
+ logger.info(f'respond called by Gradio ChatInterface with question={question}')
49
+ return chain.invoke({'question': question})
 
50
 
51
 
52
  demo = gr.ChatInterface(
 
67
 
68
 
69
  if __name__ == "__main__":
70
+ demo.launch(
71
+ show_error=True,
72
+ enable_monitoring=True
73
+ )