evanperez commited on
Commit
607b52b
·
verified ·
1 Parent(s): d52da14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -39
app.py CHANGED
@@ -131,47 +131,8 @@ def user_input(user_question, api_key):
131
 
132
  #chat history
133
  update_chat_history(user_question, response["output_text"])
134
- '''
135
 
136
 
137
- def user_input(user_question, api_key):
138
- embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001", google_api_key=api_key)
139
- new_db = FAISS.load_local("faiss_index", embeddings)
140
- docs = new_db.similarity_search(user_question)
141
- chain = get_conversational_chain()
142
- response_gemini = chain({"input_documents": docs, "question": user_question}, return_only_outputs=True)
143
-
144
- # Initialize the Hugging Face model and tokenizer
145
- model_name_or_path = "Writer/palmyra-small"
146
- model = AutoModelForCausalLM.from_pretrained(model_name_or_path)
147
- tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
148
-
149
- # Define the prompt template
150
- prompt_template = f"""
151
- Transform the following response into a more conversational tone without adding new information:
152
-
153
- Response:
154
- {response_gemini["output_text"]}
155
-
156
- Transformed Response:
157
- """
158
-
159
- # Tokenize the prompt
160
- inputs = tokenizer(prompt_template, return_tensors="pt", truncation=True,max_length=512)
161
-
162
- # Generate the transformed response using the Hugging Face model
163
- outputs = model.generate(**inputs)
164
-
165
- # Decode the generated response
166
- transformed_response = tokenizer.decode(outputs[0], skip_special_tokens=True)
167
-
168
- # Display the transformed response
169
- st.write("Reply: ", transformed_response)
170
-
171
- # Update chat history
172
- update_chat_history(user_question, transformed_response)
173
- '''
174
-
175
 
176
 
177
  def main():
 
131
 
132
  #chat history
133
  update_chat_history(user_question, response["output_text"])
 
134
 
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
 
138
  def main():