Add main.py
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
from langchain import LLMChain, PromptTemplate
|
||||||
|
from langchain_openai import OpenAI
|
||||||
|
|
||||||
|
def main():
|
||||||
|
template = """
|
||||||
|
You are a helpful assistant.
|
||||||
|
Question: {question}
|
||||||
|
Answer:"""
|
||||||
|
prompt = PromptTemplate(template=template, input_variables=["question"])
|
||||||
|
llm = OpenAI(api_key="YOUR_API_KEY", temperature=0.7)
|
||||||
|
chain = LLMChain(llm=llm, prompt=prompt)
|
||||||
|
while True:
|
||||||
|
q = input("Ask a question (or 'exit'): ")
|
||||||
|
if q.lower() in {"exit", "quit"}:
|
||||||
|
break
|
||||||
|
print(chain.run({"question": q}))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user