rm deprecated codes

This commit is contained in:
2025-06-05 08:46:45 +08:00
parent 6e477db0b2
commit f160ba76b5
3 changed files with 21 additions and 306 deletions

View File

@ -6,7 +6,7 @@
import streamlit as st
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from langchain_community.chat_models import ChatOllama
from langchain_ollama import ChatOllama
from utils import parse_config
@ -42,7 +42,7 @@ class TranslatorApp:
input_variables=['input_text', 'source_lang', 'target_lang', 'rule'],
template=template
)
return LLMChain(llm=llm, prompt=prompt)
return prompt | llm
def run(self) -> None:
""" Run the Streamlit app """
@ -75,12 +75,12 @@ class TranslatorApp:
with st.spinner('翻譯中...'):
source_lang, target_lang, rule = self._lang_directions[direction]
result = self._chain.run({
result = self._chain.invoke({
'input_text': input_text,
'source_lang': source_lang,
'target_lang': target_lang,
'rule': rule
}).strip()
}).content
output_container.text_area(
label='Output',