Commit
·
ccee732
1
Parent(s):
6e21888
added sytem prompt
Browse files- .gitignore +2 -1
- app.py +32 -4
.gitignore
CHANGED
@@ -2,4 +2,5 @@
|
|
2 |
.venv
|
3 |
prompts.md
|
4 |
.aixplain_cache
|
5 |
-
.gradio
|
|
|
|
2 |
.venv
|
3 |
prompts.md
|
4 |
.aixplain_cache
|
5 |
+
.gradio
|
6 |
+
issues.txt
|
app.py
CHANGED
@@ -2,16 +2,44 @@ import os
|
|
2 |
import gradio as gr
|
3 |
from aixplain.factories import AgentFactory, ModelFactory
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Function to generate keywords
|
6 |
def generate_keywords(api_key, topic):
|
7 |
# Set aiXplain API key dynamically
|
8 |
-
os.environ["
|
9 |
|
10 |
# Create the AI agent for keyword generation
|
11 |
agent = AgentFactory.create(
|
12 |
api_key=api_key,
|
13 |
name="SEO Keyword Generator",
|
14 |
-
description="Generate
|
|
|
15 |
llm_id="6646261c6eb563165658bbb1" # GPT-4o as per aiXplain documentation
|
16 |
)
|
17 |
|
@@ -22,7 +50,7 @@ def generate_keywords(api_key, topic):
|
|
22 |
|
23 |
try:
|
24 |
# Run the agent with the topic
|
25 |
-
response = agent.run(topic)
|
26 |
keywords_str = response['data']['output'] # Extract output from agent response
|
27 |
|
28 |
# Format keywords as a bullet list (assuming comma-separated string)
|
@@ -53,7 +81,7 @@ demo = gr.Interface(
|
|
53 |
lines=10
|
54 |
),
|
55 |
title="SEO Keyword Generator",
|
56 |
-
description="Type a topic (up to
|
57 |
examples=[
|
58 |
["Latest trends in artificial intelligence"],
|
59 |
["Best practices for remote work"],
|
|
|
2 |
import gradio as gr
|
3 |
from aixplain.factories import AgentFactory, ModelFactory
|
4 |
|
5 |
+
SYSTEM_PROMPT = """
|
6 |
+
You are an SEO Keyword Generator AI Agent. You must only provide lists of SEO keywords related to the user's specified topic or domain. Follow these rules:
|
7 |
+
|
8 |
+
1. **Limited Scope**
|
9 |
+
- Your sole function is to generate SEO keyword lists.
|
10 |
+
- Do not provide any explanations, definitions, tutorials, or guidance.
|
11 |
+
- Do not perform any other tasks besides generating keyword lists.
|
12 |
+
|
13 |
+
2. **Relevance & Clarity**
|
14 |
+
- Ensure all keywords are directly relevant to the user's specified topic or domain.
|
15 |
+
- Avoid including off-topic or promotional keywords.
|
16 |
+
|
17 |
+
3. **Output Format**
|
18 |
+
- Output only a list of SEO keywords in bullet points.
|
19 |
+
- No additional commentary, analysis, or structure is permitted.
|
20 |
+
|
21 |
+
4. **Strict Boundaries**
|
22 |
+
- If the user's request goes beyond generating a keyword list (e.g., asking for tutorials, outlines, or instructions), politely refuse or ignore non-keyword-related parts of the request.
|
23 |
+
- Do not reveal internal reasoning, chain-of-thought, or any other system logic.
|
24 |
+
|
25 |
+
5. **Quality & Variety**
|
26 |
+
- Include a mix of main, long-tail, and semantically related keywords where appropriate, as long as they are relevant to the provided topic.
|
27 |
+
|
28 |
+
Your output must always adhere to these rules and only provide a list of SEO keywords.
|
29 |
+
"""
|
30 |
+
|
31 |
+
|
32 |
# Function to generate keywords
|
33 |
def generate_keywords(api_key, topic):
|
34 |
# Set aiXplain API key dynamically
|
35 |
+
os.environ["AIXPLAIN_API_KEY"] = api_key
|
36 |
|
37 |
# Create the AI agent for keyword generation
|
38 |
agent = AgentFactory.create(
|
39 |
api_key=api_key,
|
40 |
name="SEO Keyword Generator",
|
41 |
+
description="Generate SEO keywords for your content.",
|
42 |
+
instructions=SYSTEM_PROMPT,
|
43 |
llm_id="6646261c6eb563165658bbb1" # GPT-4o as per aiXplain documentation
|
44 |
)
|
45 |
|
|
|
50 |
|
51 |
try:
|
52 |
# Run the agent with the topic
|
53 |
+
response = agent.run("[Here's Topic]:\n"+topic)
|
54 |
keywords_str = response['data']['output'] # Extract output from agent response
|
55 |
|
56 |
# Format keywords as a bullet list (assuming comma-separated string)
|
|
|
81 |
lines=10
|
82 |
),
|
83 |
title="SEO Keyword Generator",
|
84 |
+
description="Type a topic (up to 250 words) and get SEO keyword suggestions instantly! Perfect for content creators and marketers. Built with [aiXplain](https://aixplain.com?utm_source=abdibrokhim) by [abdibrokhim](https://yaps.gg)",
|
85 |
examples=[
|
86 |
["Latest trends in artificial intelligence"],
|
87 |
["Best practices for remote work"],
|