Spaces:
Paused
Paused
Add UI, LangChain templates & code, and example texts
Browse files- .gitignore +140 -0
- .idea/.gitignore +3 -0
- .idea/inspectionProfiles/Project_Default.xml +14 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +4 -0
- .idea/modules.xml +8 -0
- .idea/slides-wizard.iml +10 -0
- .idea/vcs.xml +6 -0
- app.py +84 -0
- examples/example_01.json +4 -0
- examples/example_02.json +4 -0
- global_config.py +22 -0
- langchain_templates/template_02.txt +12 -0
- langchain_templates/template_03.txt +12 -0
- langchain_templates/template_04.txt +12 -0
- langchain_templates/template_06.txt +12 -0
- langchain_templates/template_07.txt +12 -0
- langchain_templates/ztemplate_01.txt +12 -0
- langchain_templates/ztemplate_05.txt +9 -0
- llm_agent.py +89 -0
- requirements.txt +4 -0
.gitignore
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
### Python template
|
2 |
+
# Byte-compiled / optimized / DLL files
|
3 |
+
__pycache__/
|
4 |
+
*.py[cod]
|
5 |
+
*$py.class
|
6 |
+
|
7 |
+
# C extensions
|
8 |
+
*.so
|
9 |
+
|
10 |
+
# Distribution / packaging
|
11 |
+
.Python
|
12 |
+
build/
|
13 |
+
develop-eggs/
|
14 |
+
dist/
|
15 |
+
downloads/
|
16 |
+
eggs/
|
17 |
+
.eggs/
|
18 |
+
lib/
|
19 |
+
lib64/
|
20 |
+
parts/
|
21 |
+
sdist/
|
22 |
+
var/
|
23 |
+
wheels/
|
24 |
+
share/python-wheels/
|
25 |
+
*.egg-info/
|
26 |
+
.installed.cfg
|
27 |
+
*.egg
|
28 |
+
MANIFEST
|
29 |
+
|
30 |
+
# PyInstaller
|
31 |
+
# Usually these files are written by a python script from a template
|
32 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33 |
+
*.manifest
|
34 |
+
*.spec
|
35 |
+
|
36 |
+
# Installer logs
|
37 |
+
pip-log.txt
|
38 |
+
pip-delete-this-directory.txt
|
39 |
+
|
40 |
+
# Unit test / coverage reports
|
41 |
+
htmlcov/
|
42 |
+
.tox/
|
43 |
+
.nox/
|
44 |
+
.coverage
|
45 |
+
.coverage.*
|
46 |
+
.cache
|
47 |
+
nosetests.xml
|
48 |
+
coverage.xml
|
49 |
+
*.cover
|
50 |
+
*.py,cover
|
51 |
+
.hypothesis/
|
52 |
+
.pytest_cache/
|
53 |
+
cover/
|
54 |
+
|
55 |
+
# Translations
|
56 |
+
*.mo
|
57 |
+
*.pot
|
58 |
+
|
59 |
+
# Django stuff:
|
60 |
+
*.log
|
61 |
+
local_settings.py
|
62 |
+
db.sqlite3
|
63 |
+
db.sqlite3-journal
|
64 |
+
|
65 |
+
# Flask stuff:
|
66 |
+
instance/
|
67 |
+
.webassets-cache
|
68 |
+
|
69 |
+
# Scrapy stuff:
|
70 |
+
.scrapy
|
71 |
+
|
72 |
+
# Sphinx documentation
|
73 |
+
docs/_build/
|
74 |
+
|
75 |
+
# PyBuilder
|
76 |
+
.pybuilder/
|
77 |
+
target/
|
78 |
+
|
79 |
+
# Jupyter Notebook
|
80 |
+
.ipynb_checkpoints
|
81 |
+
|
82 |
+
# IPython
|
83 |
+
profile_default/
|
84 |
+
ipython_config.py
|
85 |
+
|
86 |
+
# pyenv
|
87 |
+
# For a library or package, you might want to ignore these files since the code is
|
88 |
+
# intended to run in multiple environments; otherwise, check them in:
|
89 |
+
# .python-version
|
90 |
+
|
91 |
+
# pipenv
|
92 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
93 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
94 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
95 |
+
# install all needed dependencies.
|
96 |
+
#Pipfile.lock
|
97 |
+
|
98 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
99 |
+
__pypackages__/
|
100 |
+
|
101 |
+
# Celery stuff
|
102 |
+
celerybeat-schedule
|
103 |
+
celerybeat.pid
|
104 |
+
|
105 |
+
# SageMath parsed files
|
106 |
+
*.sage.py
|
107 |
+
|
108 |
+
# Environments
|
109 |
+
.env
|
110 |
+
.venv
|
111 |
+
env/
|
112 |
+
venv/
|
113 |
+
ENV/
|
114 |
+
env.bak/
|
115 |
+
venv.bak/
|
116 |
+
|
117 |
+
# Spyder project settings
|
118 |
+
.spyderproject
|
119 |
+
.spyproject
|
120 |
+
|
121 |
+
# Rope project settings
|
122 |
+
.ropeproject
|
123 |
+
|
124 |
+
# mkdocs documentation
|
125 |
+
/site
|
126 |
+
|
127 |
+
# mypy
|
128 |
+
.mypy_cache/
|
129 |
+
.dmypy.json
|
130 |
+
dmypy.json
|
131 |
+
|
132 |
+
# Pyre type checker
|
133 |
+
.pyre/
|
134 |
+
|
135 |
+
# pytype static type analyzer
|
136 |
+
.pytype/
|
137 |
+
|
138 |
+
# Cython debug symbols
|
139 |
+
cython_debug/
|
140 |
+
|
.idea/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
.idea/inspectionProfiles/Project_Default.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<profile version="1.0">
|
3 |
+
<option name="myName" value="Project Default" />
|
4 |
+
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
5 |
+
<option name="ignoredPackages">
|
6 |
+
<value>
|
7 |
+
<list size="1">
|
8 |
+
<item index="0" class="java.lang.String" itemvalue="numpy" />
|
9 |
+
</list>
|
10 |
+
</value>
|
11 |
+
</option>
|
12 |
+
</inspection_tool>
|
13 |
+
</profile>
|
14 |
+
</component>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (slides-wizard) (2)" project-jdk-type="Python SDK" />
|
4 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/slides-wizard.iml" filepath="$PROJECT_DIR$/.idea/slides-wizard.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/slides-wizard.iml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$">
|
5 |
+
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
6 |
+
</content>
|
7 |
+
<orderEntry type="jdk" jdkName="Python 3.10 (slides-wizard) (2)" jdkType="Python SDK" />
|
8 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
9 |
+
</component>
|
10 |
+
</module>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
app.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
import llm_agent
|
4 |
+
from global_config import GlobalConfig
|
5 |
+
|
6 |
+
|
7 |
+
def build_ui():
|
8 |
+
st.write('''
|
9 |
+
# Slides Wizard
|
10 |
+
|
11 |
+
*Create your next presentation using AI*
|
12 |
+
''')
|
13 |
+
|
14 |
+
name = st.text_input(
|
15 |
+
f'''**Type in your name**''',
|
16 |
+
value='John Doe'
|
17 |
+
)
|
18 |
+
|
19 |
+
topic = st.text_area(
|
20 |
+
f'''**Describe the topic of the presentation.
|
21 |
+
Avoid mentioning the count of slides.**''',
|
22 |
+
value='''Make a presentation about AI. Talk about its pros, cons, and future prospects. '''
|
23 |
+
'''Add examples of some real-life use cases in engineering and medicine.'''
|
24 |
+
)
|
25 |
+
|
26 |
+
audience = st.text_input(
|
27 |
+
f'''**Briefly describe your target audience**''',
|
28 |
+
value='I am a teacher and want to present these slides to college students'
|
29 |
+
)
|
30 |
+
|
31 |
+
if st.button('Generate slides'):
|
32 |
+
progress_text = 'Generating your presentation slides...give it a moment'
|
33 |
+
progress_bar = st.progress(0, text=progress_text)
|
34 |
+
|
35 |
+
name_txt = name.strip()
|
36 |
+
topic_txt = topic.strip()
|
37 |
+
audience_txt = audience.strip()
|
38 |
+
|
39 |
+
process_inputs(name_txt, topic_txt, audience_txt, progress_bar)
|
40 |
+
|
41 |
+
|
42 |
+
def process_inputs(name: str, topic: str, audience: str, progress_bar):
|
43 |
+
name_length = len(name)
|
44 |
+
topic_length = len(topic)
|
45 |
+
audience_length = len(audience)
|
46 |
+
print(f'Input lengths:: name: {name_length}, topic: {topic_length}, audience: {audience_length}')
|
47 |
+
|
48 |
+
if name_length > 0 and topic_length > 10 and audience_length > 5:
|
49 |
+
print(
|
50 |
+
f'Name: {name}\n'
|
51 |
+
f'Topic: {topic}\n'
|
52 |
+
f'Audience: {audience}'
|
53 |
+
)
|
54 |
+
print('=' * 20)
|
55 |
+
|
56 |
+
target_length = min(topic_length, GlobalConfig.LLM_MODEL_MAX_INPUT_LENGTH)
|
57 |
+
|
58 |
+
try:
|
59 |
+
slides_content = llm_agent.generate_slides_content(name, topic[:target_length], audience)
|
60 |
+
|
61 |
+
print('=' * 20)
|
62 |
+
print(f'Slides content:\n{slides_content}')
|
63 |
+
print('=' * 20)
|
64 |
+
st.write(f'''Slides content:\n{slides_content}''')
|
65 |
+
progress_bar.progress(100, text='Done!')
|
66 |
+
except ValueError as ve:
|
67 |
+
st.error(f'Unfortunately, an error occurred: {ve}! '
|
68 |
+
f'Please change the text, try again later, or report it, sharing your inputs.')
|
69 |
+
|
70 |
+
# image = generate_image_from_text(summary)
|
71 |
+
# progress_bar.progress(100, text='Done!')
|
72 |
+
#
|
73 |
+
# st.image(image, caption=summary)
|
74 |
+
# st.info('Tip: Right-click on the image to save it')
|
75 |
+
else:
|
76 |
+
st.error('Not enough information provided! Please be little more descriptive :)')
|
77 |
+
|
78 |
+
|
79 |
+
def main():
|
80 |
+
build_ui()
|
81 |
+
|
82 |
+
|
83 |
+
if __name__ == '__main__':
|
84 |
+
main()
|
examples/example_01.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"topic": "Create slides for a tutorial on Python, covering the basic data types, conditions, and loops.",
|
3 |
+
"audience": "People with no technology background"
|
4 |
+
}
|
examples/example_02.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"topic": "Talk about AI, covering what it is and how it works. Add its pros, cons, and future prospects. Also, cover its job prospects.",
|
3 |
+
"audience": "I am a teacher and want to present these slides to college students."
|
4 |
+
}
|
global_config.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import dataclass
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
import os
|
4 |
+
|
5 |
+
load_dotenv()
|
6 |
+
|
7 |
+
|
8 |
+
@dataclass(frozen=True)
|
9 |
+
class GlobalConfig:
|
10 |
+
HUGGINGFACEHUB_API_TOKEN: str = os.getenv('HUGGINGFACEHUB_API_TOKEN')
|
11 |
+
|
12 |
+
# Flan-T5
|
13 |
+
# LLM_MODEL_NAME: str = 'google/flan-t5-xxl'
|
14 |
+
LLM_MODEL_NAME = 'tiiuae/falcon-7b-instruct'
|
15 |
+
LLM_MODEL_TEMPERATURE: float = 0.5
|
16 |
+
LLM_MODEL_MIN_OUTPUT_LENGTH: int = 200
|
17 |
+
LLM_MODEL_MAX_OUTPUT_LENGTH: int = 2000
|
18 |
+
LLM_MODEL_MAX_INPUT_LENGTH: int = 1000
|
19 |
+
|
20 |
+
# # Stable Diffusion
|
21 |
+
# DIFFUSION_MODEL_NAME: str = 'stabilityai/stable-diffusion-2-1'
|
22 |
+
# DIFFUSION_NUM_INFERENCE_STEPS: int = 3
|
langchain_templates/template_02.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a helpful, intelligent chatbot. Create the slides for a presentation on the given topic. Include main headings for each slide, detailed bullet points for each slide, ideas for photos for each slide and an impactful intro and closing slide.
|
2 |
+
|
3 |
+
|
4 |
+
Topic:
|
5 |
+
```{topic}```
|
6 |
+
|
7 |
+
|
8 |
+
Target audience:
|
9 |
+
```{audience}```
|
10 |
+
|
11 |
+
|
12 |
+
Generate an engaging title for the presentation and output it in the first line. The next line should contain the speaker's name. Add a title and number to each slide on a separate line.
|
langchain_templates/template_03.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a helpful, intelligent chatbot. Create the slides for a presentation on the given topic. Include main headings for each slide, detailed bullet points for each slide, ideas for photos for each slide and an impactful intro and closing slide.
|
2 |
+
|
3 |
+
|
4 |
+
Topic:
|
5 |
+
```{topic}```
|
6 |
+
|
7 |
+
|
8 |
+
Target audience:
|
9 |
+
```{audience}```
|
10 |
+
|
11 |
+
|
12 |
+
Generate an engaging title for the presentation. Add a title and number to each slide on a separate line.
|
langchain_templates/template_04.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a helpful, intelligent chatbot. Create the slides for a presentation on the given topic. Include main headings for each slide, detailed bullet points for each slide, ideas for photos for each slide and an impactful intro and closing slide.
|
2 |
+
|
3 |
+
|
4 |
+
Topic:
|
5 |
+
```{topic}```
|
6 |
+
|
7 |
+
|
8 |
+
Target audience:
|
9 |
+
```{audience}```
|
10 |
+
|
11 |
+
|
12 |
+
Generate an engaging title for the presentation. Add a title and number to each slide on a separate line.
|
langchain_templates/template_06.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a helpful, intelligent chatbot. Create the slides for a presentation on the given topic. Include main headings for each slide, detailed bullet points for each slide, as well as impactful introductory and closing slides. Add relevant content to each slide.
|
2 |
+
|
3 |
+
|
4 |
+
Topic:
|
5 |
+
```{topic}```
|
6 |
+
|
7 |
+
|
8 |
+
Target audience:
|
9 |
+
```{audience}```
|
10 |
+
|
11 |
+
|
12 |
+
Finally, generate an engaging title for the presentation aimed for the target audience.
|
langchain_templates/template_07.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a helpful, intelligent chatbot. Create the slides for a presentation on the given topic. Include main headings for each slide, detailed bullet points for each slide. Add relevant content to each slide.
|
2 |
+
|
3 |
+
|
4 |
+
Topic:
|
5 |
+
```{topic}```
|
6 |
+
|
7 |
+
|
8 |
+
Target audience:
|
9 |
+
```{audience}```
|
10 |
+
|
11 |
+
|
12 |
+
Finally, generate an engaging title for the presentation aimed for the target audience.
|
langchain_templates/ztemplate_01.txt
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Act like a professional speaker and expert in PowerPoint: Create the outline for a PowerPoint presentation on any given topic. Include main headings for each slide, detailed bullet points for each slide, ideas for photos for each slide and an impactful intro and closing slide.
|
2 |
+
|
3 |
+
|
4 |
+
Topic:
|
5 |
+
```{topic}```
|
6 |
+
|
7 |
+
|
8 |
+
Target audience:
|
9 |
+
```{audience}```
|
10 |
+
|
11 |
+
|
12 |
+
Generate an engaging title for the presentation and output it in the first line. The next line should contain the speaker's name. Add a title and number to each slide on a separate line.
|
langchain_templates/ztemplate_05.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a helpful, intelligent chatbot. Create the slides for a presentation on the given topic. Generate an engaging title for the presentation aimed for the target audience. Include main headings for each slide, detailed bullet points for each slide. Include impactful introductory and closing slides. Add relevant content to each slide.
|
2 |
+
|
3 |
+
|
4 |
+
Topic:
|
5 |
+
```{topic}```
|
6 |
+
|
7 |
+
|
8 |
+
Target audience:
|
9 |
+
```{audience}```
|
llm_agent.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain import HuggingFaceHub, PromptTemplate
|
2 |
+
|
3 |
+
from global_config import GlobalConfig
|
4 |
+
|
5 |
+
|
6 |
+
llm = HuggingFaceHub(
|
7 |
+
repo_id=GlobalConfig.LLM_MODEL_NAME,
|
8 |
+
task='text-generation',
|
9 |
+
huggingfacehub_api_token=GlobalConfig.HUGGINGFACEHUB_API_TOKEN,
|
10 |
+
model_kwargs={
|
11 |
+
'temperature': GlobalConfig.LLM_MODEL_TEMPERATURE,
|
12 |
+
'min_length': GlobalConfig.LLM_MODEL_MIN_OUTPUT_LENGTH,
|
13 |
+
'max_length': GlobalConfig.LLM_MODEL_MAX_OUTPUT_LENGTH,
|
14 |
+
'max_new_tokens': GlobalConfig.LLM_MODEL_MAX_OUTPUT_LENGTH,
|
15 |
+
'num_return_sequences': 1
|
16 |
+
}
|
17 |
+
)
|
18 |
+
print(llm)
|
19 |
+
|
20 |
+
#
|
21 |
+
# so that the speaker can deliver an engaging talk to the target audience. You use facts in your slides. When necessary,
|
22 |
+
# you also look up online for further details
|
23 |
+
|
24 |
+
template = '''
|
25 |
+
You are an artificial intelligence assistant.
|
26 |
+
You are experienced in creating slides for a presentation on any given topic.
|
27 |
+
Generate a slide deck based on the following information:
|
28 |
+
|
29 |
+
|
30 |
+
Topic:
|
31 |
+
```{topic}```
|
32 |
+
|
33 |
+
|
34 |
+
Target audience:
|
35 |
+
```{audience}```
|
36 |
+
|
37 |
+
|
38 |
+
Generate an engaging title for the presentation and output it as the first line.
|
39 |
+
The next line should contain the speaker's name.
|
40 |
+
Add a title and number to each slide on a separate line.
|
41 |
+
Each slide should have a bulleted list of items to talk about.
|
42 |
+
'''
|
43 |
+
|
44 |
+
|
45 |
+
template2 = '''
|
46 |
+
Act like a professional speaker and expert in PowerPoint: Create the outline for a PowerPoint presentation on
|
47 |
+
any given topic. Include main headings for each slide, detailed bullet points for each slide,
|
48 |
+
ideas for photos for each slide and an impactful intro and closing slide.
|
49 |
+
|
50 |
+
|
51 |
+
Speaker's name:
|
52 |
+
```{name}```
|
53 |
+
|
54 |
+
|
55 |
+
Topic:
|
56 |
+
```{topic}```
|
57 |
+
|
58 |
+
|
59 |
+
Target audience:
|
60 |
+
```{audience}```
|
61 |
+
|
62 |
+
|
63 |
+
Generate an engaging title for the presentation and output it in the first line.
|
64 |
+
The next line should contain the speaker's name.
|
65 |
+
Add a title and number to each slide on a separate line.
|
66 |
+
'''
|
67 |
+
|
68 |
+
# The contents of the slides should be in plain-text in the form of bulleted list items.
|
69 |
+
|
70 |
+
with open('langchain_templates/template_07.txt', 'r') as in_file:
|
71 |
+
template_txt = in_file.read().strip()
|
72 |
+
|
73 |
+
# prompt = PromptTemplate.from_template(template)
|
74 |
+
prompt = PromptTemplate.from_template(template_txt)
|
75 |
+
|
76 |
+
|
77 |
+
def generate_slides_content(name: str, topic: str, audience: str) -> str:
|
78 |
+
"""
|
79 |
+
Generate the contents of slides for a presentation on a given topic.
|
80 |
+
|
81 |
+
:return: The summary
|
82 |
+
"""
|
83 |
+
|
84 |
+
formatted_prompt = prompt.format(topic=topic, audience=audience)
|
85 |
+
print(formatted_prompt)
|
86 |
+
|
87 |
+
slides_content = llm(formatted_prompt)
|
88 |
+
|
89 |
+
return slides_content
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
python-dotenv[cli]
|
2 |
+
langchain
|
3 |
+
huggingface_hub
|
4 |
+
streamlit
|