Set your OpenAI API key as an environment variable:
Copy
export OPENAI_API_KEY=your_api_key_here
3
Create Script
Create a new file wikipedia_assistant.py:
Copy
from praisonaiagents import Agent, Task, Praison LabsAgentsfrom praisonaiagents.tools import ( wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language)# Create Wikipedia Agentwiki_agent = Agent( name="WikipediaAssistant", role="Wikipedia Research Specialist", goal="Extract and summarize Wikipedia content", instructions="You are a Wikipedia Agent", tools=[ wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language ], self_reflect=True, min_reflect=3, max_reflect=5)# Research a topicresponse = wiki_agent.start(""" What is the history of AI? First search the history of AI Read the page of the history of AI Get the summary of the page""")# Save research resultswith open('ai_history.md', 'w') as f: f.write(response)
# Example: Research a scientific topicfrom praisonaiagents import Agentfrom praisonaiagents.tools import wiki_search, wiki_summary, wiki_page, wiki_random, wiki_languageagent = Agent( instructions="You are a Wikipedia Agent", tools=[wiki_search, wiki_summary, wiki_page, wiki_random, wiki_language], self_reflect=True, min_reflect=3, max_reflect=5,)agent.start( "What is the history of AI?" "First search the history of AI" "Read the page of the history of AI" "Get the summary of the page")