Skip to content

Commit

Permalink
2.1.7, no langchain experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Nov 10, 2023
1 parent 41e5f17 commit a610ff7
Show file tree
Hide file tree
Showing 13 changed files with 1,164 additions and 323 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Thank you for contributing to Swarms!
Thank you for contributing to Swarms!

Replace this comment with:
- Description: a description of the change,
Expand All @@ -7,19 +7,23 @@ Replace this comment with:
- Tag maintainer: for a quicker response, tag the relevant maintainer (see below),
- Twitter handle: we announce bigger features on Twitter. If your PR gets announced and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before submitting. Run `make format`, `make lint` and `make test` to check this locally.

See contribution guidelines for more information on how to write/run tests, lint, etc:
https://github.com/kyegomez/swarms/blob/master/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on network access,
2. an example notebook showing its use.


Maintainer responsibilities:
- General / Misc / if you don't know who to tag: kye@apac.ai
- DataLoaders / VectorStores / Retrievers: kye@apac.ai
- Models / Prompts: kye@apac.ai
- Memory: kye@apac.ai
- Agents / Tools / Toolkits: kye@apac.ai
- Tracing / Callbacks: kye@apac.ai
- Async: kye@apac.ai
- swarms.models: kye@apac.ai
- swarms.memory: kye@apac.ai
- swarms.structures: kye@apac.ai

If no one reviews your PR within a few days, feel free to kye@apac.ai
If no one reviews your PR within a few days, feel free to email Kye at kye@apac.ai

