herMaster commited on
Commit
eaf2fb0
1 Parent(s): bbd68c6

trying simple chat function

Browse files
Files changed (1) hide show
  1. app.py +26 -23
app.py CHANGED
@@ -114,38 +114,41 @@ client.upload_records(
114
  print("Records uploaded........................................")
115
  print("###########################################################")
116
 
117
- def chat(question):
118
-
119
- hits = client.search(
120
- collection_name="my_facts",
121
- query_vector=encoder.encode(question).tolist(),
122
- limit=3
123
- )
124
- context = []
125
- for hit in hits:
126
- context.append(list(hit.payload.values())[0])
127
 
128
- context = context[0] + context[1] + context[2]
129
 
130
- system_prompt = """You are a helpful assistant, you will use the provided context to answer user questions.
131
- Read the given context before answering questions and think step by step. If you can not answer a user question based on
132
- the provided context, inform the user. Do not use any other information for answering user. Provide a detailed answer to the question."""
133
 
134
 
135
- B_INST, E_INST = "[INST]", "[/INST]"
136
 
137
- B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
138
 
139
- SYSTEM_PROMPT = B_SYS + system_prompt + E_SYS
140
 
141
- instruction = f"""
142
- Context: {context}
143
- User: {question}"""
144
 
145
- prompt_template = B_INST + SYSTEM_PROMPT + instruction + E_INST
146
 
147
- result = llm(prompt_template)
148
- return result
 
 
 
149
 
150
  screen = gr.Interface(
151
  fn = chat,
 
114
  print("Records uploaded........................................")
115
  print("###########################################################")
116
 
117
+ # def chat(question):
118
+
119
+ # hits = client.search(
120
+ # collection_name="my_facts",
121
+ # query_vector=encoder.encode(question).tolist(),
122
+ # limit=3
123
+ # )
124
+ # context = []
125
+ # for hit in hits:
126
+ # context.append(list(hit.payload.values())[0])
127
 
128
+ # context = context[0] + context[1] + context[2]
129
 
130
+ # system_prompt = """You are a helpful assistant, you will use the provided context to answer user questions.
131
+ # Read the given context before answering questions and think step by step. If you can not answer a user question based on
132
+ # the provided context, inform the user. Do not use any other information for answering user. Provide a detailed answer to the question."""
133
 
134
 
135
+ # B_INST, E_INST = "[INST]", "[/INST]"
136
 
137
+ # B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"
138
 
139
+ # SYSTEM_PROMPT = B_SYS + system_prompt + E_SYS
140
 
141
+ # instruction = f"""
142
+ # Context: {context}
143
+ # User: {question}"""
144
 
145
+ # prompt_template = B_INST + SYSTEM_PROMPT + instruction + E_INST
146
 
147
+ # result = llm(prompt_template)
148
+ # return result
149
+
150
+ def chat(question):
151
+ return "hello " + question
152
 
153
  screen = gr.Interface(
154
  fn = chat,