BishopAbimbola commited on
Commit
8e2cf78
·
1 Parent(s): b4fc2c8
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv
2
+ from langchain import LLMChain, HuggingFaceHub
3
+ from langchain.prompts import PromptTemplate
4
+ import gradio as gr
5
+
6
+ load_dotenv()
7
+
8
+
9
+ def storyTime(input_letter):
10
+ hub_llm = HuggingFaceHub(
11
+ repo_id="gpt2-large",
12
+ model_kwargs={'temperature': 0.5, 'max_length': 200}
13
+ )
14
+ prompt = PromptTemplate(
15
+ input_variables=["letter"],
16
+ template=" {letter}"
17
+ )
18
+
19
+ hub_chain = LLMChain(prompt=prompt, llm=hub_llm, verbose=True)
20
+ return hub_chain.run(input_letter)
21
+
22
+
23
+ iface = gr.Interface(
24
+ fn=storyTime,
25
+ inputs='text',
26
+ outputs=['text'],
27
+ title='Story Time😃',
28
+ description='Write a simple text you want a story on'
29
+ )
30
+
31
+ iface.launch(inline=False)
32
+
33
+ # input_letter = input("Write the first sentence of your letter: ")
34
+ # main(input_letter)