neha-ai-playground commited on
Commit
79081f5
·
1 Parent(s): ab7de18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -3,7 +3,7 @@ from pathlib import Path
3
  import streamlit as st
4
  from transformers import pipeline
5
  from dotenv import load_dotenv
6
- from langchain import PromptTemplate, HuggingFaceHub, LLMChain
7
  import requests
8
 
9
  if Path(".env").is_file():
@@ -17,7 +17,6 @@ def img2Text(url):
17
  st.subheader("Caption :")
18
  st.subheader(text)
19
  return text
20
- img2Text("photo.jpg")
21
 
22
  #llm
23
  def generate_story(scenario):
@@ -29,14 +28,12 @@ def generate_story(scenario):
29
  """
30
 
31
  prompt = PromptTemplate(template=template,input_variables=["scenario"])
32
- llm_chain = LLMChain(prompt=prompt,
33
- llm=HuggingFaceHub(repo_id="google/flan-t5-xl",
34
- model_kwargs={"temperature":0,
35
- "max_length":64}))
36
- story =llm_chain.run(scenario)
37
  st.subheader("Story :")
38
  st.subheader(story)
39
- print(story)
40
  return story
41
 
42
  scenario = img2Text("photo.jpg")
 
3
  import streamlit as st
4
  from transformers import pipeline
5
  from dotenv import load_dotenv
6
+ from langchain import PromptTemplate, LLMChain, OpenAI
7
  import requests
8
 
9
  if Path(".env").is_file():
 
17
  st.subheader("Caption :")
18
  st.subheader(text)
19
  return text
 
20
 
21
  #llm
22
  def generate_story(scenario):
 
28
  """
29
 
30
  prompt = PromptTemplate(template=template,input_variables=["scenario"])
31
+ story_llm = LLMChain(llm=OpenAI(
32
+ model_name="gpt-3.5-turbo", temperature=1), prompt=prompt, verbose=True)
33
+ ))
34
+ story = story_llm.predict(scenario=scenario)
 
35
  st.subheader("Story :")
36
  st.subheader(story)
 
37
  return story
38
 
39
  scenario = img2Text("photo.jpg")