iisadia commited on
Commit
d6e0529
·
verified ·
1 Parent(s): 609bab5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -158,17 +158,19 @@ def ask_llama(conversation_history, category, is_final_guess=False):
158
  # (replacing the original BlenderBot approach with DialoGPT for simplicity)
159
  def ask_help_agent(query):
160
  try:
161
- from transformers import pipeline
162
- # Using DialoGPT-medium as a free conversational text-generation model
163
- help_chat = pipeline("text-generation", model="microsoft/DialoGPT-medium")
164
- # The conversation string can incorporate previous messages if you want a dialogue
165
- # Here we simply generate a response to the current query.
166
- response = help_chat(query, max_length=100, do_sample=True, top_p=0.95)
167
- # Trim the response to show only the generated text
168
- return response[0]['generated_text']
 
169
  except Exception as e:
170
  return f"Error in help agent: {str(e)}"
171
 
 
172
  # Main game logic
173
  def main():
174
  inject_custom_css()
 
158
  # (replacing the original BlenderBot approach with DialoGPT for simplicity)
159
  def ask_help_agent(query):
160
  try:
161
+ from transformers import pipeline, Conversation
162
+ # Use the conversational pipeline with DialoGPT-medium for dialogue context
163
+ help_chat = pipeline("conversational", model="microsoft/DialoGPT-medium")
164
+ # Create a Conversation object to hold the context
165
+ conv = Conversation(query)
166
+ # Generate a response by passing the conversation object
167
+ response = help_chat(conv)
168
+ # Extract and return the generated response from the conversation
169
+ return conv.generated_responses[-1]
170
  except Exception as e:
171
  return f"Error in help agent: {str(e)}"
172
 
173
+
174
  # Main game logic
175
  def main():
176
  inject_custom_css()