-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper.py
28 lines (25 loc) · 859 Bytes
/
helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Python
import os
from dataclasses import dataclass
from typing import List
# LangChain
from langchain import LLMChain, llms
from langchain import PromptTemplate
def chain(llm:llms, template:str, inputVariables: List[str], output_key:str):
"""Create a LLM Chain
Args:
llm (llms): One of Langchain's integration for LLMs
template (str): what will be passed to the LLMs
inputVariables (List[str]): The input for the chain
output_key (str): the name of the final output from the chain
Returns:
_type_: A LLMChain
"""
return LLMChain(
llm=llm,
prompt=PromptTemplate(
input_variables=inputVariables,
template=template
),
output_key=output_key
)