Abubakari commited on
Commit
15451a7
·
1 Parent(s): 78a6c91

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +52 -0
  2. banner.jpeg +0 -0
  3. key.txt +1 -0
  4. requirements.txt +57 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import openai
3
+
4
+ # load and set our key
5
+ openai.api_key = open("key.txt", "r").read().strip("\n")
6
+
7
+ st.write("<center><h1>Bedtime Story Teller with ChatGPT</h1></center>", unsafe_allow_html=True)
8
+
9
+ #st.image(img_banner)
10
+
11
+ # Description
12
+ st.write("Welcome to the Bedtime Story Teller with ChatGPT! Get ready for a delightful storytelling experience.")
13
+
14
+ def generate_story(keyword, writing_style, age, word_count):
15
+ #return "This is a test article generated without making API calls."
16
+ response = openai.ChatCompletion.create(
17
+ model="gpt-3.5-turbo",
18
+ messages=[
19
+ {"role": "user", "content": "Write a creative and interesting Bedtime about " + keyword},
20
+ {"role": "user", "content": "The story should be " + writing_style},
21
+ {"role": "user", "content": "The langugage and tone the story should target kids around the age" + str(age)},
22
+ {"role": "user", "content": "The story length should " + str(word_count)},
23
+ {"role": "user", "content": "The story length should have a strong moral undertone"},
24
+ ]
25
+ )
26
+ result = ''
27
+
28
+ for choice in response.choices:
29
+ result += choice.message.content
30
+
31
+ print(result)
32
+ return result
33
+
34
+ keyword = st.text_input("Enter a keyword:")
35
+ writing_style = st.selectbox("Select writing style:", ["African Short Stories", "African folktale", "African sci-fi", "African Magical Realism",
36
+ "African Thrillers/Mystery", "African Mythology", "African Historical Fiction"])
37
+ age = st.slider("Select Age of kid:", min_value=1, max_value=15, step=1, value=1)
38
+ word_count = st.slider("Select word count:", min_value=300, max_value=1000, step=100, value=300)
39
+ submit_button = st.button("Generate Story")
40
+
41
+ if submit_button:
42
+ message = st.empty()
43
+ message.text("Busy generating...")
44
+ article = generate_story(keyword, writing_style, age, word_count)
45
+ message.text("")
46
+ st.write(article)
47
+ st.download_button(
48
+ label="Download Story",
49
+ data=article,
50
+ file_name= 'Story.txt',
51
+ mime='text/txt',
52
+ )
banner.jpeg ADDED
key.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 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
requirements.txt ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohttp==3.8.4
2
+ aiosignal==1.3.1
3
+ altair==4.2.2
4
+ async-timeout==4.0.2
5
+ attrs==22.2.0
6
+ blinker==1.5
7
+ cachetools==5.3.0
8
+ certifi @ file:///private/var/folders/sy/f16zz6x50xz3113nwtb9bvq00000gp/T/abs_477u68wvzm/croot/certifi_1671487773341/work/certifi
9
+ charset-normalizer==3.1.0
10
+ click==8.1.3
11
+ decorator==5.1.1
12
+ entrypoints==0.4
13
+ frozenlist==1.3.3
14
+ gitdb==4.0.10
15
+ GitPython==3.1.31
16
+ idna==3.4
17
+ importlib-metadata==6.0.0
18
+ Jinja2==3.1.2
19
+ jsonschema==4.17.3
20
+ lxml==4.9.2
21
+ markdown-it-py==2.2.0
22
+ MarkupSafe==2.1.2
23
+ mdurl==0.1.2
24
+ multidict==6.0.4
25
+ numpy==1.24.2
26
+ openai==0.27.2
27
+ packaging==23.0
28
+ pandas==1.5.3
29
+ Pillow==9.4.0
30
+ protobuf==3.20.3
31
+ pyarrow==11.0.0
32
+ pydeck==0.8.0
33
+ Pygments==2.14.0
34
+ Pympler==1.0.1
35
+ pyrsistent==0.19.3
36
+ python-dateutil==2.8.2
37
+ python-docx==0.8.11
38
+ pytz==2022.7.1
39
+ pytz-deprecation-shim==0.1.0.post0
40
+ requests==2.28.2
41
+ rich==13.3.2
42
+ semver==2.13.0
43
+ six==1.16.0
44
+ smmap==5.0.0
45
+ streamlit==1.20.0
46
+ toml==0.10.2
47
+ toolz==0.12.0
48
+ tornado==6.2
49
+ tqdm==4.65.0
50
+ typing_extensions==4.5.0
51
+ tzdata==2022.7
52
+ tzlocal==4.2
53
+ urllib3==1.26.15
54
+ validators==0.20.0
55
+ watchdog==2.3.1
56
+ yarl==1.8.2
57
+ zipp==3.15.0