yashasgupta commited on
Commit
2701462
·
verified ·
1 Parent(s): dea4769

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,13 +3,11 @@ from langchain import OpenAI
3
  from langchain.chains import LLMChain
4
  from langchain.prompts import ChatPromptTemplate
5
  import os
 
6
 
7
  os.environ["OPENAI_API_KEY"] = os.getenv("k1")
8
 
9
 
10
- llm = OpenAI(api_key = os.environ["OPENAI_API_KEY"],model="gpt-3.5", temperature=0)
11
-
12
-
13
  st.title("Summarization Application :robot_face:")
14
 
15
  options = ["English", "Telugu", "Hindi", "French", "German", "Russian", "Spanish"]
@@ -19,10 +17,12 @@ input_language = st.selectbox("Input Language: ", options)
19
  text = st.text_area("Text Input: ")
20
 
21
  if st.button("Submit"):
 
 
22
  prompt = ChatPromptTemplate.from_messages([("system", "You are an expert summarizer for {lang} texts."),
23
  ("human", "{text}")])
24
 
25
- chain = LLMChain(prompt=prompt, llm=llm)
26
 
27
  response = chain.run({"lang": input_language, "text": text})
28
 
 
3
  from langchain.chains import LLMChain
4
  from langchain.prompts import ChatPromptTemplate
5
  import os
6
+ from langchain_openai import ChatOpenAI
7
 
8
  os.environ["OPENAI_API_KEY"] = os.getenv("k1")
9
 
10
 
 
 
 
11
  st.title("Summarization Application :robot_face:")
12
 
13
  options = ["English", "Telugu", "Hindi", "French", "German", "Russian", "Spanish"]
 
17
  text = st.text_area("Text Input: ")
18
 
19
  if st.button("Submit"):
20
+
21
+ llm = ChatOpenAI(model = "gpt-3.5-turbo",temperature = 0)
22
  prompt = ChatPromptTemplate.from_messages([("system", "You are an expert summarizer for {lang} texts."),
23
  ("human", "{text}")])
24
 
25
+ chain = prompt|llm
26
 
27
  response = chain.run({"lang": input_language, "text": text})
28