mirror of
https://github.com/tcsenpai/easy-web-summarizer.git
synced 2025-06-06 10:35:20 +00:00
Add translator.py for language translation feature
This commit is contained in:
parent
60a17e396f
commit
f9ad6825cb
19
translator.py
Normal file
19
translator.py
Normal file
@ -0,0 +1,19 @@
|
||||
from langchain.chains.llm import LLMChain
|
||||
from langchain.prompts import PromptTemplate
|
||||
from langchain_community.chat_models import ChatOllama
|
||||
|
||||
|
||||
def setup_translator_chain():
|
||||
"""Setup the translation chain with a prompt template and ChatOllama."""
|
||||
prompt_template = PromptTemplate(
|
||||
template="""As a professional translator, provide a detailed and comprehensive translation of the provided text into turkish, ensuring that the translation is accurate, coherent, and faithful to the original text.
|
||||
|
||||
"{text}"
|
||||
|
||||
DETAILED TRANSLATION:""",
|
||||
input_variables=["text"],
|
||||
)
|
||||
|
||||
llm = ChatOllama(model="llama3")
|
||||
llm_chain = LLMChain(llm=llm, prompt=prompt_template)
|
||||
return llm_chain
|
Loading…
x
Reference in New Issue
Block a user