Upload 11 files
Browse files- ContentGeneratorAgent.py +88 -0
- GameBuilderAgent.py +136 -0
- Images/ai-logo.png +0 -0
- Images/download.jpeg +0 -0
- Images/download.png +0 -0
- Images/github-logo.png +0 -0
- Images/hq720.jpg +0 -0
- Images/linkedin-logo.png +0 -0
- Images/testocr.png +0 -0
- app.py +145 -117
- markdown.py +208 -1
ContentGeneratorAgent.py
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from crewai import Agent, Task, Crew, Process
|
2 |
+
from crewai_tools import SerperDevTool
|
3 |
+
import os
|
4 |
+
|
5 |
+
# Model options
|
6 |
+
llm_models = [
|
7 |
+
"gemini/gemini-1.5-flash",
|
8 |
+
"gemini/gemini-1.5-pro",
|
9 |
+
"gemini/gemini-pro"
|
10 |
+
]
|
11 |
+
|
12 |
+
selected_model = llm_models[0]
|
13 |
+
|
14 |
+
def set_model(selected_model_name):
|
15 |
+
global selected_model
|
16 |
+
selected_model = selected_model_name
|
17 |
+
|
18 |
+
def configure_api_keys(gemini_api_key, search_choice, serper_api_key):
|
19 |
+
if not gemini_api_key:
|
20 |
+
raise ValueError("Gemini API key is required")
|
21 |
+
os.environ['GEMINI_API_KEY'] = gemini_api_key
|
22 |
+
search_tool = None
|
23 |
+
if search_choice == "Yes":
|
24 |
+
if not serper_api_key:
|
25 |
+
raise ValueError("Serper API key is required for online search")
|
26 |
+
os.environ['SERPER_API_KEY'] = serper_api_key
|
27 |
+
search_tool = SerperDevTool()
|
28 |
+
return search_tool
|
29 |
+
|
30 |
+
def run_crew_cga(gemini_api_key, search_choice, serper_api_key, topic):
|
31 |
+
try:
|
32 |
+
search_tool = configure_api_keys(gemini_api_key, search_choice, serper_api_key)
|
33 |
+
|
34 |
+
researcher = Agent(
|
35 |
+
role="Online Research Specialist",
|
36 |
+
goal=f"Aggregate comprehensive information on {topic}",
|
37 |
+
verbose=True,
|
38 |
+
backstory="Expert research analyst with data sourcing expertise",
|
39 |
+
tools=[search_tool] if search_tool else [],
|
40 |
+
llm=selected_model,
|
41 |
+
allow_delegation=True
|
42 |
+
)
|
43 |
+
|
44 |
+
content_writer = Agent(
|
45 |
+
role="Expert Content Writer",
|
46 |
+
goal=f"Create SEO-optimized content on {topic}",
|
47 |
+
verbose=True,
|
48 |
+
backstory="Professional writer with digital journalism background",
|
49 |
+
tools=[],
|
50 |
+
llm=selected_model,
|
51 |
+
allow_delegation=False
|
52 |
+
)
|
53 |
+
|
54 |
+
research_task = Task(
|
55 |
+
description=f"Conduct SEO research on '{topic}'",
|
56 |
+
expected_output="Detailed research report with SEO recommendations",
|
57 |
+
tools=[search_tool] if search_tool else [],
|
58 |
+
agent=researcher
|
59 |
+
)
|
60 |
+
|
61 |
+
writer_task = Task(
|
62 |
+
description=f"Write SEO-optimized article on '{topic}'",
|
63 |
+
expected_output="Polished article draft ready for publication",
|
64 |
+
agent=content_writer,
|
65 |
+
output_file="content.md"
|
66 |
+
)
|
67 |
+
|
68 |
+
crew = Crew(
|
69 |
+
agents=[researcher, content_writer],
|
70 |
+
tasks=[research_task, writer_task],
|
71 |
+
process=Process.sequential,
|
72 |
+
verbose=True,
|
73 |
+
max_rpm=100,
|
74 |
+
share_crew=True,
|
75 |
+
output_log_file=True
|
76 |
+
)
|
77 |
+
|
78 |
+
crew.kickoff(inputs={'topic': topic})
|
79 |
+
with open("content.md", "r") as f:
|
80 |
+
content = f.read()
|
81 |
+
with open("logs.txt", 'r') as f:
|
82 |
+
logs = f.read()
|
83 |
+
# Clear the logs file after reading
|
84 |
+
with open("logs.txt", 'w') as f:
|
85 |
+
f.truncate(0)
|
86 |
+
return content, logs
|
87 |
+
except Exception as e:
|
88 |
+
return f"Error: {str(e)}", str(e)
|
GameBuilderAgent.py
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from crewai import Agent, Task, Crew, Process
|
3 |
+
# from crewai_tools import CodeInterpreterTool
|
4 |
+
|
5 |
+
# Model options
|
6 |
+
llm_models = [
|
7 |
+
"gemini/gemini-1.5-flash",
|
8 |
+
"gemini/gemini-1.5-pro",
|
9 |
+
"gemini/gemini-pro"
|
10 |
+
]
|
11 |
+
|
12 |
+
selected_model = llm_models[0]
|
13 |
+
|
14 |
+
|
15 |
+
def set_model(selected_model_name):
|
16 |
+
global selected_model
|
17 |
+
selected_model = selected_model_name
|
18 |
+
|
19 |
+
|
20 |
+
def configure_api_keys(gemini_api_key):
|
21 |
+
if not gemini_api_key:
|
22 |
+
raise ValueError("Gemini API key is required")
|
23 |
+
os.environ['GEMINI_API_KEY'] = gemini_api_key
|
24 |
+
|
25 |
+
|
26 |
+
def run_crew_game(gemini_api_key, game):
|
27 |
+
try:
|
28 |
+
# Configure API keys (no search tool used)
|
29 |
+
configure_api_keys(gemini_api_key)
|
30 |
+
|
31 |
+
# Agents
|
32 |
+
senior_game_developer_agent = Agent(
|
33 |
+
role='Senior Game Developer',
|
34 |
+
goal='Design and develop engaging games',
|
35 |
+
verbose=True,
|
36 |
+
backstory=(
|
37 |
+
"You are a Senior Game Developer at a leading game development studio. "
|
38 |
+
"Your expertise lies in game design, programming in Python, and creating immersive gaming experiences using pygame. "
|
39 |
+
"You strive to produce high-quality, innovative games that captivate players."
|
40 |
+
),
|
41 |
+
allow_delegation=True,
|
42 |
+
llm=selected_model,
|
43 |
+
)
|
44 |
+
|
45 |
+
qa_engineer_agent = Agent(
|
46 |
+
role='Software Quality Control Engineer',
|
47 |
+
goal='Create Perfect code, by analyzing the code that is given for errors',
|
48 |
+
backstory=(
|
49 |
+
"You are a software engineer that specializes in checking code for errors. "
|
50 |
+
"You have an eye for detail and a knack for finding hidden bugs. "
|
51 |
+
"You check for missing imports, variable declarations, mismatched brackets, syntax errors, "
|
52 |
+
"security vulnerabilities, and logic errors."
|
53 |
+
),
|
54 |
+
allow_delegation=False,
|
55 |
+
verbose=True,
|
56 |
+
# allow_code_execution=True,
|
57 |
+
llm=selected_model,
|
58 |
+
# tools=[CodeInterpreterTool()],
|
59 |
+
)
|
60 |
+
|
61 |
+
chief_qa_engineer_agent = Agent(
|
62 |
+
role='Chief Software Quality Control Engineer',
|
63 |
+
goal='Ensure that the code does the job that it is supposed to do',
|
64 |
+
backstory=(
|
65 |
+
"You feel that programmers always do only half the job, so you are super dedicated to making high quality code."
|
66 |
+
),
|
67 |
+
allow_delegation=True,
|
68 |
+
# allow_code_execution=True,
|
69 |
+
verbose=True,
|
70 |
+
llm=selected_model,
|
71 |
+
# tools=[CodeInterpreterTool()],
|
72 |
+
)
|
73 |
+
|
74 |
+
# Tasks
|
75 |
+
code_task = Task(
|
76 |
+
description=f'''You will create a game using Python, these are the instructions:
|
77 |
+
|
78 |
+
Instructions
|
79 |
+
------------
|
80 |
+
{game}
|
81 |
+
''',
|
82 |
+
expected_output='Your Final answer must be the full Python code, only the Python code and nothing else.',
|
83 |
+
agent=senior_game_developer_agent,
|
84 |
+
)
|
85 |
+
|
86 |
+
review_task = Task(
|
87 |
+
description=f'''You will create a game using Python, these are the instructions:
|
88 |
+
|
89 |
+
Instructions
|
90 |
+
------------
|
91 |
+
{game}
|
92 |
+
|
93 |
+
Using the code you got, check for errors. Check for logic errors,
|
94 |
+
syntax errors, missing imports, variable declarations, mismatched brackets,
|
95 |
+
and security vulnerabilities.
|
96 |
+
''',
|
97 |
+
expected_output='Your Final answer must be the full Python code, only the Python code and nothing else.',
|
98 |
+
agent=qa_engineer_agent,
|
99 |
+
)
|
100 |
+
|
101 |
+
evaluate_task = Task(
|
102 |
+
description=f'''You are helping create a game using Python, these are the instructions:
|
103 |
+
|
104 |
+
Instructions
|
105 |
+
------------
|
106 |
+
{game}
|
107 |
+
|
108 |
+
You will look over the code to ensure that it is complete and
|
109 |
+
does the job that it is supposed to do.
|
110 |
+
''',
|
111 |
+
expected_output='Your Final answer must be the full Python code, only the Python code and nothing else.',
|
112 |
+
agent=chief_qa_engineer_agent,
|
113 |
+
output_file='game.py'
|
114 |
+
)
|
115 |
+
|
116 |
+
crew = Crew(
|
117 |
+
agents=[senior_game_developer_agent , qa_engineer_agent, chief_qa_engineer_agent],
|
118 |
+
tasks=[code_task, review_task, evaluate_task],
|
119 |
+
process=Process.sequential,
|
120 |
+
verbose=True,
|
121 |
+
max_rpm=100,
|
122 |
+
share_crew=True,
|
123 |
+
output_log_file=True
|
124 |
+
)
|
125 |
+
|
126 |
+
crew.kickoff(inputs={'game': game})
|
127 |
+
with open("game.py", "r", encoding='utf-8') as f:
|
128 |
+
content = f.read()
|
129 |
+
with open("logs.txt", 'r', encoding='utf-8') as f:
|
130 |
+
logs = f.read()
|
131 |
+
with open("logs.txt", 'w', encoding='utf-8') as f:
|
132 |
+
f.truncate(0)
|
133 |
+
return content, logs
|
134 |
+
|
135 |
+
except Exception as e:
|
136 |
+
return f"Error: {str(e)}", str(e)
|
Images/ai-logo.png
ADDED
![]() |
Images/download.jpeg
ADDED
![]() |
Images/download.png
ADDED
![]() |
Images/github-logo.png
ADDED
![]() |
Images/hq720.jpg
ADDED
![]() |
Images/linkedin-logo.png
ADDED
![]() |
Images/testocr.png
ADDED
![]() |
app.py
CHANGED
@@ -1,107 +1,28 @@
|
|
1 |
-
from crewai import Agent, Task, Crew, Process
|
2 |
-
from crewai_tools import SerperDevTool
|
3 |
import gradio as gr
|
4 |
-
import os
|
5 |
import markdown as md
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
"gemini/gemini-1.5-pro",
|
12 |
-
"gemini/gemini-pro"
|
13 |
-
]
|
14 |
-
|
15 |
-
selected_model = llm_models[0]
|
16 |
-
|
17 |
-
|
18 |
-
def set_model(selected_model_name):
|
19 |
-
global selected_model
|
20 |
-
selected_model = selected_model_name
|
21 |
-
# return f"Model set to: {selected_model}"
|
22 |
-
|
23 |
|
24 |
def toggle_serper_input(choice):
|
25 |
return gr.Textbox(visible=(choice == "Yes"))
|
26 |
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
def
|
29 |
-
|
30 |
-
|
31 |
-
if not gemini_api_key:
|
32 |
-
raise ValueError("Gemini API key is required")
|
33 |
-
|
34 |
-
os.environ['GEMINI_API_KEY'] = gemini_api_key
|
35 |
-
|
36 |
-
# Configure search tool
|
37 |
-
search_tool = None
|
38 |
-
if search_choice == "Yes":
|
39 |
-
if not serper_api_key:
|
40 |
-
raise ValueError("Serper API key is required for online search")
|
41 |
-
os.environ['SERPER_API_KEY'] = serper_api_key
|
42 |
-
search_tool = SerperDevTool()
|
43 |
-
|
44 |
-
# Create agents
|
45 |
-
researcher = Agent(
|
46 |
-
role="Online Research Specialist",
|
47 |
-
goal="Aggregate comprehensive information on {topic}",
|
48 |
-
verbose=True,
|
49 |
-
backstory="Expert research analyst with data sourcing expertise",
|
50 |
-
tools=[search_tool] if search_tool else [],
|
51 |
-
llm=selected_model,
|
52 |
-
allow_delegation=True
|
53 |
-
)
|
54 |
-
|
55 |
-
content_writer = Agent(
|
56 |
-
role="Expert Content Writer",
|
57 |
-
goal="Create SEO-optimized content on {topic}",
|
58 |
-
verbose=True,
|
59 |
-
backstory="Professional writer with digital journalism background",
|
60 |
-
tools=[],
|
61 |
-
llm=selected_model,
|
62 |
-
allow_delegation=False
|
63 |
-
)
|
64 |
-
|
65 |
-
# Create tasks
|
66 |
-
research_task = Task(
|
67 |
-
description=f"Conduct SEO research on '{topic}'",
|
68 |
-
expected_output="Detailed research report with SEO recommendations",
|
69 |
-
tools=[search_tool] if search_tool else [],
|
70 |
-
agent=researcher
|
71 |
-
)
|
72 |
-
|
73 |
-
writer_task = Task(
|
74 |
-
description=f"Write SEO-optimized article on '{topic}'",
|
75 |
-
expected_output="Polished article draft ready for publication",
|
76 |
-
agent=content_writer,
|
77 |
-
output_file="content.md"
|
78 |
-
)
|
79 |
-
|
80 |
-
# Create and run crew
|
81 |
-
crew = Crew(
|
82 |
-
agents=[researcher, content_writer],
|
83 |
-
tasks=[research_task, writer_task],
|
84 |
-
process=Process.sequential,
|
85 |
-
verbose=True,
|
86 |
-
max_rpm=100,
|
87 |
-
share_crew=True,
|
88 |
-
output_log_file=True
|
89 |
-
)
|
90 |
-
|
91 |
-
result = crew.kickoff(inputs={'topic': topic})
|
92 |
-
|
93 |
-
# Return results
|
94 |
-
with open("content.md", "r") as f:
|
95 |
-
content = f.read()
|
96 |
-
with open("logs.txt", 'r') as f:
|
97 |
-
logs = f.read()
|
98 |
-
os.remove("logs.txt")
|
99 |
-
print(f"{datetime.now()}::{topic}-->{content}")
|
100 |
-
return content, logs
|
101 |
-
|
102 |
-
except Exception as e:
|
103 |
-
return f"Error: {str(e)}", str(e)
|
104 |
|
|
|
|
|
|
|
|
|
105 |
|
106 |
# UI Setup
|
107 |
with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Roboto Mono")]),
|
@@ -111,11 +32,13 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Roboto Mono")]),
|
|
111 |
with gr.Tabs():
|
112 |
with gr.TabItem("Intro"):
|
113 |
gr.Markdown(md.description)
|
114 |
-
|
115 |
-
with gr.TabItem("SEO Content
|
116 |
-
with gr.Accordion("
|
|
|
|
|
117 |
gr.Markdown(md.gemini_api_key)
|
118 |
-
with gr.Accordion("How to get SERPER API KEY
|
119 |
gr.Markdown(md.serper_api_key)
|
120 |
with gr.Row():
|
121 |
with gr.Column(scale=1):
|
@@ -138,35 +61,140 @@ with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Roboto Mono")]),
|
|
138 |
label="4. Enter Serper API Key",
|
139 |
type="password",
|
140 |
visible=False,
|
141 |
-
placeholder="Paste Serper API key if enabled..."
|
142 |
)
|
143 |
topic_input = gr.Textbox(
|
144 |
label="5. Enter Content Topic",
|
145 |
placeholder="Enter your article topic here..."
|
146 |
)
|
147 |
run_btn = gr.Button("Generate Content", variant="primary")
|
148 |
-
|
149 |
with gr.Column(scale=3):
|
150 |
output = gr.Markdown(
|
151 |
label="Generated Content",
|
152 |
value="Your content will appear here..."
|
153 |
)
|
154 |
-
with gr.Accordion("Process Logs", open=
|
155 |
logs = gr.Markdown()
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
if __name__ == "__main__":
|
172 |
-
demo.launch()
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import markdown as md
|
3 |
+
import yaml
|
4 |
+
from ContentGeneratorAgent import run_crew_cga, set_model, llm_models
|
5 |
+
from GameBuilderAgent import run_crew_game
|
6 |
+
from MarketingPostGeneratorAgent import run_crew_mpga
|
7 |
+
import base64
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def toggle_serper_input(choice):
|
10 |
return gr.Textbox(visible=(choice == "Yes"))
|
11 |
|
12 |
+
def update_game_instructions(example_key):
|
13 |
+
# Load the game design examples from the YAML file
|
14 |
+
with open('gamedesign.yaml', 'r', encoding='utf-8') as f:
|
15 |
+
examples = yaml.safe_load(f)
|
16 |
+
return examples.get(example_key, "")
|
17 |
|
18 |
+
def encode_image(image_path):
|
19 |
+
with open(image_path, "rb") as image_file:
|
20 |
+
return base64.b64encode(image_file.read()).decode('utf-8')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
# Encode the images
|
23 |
+
github_logo_encoded = encode_image("Images/github-logo.png")
|
24 |
+
linkedin_logo_encoded = encode_image("Images/linkedin-logo.png")
|
25 |
+
website_logo_encoded = encode_image("Images/ai-logo.png")
|
26 |
|
27 |
# UI Setup
|
28 |
with gr.Blocks(theme=gr.themes.Soft(font=[gr.themes.GoogleFont("Roboto Mono")]),
|
|
|
32 |
with gr.Tabs():
|
33 |
with gr.TabItem("Intro"):
|
34 |
gr.Markdown(md.description)
|
35 |
+
# Tab for SEO Content Generator Agent
|
36 |
+
with gr.TabItem("SEO Content Agent"):
|
37 |
+
with gr.Accordion("๐ Description:", open=False):
|
38 |
+
gr.Markdown(md.seo_content)
|
39 |
+
with gr.Accordion("How to get GEMINI API KEY", open=False):
|
40 |
gr.Markdown(md.gemini_api_key)
|
41 |
+
with gr.Accordion("How to get SERPER API KEY", open=False):
|
42 |
gr.Markdown(md.serper_api_key)
|
43 |
with gr.Row():
|
44 |
with gr.Column(scale=1):
|
|
|
61 |
label="4. Enter Serper API Key",
|
62 |
type="password",
|
63 |
visible=False,
|
64 |
+
placeholder="Paste your Serper API key if enabled..."
|
65 |
)
|
66 |
topic_input = gr.Textbox(
|
67 |
label="5. Enter Content Topic",
|
68 |
placeholder="Enter your article topic here..."
|
69 |
)
|
70 |
run_btn = gr.Button("Generate Content", variant="primary")
|
|
|
71 |
with gr.Column(scale=3):
|
72 |
output = gr.Markdown(
|
73 |
label="Generated Content",
|
74 |
value="Your content will appear here..."
|
75 |
)
|
76 |
+
with gr.Accordion("Process Logs", open=True):
|
77 |
logs = gr.Markdown()
|
78 |
|
79 |
+
# Event handlers for SEO Content Generator
|
80 |
+
model_dropdown.change(set_model, model_dropdown)
|
81 |
+
search_toggle.change(
|
82 |
+
toggle_serper_input,
|
83 |
+
inputs=search_toggle,
|
84 |
+
outputs=serper_key
|
85 |
+
)
|
86 |
+
run_btn.click(
|
87 |
+
run_crew_cga,
|
88 |
+
inputs=[gemini_key, search_toggle, serper_key, topic_input],
|
89 |
+
outputs=[output, logs],
|
90 |
+
show_progress="full"
|
91 |
+
)
|
92 |
+
|
93 |
+
# Tab for Game Dev Agent
|
94 |
+
with gr.TabItem("Game Dev Agent"):
|
95 |
+
with gr.Accordion('๐ Description:', open=True):
|
96 |
+
gr.Markdown(md.game_dev)
|
97 |
+
with gr.Accordion("How to get GEMINI API KEY", open=False):
|
98 |
+
gr.Markdown(md.gemini_api_key)
|
99 |
+
with gr.Row():
|
100 |
+
with gr.Column(scale=1):
|
101 |
+
game_model_dropdown = gr.Dropdown(
|
102 |
+
llm_models,
|
103 |
+
label="1. Select AI Model",
|
104 |
+
value=llm_models[0]
|
105 |
+
)
|
106 |
+
game_gemini_key = gr.Textbox(
|
107 |
+
label="2. Enter Gemini API Key",
|
108 |
+
type="password",
|
109 |
+
placeholder="Paste your Gemini API key here..."
|
110 |
+
)
|
111 |
+
game_example_dropdown = gr.Dropdown(
|
112 |
+
choices=["pacman", "pacman2", "snake", "space_invaders", "Tetris", "Frogger", "Chess", "Go", "Reversi"],
|
113 |
+
label="3. Select Example",
|
114 |
+
value="example1_pacman"
|
115 |
+
)
|
116 |
+
game_load_example_btn = gr.Button("Load Example", variant="secondary")
|
117 |
+
|
118 |
+
game_instructions = gr.Textbox(
|
119 |
+
label="4. Enter Game Design Instructions",
|
120 |
+
placeholder="Enter your game design instructions here...",
|
121 |
+
lines=5
|
122 |
+
)
|
123 |
+
game_run_btn = gr.Button("Generate Game Code", variant="primary")
|
124 |
+
with gr.Column(scale=3):
|
125 |
+
game_output = gr.Markdown(
|
126 |
+
label="Generated Game Code",
|
127 |
+
value="Your game code will appear here..."
|
128 |
+
)
|
129 |
+
with gr.Accordion("Process Logs", open=False):
|
130 |
+
game_logs = gr.Markdown()
|
131 |
+
|
132 |
+
# Event handlers for Game Dev Agent
|
133 |
+
game_model_dropdown.change(set_model, game_model_dropdown)
|
134 |
+
game_load_example_btn.click(
|
135 |
+
update_game_instructions,
|
136 |
+
inputs=[game_example_dropdown],
|
137 |
+
outputs=[game_instructions]
|
138 |
+
)
|
139 |
+
game_run_btn.click(
|
140 |
+
run_crew_game,
|
141 |
+
inputs=[game_gemini_key, game_instructions],
|
142 |
+
outputs=[game_output, game_logs],
|
143 |
+
show_progress="full"
|
144 |
+
)
|
145 |
+
|
146 |
+
# Tab for Marketing Posts Generator Agent
|
147 |
+
with gr.TabItem("Marketing Posts Generator Agent"):
|
148 |
+
with gr.Accordion("How to get GEMINI API KEY", open=False):
|
149 |
+
gr.Markdown(md.gemini_api_key)
|
150 |
+
with gr.Accordion("How to get SERPER API KEY", open=False):
|
151 |
+
gr.Markdown(md.serper_api_key)
|
152 |
+
with gr.Row():
|
153 |
+
with gr.Column(scale=1):
|
154 |
+
mpga_model_dropdown = gr.Dropdown(
|
155 |
+
llm_models,
|
156 |
+
label="1. Select AI Model",
|
157 |
+
value=llm_models[0]
|
158 |
+
)
|
159 |
+
mpga_gemini_key = gr.Textbox(
|
160 |
+
label="2. Enter Gemini API Key",
|
161 |
+
type="password",
|
162 |
+
placeholder="Paste your Gemini API key here..."
|
163 |
+
)
|
164 |
+
mpga_serper_key = gr.Textbox(
|
165 |
+
label="3. Enter Serper API Key",
|
166 |
+
type="password",
|
167 |
+
placeholder="Paste your Serper API key here..."
|
168 |
+
)
|
169 |
+
customer_domain = gr.Textbox(
|
170 |
+
label="4. Enter Customer Domain",
|
171 |
+
placeholder="Enter the customer domain here..."
|
172 |
+
)
|
173 |
+
project_description = gr.Textbox(
|
174 |
+
label="5. Enter Project Description",
|
175 |
+
placeholder="Enter the project description here..."
|
176 |
+
)
|
177 |
+
mpga_run_btn = gr.Button("Generate Marketing Posts", variant="primary")
|
178 |
+
with gr.Column(scale=3):
|
179 |
+
mpga_output = gr.Markdown(
|
180 |
+
label="Generated Marketing Posts",
|
181 |
+
value="Your marketing posts will appear here..."
|
182 |
+
)
|
183 |
+
with gr.Accordion("Process Logs", open=False):
|
184 |
+
mpga_logs = gr.Markdown()
|
185 |
+
|
186 |
+
# Event handlers for Marketing Posts Generator Agent
|
187 |
+
mpga_model_dropdown.change(set_model, mpga_model_dropdown)
|
188 |
+
# mpga_run_btn.click(
|
189 |
+
# run_crew_mpga,
|
190 |
+
# inputs=[mpga_gemini_key, mpga_serper_key, {
|
191 |
+
# "customer_domain": customer_domain,
|
192 |
+
# "project_description": project_description
|
193 |
+
# }],
|
194 |
+
# outputs=[mpga_output, mpga_logs],
|
195 |
+
# show_progress="full"
|
196 |
+
# )
|
197 |
+
gr.HTML(md.footer.format(github_logo_encoded, linkedin_logo_encoded, website_logo_encoded))
|
198 |
|
199 |
if __name__ == "__main__":
|
200 |
+
demo.launch()
|
markdown.py
CHANGED
@@ -1,4 +1,106 @@
|
|
1 |
-
description='''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
gemini_api_key = """
|
4 |
** STEP by STEP Guide for getting Gemini API key **:
|
@@ -35,6 +137,7 @@ This is the fastest and easiest method.
|
|
35 |
* **Terms of Service:** By using the Gemini API, you agree to Google's Terms of Service. It's a good idea to review these terms.
|
36 |
"""
|
37 |
|
|
|
38 |
serper_api_key="""
|
39 |
**Step-by-Step Guide to Getting a SERPER API Key**
|
40 |
|
@@ -70,4 +173,108 @@ serper_api_key="""
|
|
70 |
* Terms of service : Go through terms of service.
|
71 |
|
72 |
By following these steps, you should be able to obtain and start using your SERPER API key. Remember to consult the official documentation for the most up-to-date and detailed information.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
"""
|
|
|
1 |
+
description='''# ๐ค **AI Agents Suite: A Multi-Agent System for Content and Game Generation**
|
2 |
+
|
3 |
+
## โจ **Project Overview**
|
4 |
+
The **AI Agents Suite** is a collection of intelligent agents designed to automate content generation, game development, and marketing content creation using advanced language models. This system utilizes **CrewAI**, **Gemini LLMs**, and **Serper API** to perform structured, high-quality content generation and game-building tasks.
|
5 |
+
|
6 |
+
## ๐ **Key Components**
|
7 |
+
### 1. **SEO Content Generator Agent**
|
8 |
+
- Generates **SEO-optimized articles** by researching topics and crafting high-quality content.
|
9 |
+
- Supports **online research** using **Serper API** for real-time data collection.
|
10 |
+
- Leverages **Gemini AI models** for efficient content writing.
|
11 |
+
|
12 |
+
### 2. **Game Development Agent**
|
13 |
+
- Automates the process of **designing and developing games** using Python.
|
14 |
+
- Ensures **code quality** by integrating multiple levels of **quality control** through AI agents.
|
15 |
+
- Supports **multiple game genres**, including classic arcade, board games, and more.
|
16 |
+
|
17 |
+
### 3. **Marketing Post Generator Agent (Future Integration)**
|
18 |
+
- Will create **engaging marketing content** tailored for different domains.
|
19 |
+
- Enables structured **campaign planning** for digital outreach.
|
20 |
+
|
21 |
+
---
|
22 |
+
|
23 |
+
## ๐ **How the Application Works**
|
24 |
+
The system is structured into **three main AI-driven agents** that interact through the **CrewAI** framework:
|
25 |
+
|
26 |
+
### ๐ **1. SEO Content Generator Agent**
|
27 |
+
- Accepts a **topic** input from the user.
|
28 |
+
- Performs **online research** if enabled.
|
29 |
+
- Generates a **structured, SEO-optimized article**.
|
30 |
+
|
31 |
+
#### **Workflow:**
|
32 |
+
1. **User Inputs** topic and selects an **AI model**.
|
33 |
+
2. AI **Research Agent** gathers insights from online sources (if enabled).
|
34 |
+
3. AI **Content Writer Agent** drafts a **polished article**.
|
35 |
+
4. Outputs a **ready-to-publish** SEO article.
|
36 |
+
|
37 |
+
---
|
38 |
+
|
39 |
+
### ๐ **2. Game Development Agent**
|
40 |
+
- Converts **game design instructions** into fully functional **Python game code**.
|
41 |
+
- Implements **multi-step quality control** using dedicated agents.
|
42 |
+
- Generates **error-free, optimized game logic**.
|
43 |
+
|
44 |
+
#### **Workflow:**
|
45 |
+
1. User provides **game design instructions**.
|
46 |
+
2. **Senior Game Developer Agent** writes game logic.
|
47 |
+
3. **QA Engineer Agent** inspects code for errors.
|
48 |
+
4. **Chief QA Engineer Agent** ensures **game functionality**.
|
49 |
+
5. Outputs **fully functional game code**.
|
50 |
+
|
51 |
+
---
|
52 |
+
|
53 |
+
### ๐ฉโ๐ป **Agents in Action**
|
54 |
+
#### **SEO Content Generator Agents**
|
55 |
+
- **Researcher Agent**: Collects data for SEO optimization.
|
56 |
+
- **Content Writer Agent**: Creates structured articles based on research.
|
57 |
+
|
58 |
+
#### **Game Development Agents**
|
59 |
+
- **Senior Game Developer**: Writes Python game code based on input instructions.
|
60 |
+
- **QA Engineer**: Identifies syntax errors, missing imports, and logic issues.
|
61 |
+
- **Chief QA Engineer**: Ensures the game works correctly and optimally.
|
62 |
+
|
63 |
+
---
|
64 |
+
|
65 |
+
## ๐
**Usage Instructions**
|
66 |
+
### ๐ **SEO Content Generator**
|
67 |
+
1. Select **AI Model** (e.g., Gemini Flash, Gemini Pro).
|
68 |
+
2. Enter **Gemini API Key**.
|
69 |
+
3. Choose **Online Search** (Yes/No).
|
70 |
+
4. Provide a **topic**.
|
71 |
+
5. Click **Generate Content**.
|
72 |
+
|
73 |
+
### ๐ฎ **Game Development Agent**
|
74 |
+
1. Select **AI Model**.
|
75 |
+
2. Enter **Game Instructions**.
|
76 |
+
3. Click **Generate Game Code**.
|
77 |
+
|
78 |
+
---
|
79 |
+
|
80 |
+
## ๐ **Supported AI Models**
|
81 |
+
### **Gemini Models**
|
82 |
+
- **Gemini-1.5-Flash** (Fastest Response)
|
83 |
+
- **Gemini-1.5-Pro** (Balanced Performance)
|
84 |
+
- **Gemini-Pro** (Most Accurate)
|
85 |
+
|
86 |
+
---
|
87 |
+
|
88 |
+
## ๐ **Project Benefits**
|
89 |
+
- **Automated Content Generation**: Saves time by generating high-quality SEO articles.
|
90 |
+
- **Efficient Game Development**: Automates coding and quality checks for Python games.
|
91 |
+
- **Scalability**: Supports multiple AI models and frameworks.
|
92 |
+
- **Future Expansion**: New AI-powered agents can be integrated for additional tasks.
|
93 |
+
|
94 |
+
---
|
95 |
+
|
96 |
+
## ๐ **Future Enhancements**
|
97 |
+
- **Marketing Post Generator** for social media campaigns.
|
98 |
+
- **Integration with Cloud-Based AI models** for enhanced scalability.
|
99 |
+
- **Support for additional Game Development tools** beyond Python.
|
100 |
+
|
101 |
+
### ๐ **Get Started Today!**
|
102 |
+
Explore the power of AI-driven automation and enhance your workflow with the **AI Agents Suite**!
|
103 |
+
'''
|
104 |
|
105 |
gemini_api_key = """
|
106 |
** STEP by STEP Guide for getting Gemini API key **:
|
|
|
137 |
* **Terms of Service:** By using the Gemini API, you agree to Google's Terms of Service. It's a good idea to review these terms.
|
138 |
"""
|
139 |
|
140 |
+
|
141 |
serper_api_key="""
|
142 |
**Step-by-Step Guide to Getting a SERPER API Key**
|
143 |
|
|
|
173 |
* Terms of service : Go through terms of service.
|
174 |
|
175 |
By following these steps, you should be able to obtain and start using your SERPER API key. Remember to consult the official documentation for the most up-to-date and detailed information.
|
176 |
+
"""
|
177 |
+
|
178 |
+
seo_content="""# CrewAI Content Generation Agent
|
179 |
+
|
180 |
+
## Overview
|
181 |
+
|
182 |
+
The provided Agent leverages the CrewAI framework to automate the process of generating SEO-optimized content. It integrates with the Gemini language model and optionally uses the SerperDevTool for online search capabilities.
|
183 |
+
|
184 |
+
## Roles
|
185 |
+
|
186 |
+
- **Online Research Specialist**: Conducts comprehensive research on the specified topic, focusing on SEO recommendations.
|
187 |
+
- **Expert Content Writer**: Creates SEO-optimized content based on the research findings, ensuring high-quality and polished output.
|
188 |
+
|
189 |
+
## Tasks
|
190 |
+
|
191 |
+
- **Research Task**: Aggregates detailed information and SEO recommendations on the given topic.
|
192 |
+
- **Writing Task**: Produces a polished, SEO-optimized article draft ready for publication.
|
193 |
+
|
194 |
+
## Usage
|
195 |
+
|
196 |
+
1. **Set Model**: Choose the desired Gemini model.
|
197 |
+
2. **Configure API Keys**: Provide necessary API keys for Gemini and SerperDevTool.
|
198 |
+
3. **Run Crew**: Execute the crew with the specified topic to generate content.
|
199 |
+
|
200 |
+
## Features
|
201 |
+
|
202 |
+
- **Model Selection**: Supports multiple Gemini language models for flexibility.
|
203 |
+
- **API Configuration**: Manages API keys for Gemini and SerperDevTool.
|
204 |
+
- **Agent Roles**: Defines specialized agents for research and content writing.
|
205 |
+
- **Task Management**: Orchestrates sequential tasks for research and writing.
|
206 |
+
- **Output**: Generates a polished article draft and detailed logs.
|
207 |
+
|
208 |
+
## Benefits
|
209 |
+
|
210 |
+
- **Efficiency**: Automates the content creation process, saving time and effort.
|
211 |
+
- **Quality**: Ensures high-quality, SEO-optimized content.
|
212 |
+
- **Flexibility**: Allows for easy integration of online search tools for enhanced research.
|
213 |
+
|
214 |
+
Experience streamlined content generation with CrewAI's advanced automation capabilities."""
|
215 |
+
|
216 |
+
game_dev = """# CrewAI Game Development Agent
|
217 |
+
|
218 |
+
## Overview
|
219 |
+
|
220 |
+
The provided code utilizes the CrewAI framework to automate the development and quality assurance process for creating games using Python. It leverages the Gemini language model to facilitate the tasks.
|
221 |
+
|
222 |
+
## Roles
|
223 |
+
|
224 |
+
- **Senior Game Developer**: Designs and develops engaging games based on provided instructions.
|
225 |
+
- **Software Quality Control Engineer**: Reviews the code for errors, including syntax, logic, and security vulnerabilities.
|
226 |
+
- **Chief Software Quality Control Engineer**: Ensures the code is complete and functions as intended.
|
227 |
+
|
228 |
+
## Tasks
|
229 |
+
|
230 |
+
- **Code Task**: Develops the game based on the given instructions.
|
231 |
+
- **Review Task**: Checks the code for errors and vulnerabilities.
|
232 |
+
- **Evaluate Task**: Ensures the code is complete and performs the intended functions.
|
233 |
+
|
234 |
+
## Usage
|
235 |
+
|
236 |
+
1. **Set Model**: Choose the desired Gemini model.
|
237 |
+
2. **Configure API Keys**: Provide the necessary API key for Gemini.
|
238 |
+
3. **Run Crew**: Execute the crew with the specified game instructions to generate the game code.
|
239 |
+
|
240 |
+
## Features
|
241 |
+
|
242 |
+
- **Model Selection**: Supports multiple Gemini language models for flexibility.
|
243 |
+
- **API Configuration**: Manages API keys for Gemini.
|
244 |
+
- **Agent Roles**: Defines specialized agents for game development and quality assurance.
|
245 |
+
- **Task Management**: Orchestrates sequential tasks for coding, reviewing, and evaluating.
|
246 |
+
- **Output**: Generates a complete Python game code and detailed logs.
|
247 |
+
|
248 |
+
## Benefits
|
249 |
+
|
250 |
+
- **Efficiency**: Automates the game development process, saving time and effort.
|
251 |
+
- **Quality**: Ensures high-quality, error-free code.
|
252 |
+
- **Flexibility**: Allows for easy integration of additional tools for enhanced functionality.
|
253 |
+
|
254 |
+
Experience streamlined game development with CrewAI's advanced automation capabilities.
|
255 |
+
"""
|
256 |
+
|
257 |
+
footer = """
|
258 |
+
<div style="background-color: #1d2938; color: white; padding: 10px; width: 100%; bottom: 0; left: 0; display: flex; justify-content: space-between; align-items: center; padding: .2rem 35px; box-sizing: border-box; font-size: 16px;">
|
259 |
+
<div style="text-align: left;">
|
260 |
+
<p style="margin: 0;">© 2025 </p>
|
261 |
+
</div>
|
262 |
+
<div style="text-align: center; flex-grow: 1;">
|
263 |
+
<p style="margin: 0;"> This website is made with โค by SARATH CHANDRA</p>
|
264 |
+
</div>
|
265 |
+
<div class="social-links" style="display: flex; gap: 20px; justify-content: flex-end; align-items: center;">
|
266 |
+
<a href="https://github.com/21bq1a4210" target="_blank" style="text-align: center;">
|
267 |
+
<img src="data:image/png;base64,{}" alt="GitHub" width="40" height="40" style="display: block; margin: 0 auto;">
|
268 |
+
<span style="font-size: 14px;">GitHub</span>
|
269 |
+
</a>
|
270 |
+
<a href="https://www.linkedin.com/in/sarath-chandra-bandreddi-07393b1aa/" target="_blank" style="text-align: center;">
|
271 |
+
<img src="data:image/png;base64,{}" alt="LinkedIn" width="40" height="40" style="display: block; margin: 0 auto;">
|
272 |
+
<span style="font-size: 14px;">LinkedIn</span>
|
273 |
+
</a>
|
274 |
+
<a href="https://21bq1a4210.github.io/MyPortfolio-/" target="_blank" style="text-align: center;">
|
275 |
+
<img src="data:image/png;base64,{}" alt="Portfolio" width="40" height="40" style="display: block; margin-right: 40px;">
|
276 |
+
<span style="font-size: 14px;">Portfolio</span>
|
277 |
+
</a>
|
278 |
+
</div>
|
279 |
+
</div>
|
280 |
"""
|