import streamlit as st from prompt import get_llm_response from post_process import process_response # 页面配置 st.set_page_config( page_title="EnglishMate - 你的英语学习助手", page_icon="⚡", layout="wide" ) # 页面标题 st.title("EnglishMate - 你的英语学习助手 ⚡") st.markdown("输入中文,获取地道的英语表达!") # 用户输入区域 example_text = "我昨天跟同学在西公园打篮球,我成功完成了一次暴扣。" user_input = st.text_area("请输入你想用英语表达的内容:", value=example_text, height=150) # 添加提交按钮 if st.button("翻译"): if user_input: with st.spinner('正在生成英语表达...'): # 调用LLM获取响应 response = get_llm_response(user_input) english_translation, important_words = process_response(response) # 高亮重要单词 for word in important_words: english_translation = english_translation.replace( word['word_en'], f"{word['word_en']}") # 显示英语表达 st.subheader("🔤 英语表达") st.markdown(f"