def getmostsimilarquestion(userText,history): newdf['userquery'] =…
- User
def get_most_similar_question(userText,history):
new_df['user_query'] = new_df['user_query'].str.lower() question_list = new_df["user_query"].to_list() question_embeddings = retrieval_model.encode(question_list) user_text_embedding = retrieval_model.encode([userText.lower()])# Calculate similarity scores similarity_scores = np.inner(user_text_embedding, question_embeddings).flatten() top_match_idx = np.argmax(similarity_scores) if similarity_scores[top_match_idx] == 0: return "Sorry, no similar questions were found for your query." matched_data = new_df.iloc[top_match_idx,[1]] return matched_data.to_frame().T.to_html(index=False) # Returning the matched row as HTMLit is retruning a datafrae kind of data,can it just show the value of the data and not header and table in html
- Assistant
Yes, you can simply return the value of the data without converting it to an HTML table. Instead of converting the matched row to a dataframe and then to HTML, you can directly access the value you need. Here is an updated version of your function to return just the value: