-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBasicPromptTemplate.py
More file actions
35 lines (27 loc) · 1005 Bytes
/
BasicPromptTemplate.py
File metadata and controls
35 lines (27 loc) · 1005 Bytes
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
29
30
31
32
33
34
35
"""
This application will fetch the Celebrity Name from User in the form of Template and
returns or displays the response from the LLM in the app
"""
## To Integrate our code with OpenAI API
import os
from constants import openai_key
from langchain_openai import OpenAI
from langchain_core.prompts.prompt import PromptTemplate
from langchain.chains import LLMChain
# For UI Webpages
import streamlit as st
# Seeting the Environment Variables
os.environ['OPENAI_API_KEY'] = openai_key
# streamlit framework
st.title('Celebrity Search using LangChain')
input_text = st.text_input('Mention the name of the Celebrity ')
# Prompt Template
first_input_prompt = PromptTemplate(
input_variables=['name'],
template= 'Please briefly describe about the Celebrity - {name}'
)
# OpenAI Large Language Models
llm = OpenAI(temperature=0.8)
chain = LLMChain(llm= llm, prompt= first_input_prompt, verbose =True)
if input_text:
st.write(chain.run(input_text))