learnai / app.py
deepakaitcs's picture
first
24c1914
raw
history blame
761 Bytes
# import openai
from langchain_openai.llms import OpenAI
from dotenv import load_dotenv
import os
from langchain_core.prompts import PromptTemplate
from langchain.chains import LLMChain
# os.environ["OPENAPI_KEY"]='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'
load_dotenv()
api_key = os.environ['OPEN_API_KEY'];
llm = OpenAI(openai_api_key=api_key)
mytemplate = """Question: {question}
Answer: Let's think step by step."""
# prompt = PromptTemplate.from_template(mytemplate)
# mychain = LLMChain(llm=llm, prompt=prompt)
# question ="who is fastest man on earth?"
# print(mychain.run(question))
result= llm.generate(['two hit movies of bollywood ', 'two flop movies of bollywood'])
print(result.llm_output)
print(result.generations[1][0].text)