Add main.py

This commit is contained in:
2026-05-27 08:52:57 +00:00
parent 911279946e
commit 2ea0ea930e
+19
View File
@@ -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()