Generate your OpenAI API key from OpenAI.
Use other LLM providers like Ollama, Anthropic, Groq, Google, etc. Please refer to the Models for more information.
3
Create Agents
Create app.py:
Copy
from praisonaiagents import Agent, PraisonAIAgents# Create a simple agentsummarise_agent = Agent(instructions="Summarise Photosynthesis")# Run the agentagents = PraisonAIAgents(agents=[summarise_agent])agents.start()
4
Run Agents
Execute your script:
Copy
python app.py
You’ll see:
Agent initialization
Task execution progress
Final results
You have successfully CreatedAI Agents and made them work for you!
const { Agent } = require('praisonai');const agent = new Agent({ instructions: 'You are a helpful AI assistant' });agent.start('Write a movie script about a robot in Mars');
import { Agent } from 'praisonai';const agent = new Agent({ instructions: `You are a creative writer who writes short stories with emojis.`, name: "StoryWriter"});agent.start("Write a story about a time traveler")
Generate your OpenAI API key from OpenAI
Use other LLM providers like Ollama, Anthropic, Groq, Google, etc. Please refer to the Models for more information.
3
Create Agent
Create app.py:
Copy
from praisonaiagents import Agent, Task, PraisonAIAgents# Create an agentresearcher = Agent( name="Researcher", role="Senior Research Analyst", goal="Uncover cutting-edge developments in AI", backstory="You are an expert at a technology research group", verbose=True, llm="gpt-4o")# Define a tasktask = Task( name="research_task", description="Analyze 2024's AI advancements", expected_output="A detailed report", agent=researcher)# Run the agentsagents = PraisonAIAgents( agents=[researcher], tasks=[task], verbose=False)result = agents.start()
4
Start Agents
Execute your script:
Terminal
Copy
python app.py
You should see:
Agent initialization
Agents progress
Final results
Generated report
1
Install No Code PraisonAI
Install the No Code PraisonAI Package:
Terminal
Copy
pip install praisonai
2
Set API Key
Set your OpenAI API key as an environment variable in your terminal:
Terminal
Copy
export OPENAI_API_KEY=your_openai_key
3
Create a file
Create a new file agents.yaml with the basic setup:
Copy
framework: praisonaitopic: create movie script about cat in marsagents: # Canonical: use 'agents' instead of 'roles' scriptwriter: instructions: # Canonical: use 'instructions' instead of 'backstory' Expert in dialogue and script structure, translating concepts into scripts. goal: Write a movie script about a cat in Mars role: Scriptwriter tasks: scriptwriting_task: description: Turn the story concept into a production-ready movie script, including dialogue and scene details. expected_output: Final movie script with dialogue and scene details.
You can automatically create agents.yaml file using
Terminal
Copy
praisonai --init create movie script about cat in mars
More information about tools can be found in the Tools section.
Code
No Code
1
Install PraisonAI
Install the core package and duckduckgo_search package:
Terminal
Copy
pip install praisonai duckduckgo_search
2
Create Tools and Agents
Copy
from praisonaiagents import Agent, Task, PraisonAIAgentsfrom duckduckgo_search import DDGSfrom typing import List, Dict# 1. Tooldef internet_search_tool(query: str) -> List[Dict]: """ Perform Internet Search """ results = [] ddgs = DDGS() for result in ddgs.text(keywords=query, max_results=5): results.append({ "title": result.get("title", ""), "url": result.get("href", ""), "snippet": result.get("body", "") }) return results# 2. Agentdata_agent = Agent( name="DataCollector", role="Search Specialist", goal="Perform internet searches to collect relevant information.", backstory="Expert in finding and organising internet data.", tools=[internet_search_tool], self_reflect=False)# 3. Taskscollect_task = Task( description="Perform an internet search using the query: 'AI job trends in 2024'. Return results as a list of title, URL, and snippet.", expected_output="List of search results with titles, URLs, and snippets.", agent=data_agent, name="collect_data",)# 4. Start Agentsagents = PraisonAIAgents( agents=[data_agent], tasks=[collect_task], process="sequential")agents.start()
3
Start Agents
Run your script:
Terminal
Copy
python app.py
1
Install PraisonAI
Install the core package and duckduckgo_search package:
Terminal
Copy
pip install praisonai duckduckgo_search
2
Create Custom Tool
To add additional tools/features you need some coding which can be generated using ChatGPT or any LLM
Create a new file tools.py with the following content:
Copy
from duckduckgo_search import DDGSfrom typing import List, Dict# 1. Tooldef internet_search_tool(query: str) -> List[Dict]: """ Perform Internet Search """ results = [] ddgs = DDGS() for result in ddgs.text(keywords=query, max_results=5): results.append({ "title": result.get("title", ""), "url": result.get("href", ""), "snippet": result.get("body", "") }) return results
3
Create Agent
Create a new file agents.yaml with the following content:
Copy
framework: praisonaitopic: create movie script about cat in marsagents: # Canonical: use 'agents' instead of 'roles' scriptwriter: instructions: # Canonical: use 'instructions' instead of 'backstory' Expert in dialogue and script structure, translating concepts into scripts. goal: Write a movie script about a cat in Mars role: Scriptwriter tools: - internet_search_tool # <-- Tool assigned to Agent here tasks: scriptwriting_task: description: Turn the story concept into a production-ready movie script, including dialogue and scene details. expected_output: Final movie script with dialogue and scene details.