SEO example
Browse files- app.py +4 -3
- components.py +3 -4
- examples/generate_ad.py +1 -1
- examples/seo.py +44 -0
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import actions as a
|
4 |
-
from examples import authenticate_google, best_clubs, generate_ad, summarize_website
|
5 |
from components import all_tasks, Tasks
|
6 |
|
7 |
|
@@ -15,7 +15,7 @@ with gr.Blocks() as demo:
|
|
15 |
<br>
|
16 |
<br>**AI Task**: Ask ChatGPT to do something for you. Eg, summarize a text.
|
17 |
<br>**Code Task**: You will need code to do certain things that ChatGPT can't do, like access the internet or iterate over 4k+ tokens.
|
18 |
-
<br> With this task, ChatGPT will generate code
|
19 |
<br>
|
20 |
<br>Output from previous tasks can be referenced in subsequen tasks with {tn}. Max 10 tasks allowed (for now).
|
21 |
"""
|
@@ -62,8 +62,9 @@ with gr.Blocks() as demo:
|
|
62 |
|
63 |
# Examples
|
64 |
summarize_website.render()
|
65 |
-
|
66 |
best_clubs.render()
|
|
|
67 |
authenticate_google.render()
|
68 |
|
69 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import actions as a
|
4 |
+
from examples import authenticate_google, best_clubs, generate_ad, seo, summarize_website
|
5 |
from components import all_tasks, Tasks
|
6 |
|
7 |
|
|
|
15 |
<br>
|
16 |
<br>**AI Task**: Ask ChatGPT to do something for you. Eg, summarize a text.
|
17 |
<br>**Code Task**: You will need code to do certain things that ChatGPT can't do, like access the internet or iterate over 4k+ tokens.
|
18 |
+
<br> With this task, ChatGPT will generate code and then execute. The code must be generated before executing all tasks.
|
19 |
<br>
|
20 |
<br>Output from previous tasks can be referenced in subsequen tasks with {tn}. Max 10 tasks allowed (for now).
|
21 |
"""
|
|
|
62 |
|
63 |
# Examples
|
64 |
summarize_website.render()
|
65 |
+
seo.render()
|
66 |
best_clubs.render()
|
67 |
+
generate_ad.render()
|
68 |
authenticate_google.render()
|
69 |
|
70 |
demo.launch()
|
components.py
CHANGED
@@ -201,12 +201,11 @@ class CodeTask(TaskComponent):
|
|
201 |
print(f"Generating code.")
|
202 |
try:
|
203 |
raw_output = llm_call(
|
204 |
-
f"""
|
205 |
{code_prompt}
|
206 |
|
207 |
-
Name the function toolkit.
|
208 |
Use pip packages where available.
|
209 |
-
For example, if you wanted to make a google search, use the googlesearch-python package instead of scraping google.
|
210 |
Include the necessary imports.
|
211 |
Instead of printing or saving to disk, the function should return the data."""
|
212 |
)
|
@@ -225,7 +224,7 @@ Include only the packages that need to be installed with pip.
|
|
225 |
Put them in a valid JSON:
|
226 |
```
|
227 |
{{
|
228 |
-
"packages":
|
229 |
}}
|
230 |
```""",
|
231 |
f"""The following text has some python code:
|
|
|
201 |
print(f"Generating code.")
|
202 |
try:
|
203 |
raw_output = llm_call(
|
204 |
+
f"""Write a python function to:
|
205 |
{code_prompt}
|
206 |
|
207 |
+
Write the code for the function. Name the function toolkit.
|
208 |
Use pip packages where available.
|
|
|
209 |
Include the necessary imports.
|
210 |
Instead of printing or saving to disk, the function should return the data."""
|
211 |
)
|
|
|
224 |
Put them in a valid JSON:
|
225 |
```
|
226 |
{{
|
227 |
+
"packages": List of packages. If no packages, empty list.
|
228 |
}}
|
229 |
```""",
|
230 |
f"""The following text has some python code:
|
examples/generate_ad.py
CHANGED
@@ -28,7 +28,7 @@ Avoid logos.""",
|
|
28 |
2,
|
29 |
"{t1}",
|
30 |
visible=True,
|
31 |
-
code_value="Use openai
|
32 |
),
|
33 |
AITask(
|
34 |
1,
|
|
|
28 |
2,
|
29 |
"{t1}",
|
30 |
visible=True,
|
31 |
+
code_value="Use openai to generate an image from a prompt. Use they key {your_key}. Return the url.",
|
32 |
),
|
33 |
AITask(
|
34 |
1,
|
examples/seo.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from components import AITask, CodeTask
|
3 |
+
|
4 |
+
from examples import demo_buttons, demo_tasks
|
5 |
+
|
6 |
+
|
7 |
+
DEMO_ID = __name__
|
8 |
+
tasks = [
|
9 |
+
CodeTask(
|
10 |
+
0,
|
11 |
+
"https://techcrunch.com",
|
12 |
+
visible=True,
|
13 |
+
code_value="Get the text from a website. Remove empty lines.",
|
14 |
+
),
|
15 |
+
AITask(
|
16 |
+
1,
|
17 |
+
"""Here is the text from a website:
|
18 |
+
{t0}
|
19 |
+
|
20 |
+
Analyze it and give me recommendations to optimize its SEO. Give the recommendations in the order of most impactful to least impactful.""",
|
21 |
+
visible=True,
|
22 |
+
),
|
23 |
+
]
|
24 |
+
demo_tasks[DEMO_ID] = tasks
|
25 |
+
|
26 |
+
|
27 |
+
def render():
|
28 |
+
with gr.Tab("Example: SEO recommendations"):
|
29 |
+
demo_id = gr.Textbox(DEMO_ID, visible=False)
|
30 |
+
with gr.Box():
|
31 |
+
gr.Dropdown(
|
32 |
+
value=CodeTask.name,
|
33 |
+
label="Pick a new Task",
|
34 |
+
interactive=False,
|
35 |
+
)
|
36 |
+
tasks[0].render()
|
37 |
+
with gr.Box():
|
38 |
+
gr.Dropdown(
|
39 |
+
value=AITask.name,
|
40 |
+
label="Pick a new Task",
|
41 |
+
interactive=False,
|
42 |
+
)
|
43 |
+
tasks[1].render()
|
44 |
+
demo_buttons(demo_id, tasks)
|