dogutcu commited on
Commit
937c9f4
·
verified ·
1 Parent(s): f2d7c25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -64,6 +64,7 @@ def generate_response(user_query, relevant_segment):
64
  """
65
  Generate a response emphasizing the bot's capability to provide information related to composting food.
66
  """
 
67
  try:
68
  system_message = "You are a chatbot specialized in providing information about food composting tips, tricks, and basics."
69
  user_message = f"Here's the information on composting: {relevant_segment}"
@@ -84,6 +85,16 @@ def generate_response(user_query, relevant_segment):
84
  except Exception as e:
85
  print(f"Error in generating response: {e}")
86
  return f"Error in generating response: {e}"
 
 
 
 
 
 
 
 
 
 
87
 
88
  def query_model(question):
89
  """
 
64
  """
65
  Generate a response emphasizing the bot's capability to provide information related to composting food.
66
  """
67
+ """
68
  try:
69
  system_message = "You are a chatbot specialized in providing information about food composting tips, tricks, and basics."
70
  user_message = f"Here's the information on composting: {relevant_segment}"
 
85
  except Exception as e:
86
  print(f"Error in generating response: {e}")
87
  return f"Error in generating response: {e}"
88
+ """
89
+ # Create pipeline for text generation with confidence scores
90
+ generator = pipeline("text-davinci-003", device=0) # Adjust device if needed
91
+
92
+ # Generate response and get confidence score
93
+ response = generator(query=f"Here's the information on chess: {relevant_segment} {user_query}", max_length=150, temperature=0.2, top_p=1)
94
+ generated_text = response[0]['generated_text'].strip()
95
+ confidence_score = response[0]['score']
96
+
97
+ return generated_text, confidence_score
98
 
99
  def query_model(question):
100
  """