See contribution guidelines for more information on how to write/run tests, lint, etc: https://github.com/kyegomez/swarms
292 changes: 10 additions & 282 deletions demos/positive_med.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,257 +14,23 @@
Distribution Agent:
- Social Media posts for the article.
# TODO
- Add shorter and better topic generator prompt
- Optimize writer prompt to create longer and more enjoyeable blogs
- Use Local Models like Storywriter
"""

from swarms.models import OpenAIChat
from termcolor import colored
from swarms.models import OpenAIChat
from swarms.prompts.autoblogen import (
DRAFT_AGENT_SYSTEM_PROMPT,
REVIEW_PROMPT,
SOCIAL_MEDIA_SYSTEM_PROMPT_AGENT,
TOPIC_GENERATOR,
)
import os

TOPIC_GENERATOR = f"""
First search for a list of topics on the web based their relevance to Positive Med's long term vision then rank than based on the goals this month, then output a single headline title for a blog for the next autonomous agent to write the blog, utilize the SOP below to help you strategically select topics. Output a single topic that will be the foundation for a blog.
VISION: Emphasis on exotic healthcare for improved health using Taoism, Ayurveda, and other ancient practices.
GOALS THIS MONTH: Clicks and engagement
Rank the topics on a scale from 0.0 to 1.0 on how likely it is to achieve the goal and then return the single most likely topic to satisfy the goals this month.
########### Standard Operating Procedure for Topic Selection for PositiveMed.com ######################
Objective:
The goal of this SOP is to provide clear guidelines and best practices for selecting high-quality, engaging, and SEO-friendly topics to create content for PositiveMed.com. The content should align with PositiveMed's brand mission of providing valuable health, wellness, and medical information to readers.
Overview:
Topic selection is a crucial first step in creating content for PositiveMed. Topics should inform, interest and engage readers, while also attracting search engine traffic through optimized keywords. This SOP covers core strategies and processes for researching, evaluating and selecting optimal topics.
Roles & Responsibilities:
The content team, consisting of writers, editors and content strategists, own the topic selection process.
The content team is responsible for:
- Monitoring health, medical, wellness trends and current events
- Conducting keyword research
- Assessing site analytics and reader feedback
- Crowdsourcing topic ideas from internal team and external contributors
- Maintaining editorial calendar with upcoming topics
- Pitching and selecting topics for content approval
The editorial team is responsible for:
- Providing final approval on topics based on brand suitability, reader interest, and potential traffic/engagement
- Ensuring selected topics are differentiated and not duplicative of existing content
- Reviewing and updating keyword opportunities tied to topics
Topic Sourcing
A strong content calendar begins with investing time into researching and generating promising topics. Here are key tactics and guidelines for sourcing topics:
Monitor Trends:
- Set Google Alerts for relevant keywords like "health news," "fitness trends," "nutrition research" etc. to receive daily updates.
- Subscribe to email newsletters, RSS feeds from authoritative sites like CDC, NIH, Mayo Clinic etc.
- Follow social media accounts of health organizations and influencers to stay on top of latest discussions.
- Check online communities like Reddit, Quora, Facebook Groups for emerging topics.
- Look for real-world events, awareness months, holidays that tie into health observances.
Perform Keyword Research:
- Use keyword research tools such as Google Keyword Planner, SEMrush, Moz Keyword Explorer etc.
- Target keywords with moderate-high search volume and low competition for the best opportunity.
- Look for conversational long-tail keywords that are more conversational and closely tied to topic themes.
- Ensure keywords have not been over-optimized by competitors to avoid saturation.
- Aim for topics that offerClusters of interconnected keywords around related sub-topics. This allows targeting several keywords with one piece of content.
Analyze Site Analytics:
- Review Google Analytics data to identify:
- Most-read articles - Consider follow-up content or additional installments.
- Highest-traffic landing pages - Expand on topics driving site visitors.
- Top-performing categories - Prioritize related subjects that attract readers.
- Look for content gaps - Assess which categories have not been recently updated and need fresh content.
Crowdsource Topic Ideas:
- Ask readers to suggest topics through surveys, emails, social media, comments etc.
- Review discussions in online communities to find topics readers are interested in.
- Collaborate with guest contributors who may pitch relevant ideas and angles.
- Solicit insights from internal team members who interact closely with readers.
Map Editorial Calendar:
- Maintain a content calendar that maps topics over weeks and months.
- Ensure a healthy mix of evergreen and trending topics across categories.
- Balance informational articles with more entertaining listicles or quizzes.
- Schedule both individual articles and content series around specific themes.
- Revisit calendar routinely to incorporate new topics as they emerge.
Evaluate Ideas
With a robust list of prospective topics, the next step is determining which ideas are worth pursuing. Use these criteria when assessing the merit of topics:
Reader Interest:
- Would the topic pique the curiosity of PositiveMed's target audience?
- Does it address questions readers may be asking about health, medicine, nutrition?
- Will it appeal to readers' needs for wellness tips, self-improvement advice?
- Does it present an interesting angle on a known subject versus just reporting basic facts?
Differentiation:
- Has this specific topic been recently covered on PositiveMed or similar sites?
- If covered before, does the pitch offer a novel spin - new research, fresh data, contrarian view?
- Will the content provide value-add beyond what readers can easily find through a Google search?
Brand Suitability:
- Does the topic match the tone and mission of the PositiveMed brand?
- Will the content uphold PositiveMed's standards for accuracy, credibility and ethics?
- Could the topic be construed as promoting unproven advice or "pseudoscience"?
Positioning:
- What unique perspective can PositiveMed bring that differs from mainstream health sites?
- Does the topic lend itself to an uplifting, empowering message aligned with the brand?
- Can the material be framed in a way that resonates with PositiveMed's niche audience?
Actionability:
- Will readers come away with new knowledge they can apply in their daily lives?
- Can the content offer clear steps, takeaways for improving health and wellbeing?
- Does the topic present opportunities to include tips, product recommendations etc.?
Timeliness:
- Is this tied to a recent news event or emerging trend that warrants timely coverage?
- For evergreen topics, are there new studies, pop culture references etc. that can make it timely?
- Does the angle offer a way to make an old topic feel fresh and relevant?
Competition:
- How saturated is the topic market? Who has top-ranking content on this topic?
- Does PositiveMed have a strong opportunity to own the conversation with a unique take?
- What value can be added versus competitor content on this subject?
Commercial Viability:
- Does the topic allow integrating affiliate links, product recommendations, lead generation offers etc.?
- Can it support the development of related products or paid offerings in the future?
- Will it attract engagement and social shares to increase traffic?
Keyword Integration
With promising topics identified, the next step is integrating keywords into content plans and outlines.
Conduct Keyword Research:
- Identify primary target keyword for topic that has:
- Moderate-to-high search volume
- Low-to-medium competition
- Relevance to topic and PositiveMed's niche
Find Supporting Keywords:
- Build a cluster of 3-5 secondary keywords around topic including:
- Related searches and questions
- Semantically connected words/phrases
- Keyword variations (long tail, alternate wording etc.)
- Stay within minimum monthly search volumes
Map Out Keywords:
- Determine optimal keyword placement for outlined sections e.g.:
- Primary KW in title, H1, intro, conclusion
- Supporting KWs in H2s, first sentence of paras etc.
- Include keywords naturally - no over-optimization
Check Cannibalization:
- Compare suggested keywords against existing content to avoid targeting same terms.
- Modify keywords if needed to differentiate and drive incremental traffic.
Review Opportunities:
- Cross-check keywords in planning tools to confirm search volume and competition.
- Align keywords with buyer intent and top of funnel to mid funnel searches.
- Ensure keywords are entered into analytics to track conversions.
Style and Tone Guidelines
In line with PositiveMed's brand voice, content should adopt an:
Educational yet conversational tone:
- Explain health topics, science and research simply without over-simplifying complex issues.
- Present insightful information in a way that is accessible and engaging for a layperson audience.
Empowering and motivational style:
- Frame content with an uplifting, inspirational tone versus fear-mongering or alarming portrayal of health risks.
- Provide encouraging advice to inspire readers to take charge of their wellbeing.
Trustworthy and ethical approach:
- Uphold highest standards of accuracy, credibility and reliability.
- Cite legitimate sources. Avoid promoting unverified claims or exaggerated benefits.
- Disclose risks, drawbacks and limitations of health approaches covered.
Inclusive and compassionate voice:
- Reflect diversity and sensitivity towards people of different backgrounds, conditions and needs.
- Consider circumstances like financial constraints, disabilities, cultural values etc. that impact health choices.
Hopeful outlook grounded in facts:
- Focus on solutions and a positive outlook while still being realistic.
- Counter misinformation; clarify myths vs facts.
"""


REVIEW_PROMPT = """
You are responsible for refining an article to meet PositiveMed’s stringent publication standards.
Your role involves content analysis, editorial precision, expert validation, legal verification, and overall quality assurance.
# ContentReview:
- Provide constructive feedback on outline and drafts content
- Collect input on strengths to leverage and areas needing improvement.
# Editor Review:
- Evaluate initial drafts for errors, gaps that require additional research.
- Provide guidance on better organizing structure and flow.
- Assess tone, voice and brand alignment.
# Expert Review:
- Ask medical experts related to article topic to validate accuracy of information.
- Verify advice follows ethical guidelines accepted by the medical community.
- Request quotes that lend credibility and reinforce key points.
# Legal Review:
- Confirm content meets regulatory standards for health claims and liability risks.
- Address any recommended edits to mitigate brand reputation risk.
# Quality Checklist: Scrutinize final draft against PositiveMed's standards:
- Medical accuracy - error-free facts/statistics, supported claims
- Logical flow - smooth transitions, complementary sections
- Reader value - insightful analysis beyond fluffy content
- Brand alignment - uplifting tone, inclusive messaging
- Strong conclusion - memorable takeaways, relevant next steps/resources for readers
# ARTICLE TO REVIEW:
{{ARTICLE}}
# OUTPUT:
Re-Write the article, taking into account all review instructions and standards
"""


SOCIAL_MEDIA_SYSTEM_PROMPT_AGENT = """
You're the Social Media System Agent. Your job is to create social media posts for the article below.
Your responsibilities are:
Publishing and Distribution:
• Publishing AI Agent:
• Automated publishing to designated platforms.
• Formatting checks for platform compatibility.
• Distribution:
• Automated sharing to social media channels.
• Email distribution to subscriber list.
Create high converting posts for each social media instagram, facebook, twitter, linkedin, and pinterest optimizing for {{GOAL}} using the article below.
Denote the social media's by using the social media name in HTML like tags
<FACEBOOK> POST CONTENT </FACEBOOK>
<TWITTER> POST CONTENT </TWITTER>
<INSTAGRAM> POST CONTENT </INSTAGRAM>
######### ARTICLE #######
{{ARTICLE}}
"""

llm = OpenAIChat(openai_api_key="")
api_key = os.environ["OPENAI_API_KEY"]
llm = OpenAIChat(openai_api_key=api_key)


def get_review_prompt(article):
Expand Down Expand Up @@ -302,44 +68,6 @@ def social_media_prompt(article: str, goal: str = "Clicks and engagement"):
)
)

# Agent that generates blogs
DRAFT_AGENT_SYSTEM_PROMPT = f"""
Write a 5,000+ word long narrative essay on the highest rated topic from a list of topics for positivemed.com,
their vision is: to democratize health wisdom to modern young professionals in a healthy and conversational and friendly manner,
be nice and reference research papers and other data where you pull from.
You don't have a word limit, you can write as you wish.
--------------------------- Your Responsibilities: -----------------------------
Outline Content:
- Organize research into logical sections and subsections for smooth flow.
- Ensure optimal keyword placement for SEO while maintaining natural tone.
- Structure content to focus on most valuable information upfront.
Compose Draft:
- Open with a relatable introduction to hook readers and overview key points.
- Elaborate on research in the body - explain, analyze and contextualize facts/data .
- Include expert perspective to reinforce claims rather than solely stating opinion.
- Use formatting like bullets, subheads, bolded text to highlight key takeaways.
Apply Brand Voice:
- Maintain an uplifting, motivational tone aligned with PositiveMed's mission.
- Stress solutions-focused advice versus fear-based warnings to empower readers.
- Use inclusive language and culturally sensitive medical references.
Inject Creativity:
- Blend facts with anecdotes, analogies, and examples to spark reader interest.
- Incorporate storytelling elements - journey, conflict, resolution - while being authentic.
- Use conversational style, first- and second-person point-of-view for readability.
Check Accuracy:
- Verify all medical statements against legitimate sources like CDC, Mayo Clinic, NIH.
- Scrutinize cited data for relevance and statistical significance.
- Flag any bold claims that lack credible evidence for fact-checker review.
"""


draft_blog = llm(DRAFT_AGENT_SYSTEM_PROMPT)
draft_out = print(
Expand Down
26 changes: 26 additions & 0 deletions demos/positive_med_sequential.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Swarm Flow
Topic selection agent -> draft agent -> review agent -> distribution agent
Topic Selection Agent:
- Generate 10 topics on gaining mental clarity using Taosim and Christian meditation
Draft Agent:
- Write a 100% unique, creative and in human-like style article of a minimum of 5,000 words using headings and sub-headings.
Review Agent:
- Refine the article to meet PositiveMed’s stringent publication standards.
Distribution Agent:
- Social Media posts for the article.
# TODO
- Add shorter and better topic generator prompt
- Optimize writer prompt to create longer and more enjoyeable blogs
- Use Local Models like Storywriter
"""
from swarms.models import OpenAIChat
from termcolor import colored
2 changes: 1 addition & 1 deletion demos/ui_software_demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Autonomous swarm that optimizes UI autonomously
GPT4Vision ->> GPT4 ->> UI
GPT4Vision ->> GPT4 ->> UI Code
"""
5 changes: 5 additions & 0 deletions openai_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from swarms.models.openai_chat import ChatOpenAI

model = ChatOpenAI()

print(model("Hello, my name is", 5))
3 changes: 0 additions & 3 deletions playground/models/dalle3_concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@
results = dalle3.process_batch_concurrently(tasks)

# print(results)



0 comments on commit a610ff7

Please sign in to comment.