gupta-amulya commited on
Commit
bde636a
·
1 Parent(s): d1b46c1

Refactor app.py to enable SemanticSearcher and UpvotePredictor functionality

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -5,9 +5,8 @@ import pandas as pd
5
  from datasets import load_dataset
6
 
7
  from src.genai import GenAI
8
-
9
- # from src.semantic_searcher import SemanticSearcher
10
- # from src.upvote_predictor import UpvotePredictor
11
 
12
  # Load the dataset
13
  dataset_counsel_chat = load_dataset("nbertagnolli/counsel-chat")
@@ -53,19 +52,19 @@ examples = "\n".join(
53
 
54
  # Initialize the SemanticSearcher
55
  genai = GenAI()
56
- # upvote_predictor = UpvotePredictor("models/bert_model")
57
- # _ = SemanticSearcher(df_counsel_chat_topic)
58
 
59
 
60
  def get_output(question: str, question_context: str = None) -> str:
61
  answer, topic = genai.generate_content(
62
  question, question_context, unique_topics, examples
63
  )
64
- return (answer, topic, "Yes", pd.DataFrame())
65
- # upvote_prediction = upvote_predictor.get_upvote_prediction(
66
- # question, answer, question_context
67
- # )
68
- # return (answer, topic, upvote_prediction[0], upvote_prediction[1])
69
 
70
 
71
  demo = gr.Interface(
 
5
  from datasets import load_dataset
6
 
7
  from src.genai import GenAI
8
+ from src.semantic_searcher import SemanticSearcher
9
+ from src.upvote_predictor import UpvotePredictor
 
10
 
11
  # Load the dataset
12
  dataset_counsel_chat = load_dataset("nbertagnolli/counsel-chat")
 
52
 
53
  # Initialize the SemanticSearcher
54
  genai = GenAI()
55
+ upvote_predictor = UpvotePredictor("models/bert_model")
56
+ _ = SemanticSearcher(df_counsel_chat_topic)
57
 
58
 
59
  def get_output(question: str, question_context: str = None) -> str:
60
  answer, topic = genai.generate_content(
61
  question, question_context, unique_topics, examples
62
  )
63
+ # return (answer, topic, "Yes", pd.DataFrame())
64
+ upvote_prediction = upvote_predictor.get_upvote_prediction(
65
+ question, answer, question_context
66
+ )
67
+ return (answer, topic, upvote_prediction[0], upvote_prediction[1])
68
 
69
 
70
  demo = gr.Interface(