Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ tools:
reference: ./atlassian/jira
wordpress:
reference: ./wordpress
wordpress-seo:
reference: ./wordpress-seo
excel:
reference: ./excel
browser:
Expand Down
Empty file added wordpress-seo/__init__.py
Empty file.
59 changes: 59 additions & 0 deletions wordpress-seo/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from tools.helper import setup_logger
import sys
from tools.keywords_suggestions import keywords_suggestions_tool
from tools.keyword_density import keyword_density_metrics_tool
from tools.readability import readability_metrics_tool
from tools.long_tail_keywords import google_search_suggestions_tool
import os
import json

logger = setup_logger(__name__)


def main():
if len(sys.argv) < 2:
print("Usage: python main.py <command>")
sys.exit(1)

command = sys.argv[1]
try:
match command:
case "KeywordDensityMetrics":
title = os.getenv("TITLE")
content = os.getenv("CONTENT")
primary_keyword = os.getenv("PRIMARY_KEYWORD")
if not primary_keyword:
raise ValueError("PRIMARY_KEYWORD is required")
secondary_keywords = os.getenv("SECONDARY_KEYWORDS", [])
if secondary_keywords:
try:
secondary_keywords = json.loads(secondary_keywords)
except json.JSONDecodeError:
raise ValueError(
"SECONDARY_KEYWORDS must be a valid JSON array of strings"
)
res = keyword_density_metrics_tool(
title, content, primary_keyword, secondary_keywords
)
case "KeywordsSuggestions":
content = os.getenv("CONTENT")
res = keywords_suggestions_tool(content)
case "ReadabilityMetrics":
content = os.getenv("CONTENT")
res = readability_metrics_tool(content)
case "LongTailKeywords":
seed_keyword = os.getenv("SEED_KEYWORD")
num_suggestions = int(os.getenv("NUM_SUGGESTIONS", 5))
res = google_search_suggestions_tool(seed_keyword, num_suggestions)
case _:
print(f"Unknown command: {command}")
sys.exit(1)

print(json.dumps(res, indent=4))
except Exception as e:
print(f"Running command: {' '.join(sys.argv)} failed. Error: {e}")
sys.exit(1)


if __name__ == "__main__":
main()
8 changes: 8 additions & 0 deletions wordpress-seo/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
textstat==0.7.5
# scikit-learn
pandas==2.2.3
yake==0.4.8
openai==1.72.0
markdownify==1.1.0
html2text==2024.2.26
requests==2.32.3
75 changes: 75 additions & 0 deletions wordpress-seo/tool.gpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
Name: Wordpress SEO
Description: Search engine optimization tools for wordpress sites. This helps you optimize the content of a post.
Metadata: bundle: true
Share Tools: Keywords Suggestions, Keyword Density Metrics, Long Tail Keywords, Readability Metrics
---
Name: Keywords Suggestions
Description: Suggest keywords to focus on for SEO given a content.
Credential: sys.model.provider.credential
Share Context: Wordpress SEO Context
Param: content: (required) the content to suggest keywords for.

#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py KeywordsSuggestions

---
Name: Keyword Density Metrics
Description: Get the keyword density metrics for a given content. Primary keyword is required. Secondary keywords are optional but highly recommended.
Credential: sys.model.provider.credential
Share Context: Wordpress SEO Context
Param: title: (required) the title of the content to analyze.
Param: content: (required) the content to analyze.
Param: primary_keyword: (required) the primary keyword to analyze.
Param: secondary_keywords: (optional) the secondary keywords to analyze. Must be an python array of keywords, e.g. ["keyword1", "keyword2", "keyword3"], NOT a string.

#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py KeywordDensityMetrics

---
Name: Long Tail Keywords
Description: Suggest long tail keywords for a given keyword. This is based on Google Search's long tail keyword suggestions.
Credential: sys.model.provider.credential
Share Context: Wordpress SEO Context
Param: seed_keyword: (required) the keyword to suggest long tail keywords for.
Param: num_suggestions: (optional) the number of suggestions to return. Default is 5.

#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py LongTailKeywords


---
Name: Readability Metrics
Description: Get the readability metrics for a given content.
Credential: sys.model.provider.credential
Share Context: Wordpress SEO Context
Param: content: (required) the content to analyze.

#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py ReadabilityMetrics

---
Name: Wordpress SEO Context
Type: context

#!sys.echo

## Instructions for using WordPress SEO tools

Help the user optimize a post for SEO by following these steps:

1. Use the `Keywords Suggestions` tool to recommend relevant keywords based on the content.

2. Inform the user that they can check keyword volume and difficulty using third-party tools/plugins. Offer to suggest long-tail keywords if they provide a base keyword.

3. Ask the user to confirm their primary and secondary keywords for optimization.

4. Use the `Keyword Density Metrics` tool to analyze the content using the confirmed keywords.
Provide actionable suggestions to improve keyword usage based on the analysis.

5. (Optional) Use the `Readability Metrics` tool to assess and suggest improvements for readability.
Explain the result metrics to the user, also remind the user that readability formulas aren't always a good match for well-written professional/technical content.

Finally, generate an updated version of the content reflecting the SEO and readability enhancements.

## End of instructions for using WordPress SEO tools

---
!metadata:*:icon
/admin/assets/wordpress-logo.png
Loading
Loading