Spaces:
Runtime error
Runtime error
Update app.py
Browse files81 unmodified lines82838485868788899091929394959697989910010110210310410510610710881 unmodified linesreturn "⚠️ Sorry, I only respond in English. Can you rephrase your question?"# ✅ Follow-Up Question Generation (Ensures Proper Formatting)def generate_follow_up(user_text):"""Generates a structured follow-up question in a concise format."""prompt_text = (f"Given the user's question: '{user_text}', generate a SHORT follow-up question in the format: ""'Would you like to learn more about [related topic] or explore something else?'. ""Ensure it's concise and structured exactly as requested without extra commentary.")hf = get_llm_hf_inference(max_new_tokens=30, temperature=0.3)output = hf.invoke(input=prompt_text).strip()# ✅ Extract relevant part, removing unwanted symbolscleaned_output = re.sub(r"```|''|\"", "", output).strip()if "Would you like to learn more about" not in cleaned_output:cleaned_output = "Would you like to explore another related topic or ask about something else?"return cleaned_output# ✅ Main Response Function (Fixed History & Language Issues)def get_response(system_message, user_text, max_new_tokens=800):"""Generates a response and ensures conversation history is updated."""81 unmodified lines82838485868781 unmodified linesreturn "⚠️ Sorry, I only respond in English. Can you rephrase your question?"# ✅ Main Response Function (Fixed History & Language Issues)def get_response(system_message, user_text, max_new_tokens=800):"""Generates a response and ensures conversation history is updated."""
app.py-21