mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-08 01:08:39 -10:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27d6fef28d | ||
|
|
375ffb0365 | ||
|
|
502bff110b | ||
|
|
3ea8ff4cb7 | ||
|
|
dd5ffe2454 | ||
|
|
08742f5dda | ||
|
|
cf601070a4 | ||
|
|
9f0429f559 | ||
|
|
ea54abf3d1 | ||
|
|
4447d64fb6 | ||
|
|
548e96dcf0 | ||
|
|
c97cfa2f5c | ||
|
|
a8e60930d7 | ||
|
|
8c155949db | ||
|
|
3ef6eddb61 | ||
|
|
93f3b23222 | ||
|
|
8e1c393abf | ||
|
|
5b9bcc99c9 | ||
|
|
1124cf1288 | ||
|
|
04f9c313e2 | ||
|
|
ee5c7840fb | ||
|
|
0fc656116f | ||
|
|
340a25b657 | ||
|
|
aa853e0869 | ||
|
|
827a98281d | ||
|
|
b47fa841d9 | ||
|
|
3138d7ebe8 | ||
|
|
54c57f144e |
No files matched your search
@@ -0,0 +1,3 @@
|
||||
OPENAI_MODEL_NAME="gpt-4-turbo-preview"
|
||||
OPENAI_API_KEY="Enter your API key"
|
||||
OPENAI_API_BASE="https://api.openai.com/v1"
|
||||
@@ -0,0 +1,40 @@
|
||||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
||||
|
||||
name: Python package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "develop" ]
|
||||
pull_request:
|
||||
branches: [ "develop" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.10", "3.11"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install flake8 pytest
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||
# - name: Test with pytest
|
||||
# run: |
|
||||
# pytest
|
||||
@@ -0,0 +1,39 @@
|
||||
# This workflow will upload a Python Package using Twine when a release is created
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
name: Upload Python Package
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install build
|
||||
- name: Build package
|
||||
run: python -m build
|
||||
- name: Publish package
|
||||
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.PYPI_API_TOKEN }}
|
||||
+15
-22
@@ -1,23 +1,16 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.vscode
|
||||
crewai
|
||||
.cache
|
||||
__pycache__
|
||||
chroma.sqlite3
|
||||
test/
|
||||
dist/
|
||||
.env
|
||||
assets/*
|
||||
.idea
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pytest_cache
|
||||
praisonAI.egg-info
|
||||
flagged
|
||||
test.yaml
|
||||
db
|
||||
@@ -0,0 +1,6 @@
|
||||
FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN pip install flask praisonai==0.0.18 gunicorn markdown
|
||||
EXPOSE 8080
|
||||
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
|
||||
@@ -1,70 +1,203 @@
|
||||
# Getting Started with Create React App
|
||||
# Praison AI
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
Praison AI, leveraging both AutoGen and CrewAI or any other agent framework, represents a low-code, centralised framework designed to simplify the creation and orchestration of multi-agent systems for various LLM applications, emphasizing ease of use, customization, and human-agent interaction.
|
||||
|
||||
## Available Scripts
|
||||
## Installation
|
||||
|
||||
In the project directory, you can run:
|
||||
```bash
|
||||
pip install praisonai
|
||||
```
|
||||
|
||||
### `npm start`
|
||||
## Initialise
|
||||
|
||||
```bash
|
||||
praisonai --init create a movie script about dog in moon
|
||||
```
|
||||
This will automatically create agents.yaml file in the current directory.
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
||||
To initialse with a specific agent framework:
|
||||
|
||||
The page will reload when you make changes.\
|
||||
You may also see any lint errors in the console.
|
||||
```bash
|
||||
praisonai --framework autogen --init create movie script about cat in mars
|
||||
```
|
||||
|
||||
### `npm test`
|
||||
## Run
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
```bash
|
||||
praisonai
|
||||
```
|
||||
|
||||
### `npm run build`
|
||||
or
|
||||
|
||||
```bash
|
||||
python -m praisonai
|
||||
```
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
### Specify the agent framework
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
```bash
|
||||
praisonai --framework autogen
|
||||
```
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
### Full Automatic Mode
|
||||
|
||||
### `npm run eject`
|
||||
```bash
|
||||
praisonai --auto create a movie script about Dog in Moon
|
||||
```
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
||||
## Test
|
||||
|
||||
```bash
|
||||
python -m unittest tests.test
|
||||
```
|
||||
|
||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
## Agents Playbook
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
||||
### Simple Playbook
|
||||
|
||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
||||
```yaml
|
||||
framework: crewai
|
||||
topic: Artificial Intelligence
|
||||
roles:
|
||||
screenwriter:
|
||||
backstory: 'Skilled in crafting scripts with engaging dialogue about {topic}.'
|
||||
goal: Create scripts from concepts.
|
||||
role: Screenwriter
|
||||
tasks:
|
||||
scriptwriting_task:
|
||||
description: 'Develop scripts with compelling characters and dialogue about {topic}.'
|
||||
expected_output: 'Complete script ready for production.'
|
||||
```
|
||||
|
||||
## Learn More
|
||||
### Detailed Playbook
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
```yaml
|
||||
framework: crewai
|
||||
topic: Artificial Intelligence
|
||||
roles:
|
||||
movie_concept_creator:
|
||||
backstory: 'Creative thinker with a deep understanding of cinematic storytelling,
|
||||
capable of using AI-generated storylines to create unique and compelling movie
|
||||
ideas.'
|
||||
goal: Generate engaging movie concepts using AI storylines
|
||||
role: Movie Concept Creator
|
||||
tasks:
|
||||
movie_concept_development:
|
||||
description: 'Develop movie concepts from AI-generated storylines, ensuring
|
||||
they are engaging and have strong narrative arcs.'
|
||||
expected_output: 'Well-structured movie concept document with character
|
||||
bios, settings, and plot outlines.'
|
||||
screenwriter:
|
||||
backstory: 'Expert in writing engaging dialogue and script structure, able to
|
||||
turn movie concepts into production-ready scripts.'
|
||||
goal: Write compelling scripts based on movie concepts
|
||||
role: Screenwriter
|
||||
tasks:
|
||||
scriptwriting_task:
|
||||
description: 'Turn movie concepts into polished scripts with well-developed
|
||||
characters, strong dialogue, and effective scene transitions.'
|
||||
expected_output: 'Production-ready script with a beginning, middle, and
|
||||
end, along with character development and engaging dialogues.'
|
||||
editor:
|
||||
backstory: 'Adept at identifying inconsistencies, improving language usage,
|
||||
and maintaining the overall flow of the script.'
|
||||
goal: Refine the scripts and ensure continuity of the movie storyline
|
||||
role: Editor
|
||||
tasks:
|
||||
editing_task:
|
||||
description: 'Review, edit, and refine the scripts to ensure they are cohesive
|
||||
and follow a well-structured narrative.'
|
||||
expected_output: 'A polished final draft of the script with no inconsistencies,
|
||||
strong character development, and effective dialogue.'
|
||||
dependencies: []
|
||||
```
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
## Include praisonai package in your project
|
||||
|
||||
### Code Splitting
|
||||
```python
|
||||
from praisonai import PraisonAI
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
||||
def basic(): # Basic Mode
|
||||
praison_ai = PraisonAI(agent_file="agents.yaml")
|
||||
praison_ai.main()
|
||||
|
||||
def advanced(): # Advanced Mode with options
|
||||
praison_ai = PraisonAI(
|
||||
agent_file="agents.yaml",
|
||||
framework="autogen",
|
||||
)
|
||||
praison_ai.main()
|
||||
|
||||
def auto(): # Full Automatic Mode
|
||||
praison_ai = PraisonAI(
|
||||
auto="Create a movie script about car in mars",
|
||||
framework="autogen"
|
||||
)
|
||||
print(praison_ai.framework)
|
||||
praison_ai.main()
|
||||
|
||||
### Analyzing the Bundle Size
|
||||
if __name__ == "__main__":
|
||||
basic()
|
||||
advanced()
|
||||
auto()
|
||||
```
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
||||
## Deploy
|
||||
|
||||
```bash
|
||||
gcloud init
|
||||
gcloud services enable run.googleapis.com
|
||||
gcloud services enable containerregistry.googleapis.com
|
||||
gcloud services enable cloudbuild.googleapis.com
|
||||
|
||||
### Making a Progressive Web App
|
||||
export OPENAI_MODEL_NAME="gpt-4-turbo-preview"
|
||||
export OPENAI_API_KEY="Enter your API key"
|
||||
export OPENAI_API_BASE="https://api.openai.com/v1"
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
||||
yes | gcloud auth configure-docker us-central1-docker.pkg.dev
|
||||
gcloud artifacts repositories create praisonai-repository --repository-format=docker --location=us-central1
|
||||
|
||||
### Advanced Configuration
|
||||
PROJECT_ID=$(gcloud config get-value project)
|
||||
TAG="latest"
|
||||
docker build --platform linux/amd64 -t gcr.io/${PROJECT_ID}/praisonai-app:${TAG} .
|
||||
docker tag gcr.io/${PROJECT_ID}/praisonai-app:${TAG} us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG}
|
||||
docker push us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG}
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
||||
gcloud run deploy praisonai-service \
|
||||
--image us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG} \
|
||||
--platform managed \
|
||||
--region us-central1 \
|
||||
--allow-unauthenticated \
|
||||
--set-env-vars OPENAI_MODEL_NAME=${OPENAI_MODEL_NAME},OPENAI_API_KEY=${OPENAI_API_KEY},OPENAI_API_BASE=${OPENAI_API_BASE}
|
||||
|
||||
### Deployment
|
||||
## Other Models
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
||||
Ollama
|
||||
OPENAI_API_BASE='http://localhost:11434/v1'
|
||||
OPENAI_MODEL_NAME='mistral'
|
||||
OPENAI_API_KEY='NA'
|
||||
|
||||
### `npm run build` fails to minify
|
||||
FastChat¶
|
||||
OPENAI_API_BASE="http://localhost:8001/v1"
|
||||
OPENAI_MODEL_NAME='oh-2.5m7b-q51'
|
||||
OPENAI_API_KEY=NA
|
||||
|
||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
||||
LM Studio¶
|
||||
OPENAI_API_BASE="http://localhost:8000/v1"
|
||||
OPENAI_MODEL_NAME=NA
|
||||
OPENAI_API_KEY=NA
|
||||
|
||||
Mistral API¶
|
||||
OPENAI_API_BASE=https://api.mistral.ai/v1
|
||||
OPENAI_MODEL_NAME="mistral-small"
|
||||
OPENAI_API_KEY=your-mistral-api-key
|
||||
|
||||
## Contributing
|
||||
|
||||
- Fork on GitHub: Use the "Fork" button on the repository page.
|
||||
- Clone your fork: `git clone https://github.com/yourusername/praisonAI.git`
|
||||
- Create a branch: `git checkout -b new-feature`
|
||||
- Make changes and commit: `git commit -am "Add some feature"`
|
||||
- Push to your fork: `git push origin new-feature`
|
||||
- Submit a pull request via GitHub's web interface.
|
||||
- Await feedback from project maintainers.
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
framework: crewai
|
||||
topic: create a movie about cat in mars based on https://blog.celtx.com/how-to-write-a-good-story/
|
||||
roles:
|
||||
story_developer:
|
||||
backstory: Experienced in crafting compelling narratives for a diverse audience.
|
||||
goal: Develop an engaging storyline for a movie about cats in Mars
|
||||
role: Story Developer
|
||||
tasks:
|
||||
storyline_creation:
|
||||
description: Create a captivating storyline for a movie about cats in Mars
|
||||
inspired by the blog post at https://blog.celtx.com/how-to-write-a-good-story/
|
||||
expected_output: Detailed storyline with key plot points, character motivations,
|
||||
and setting descriptions.
|
||||
tools:
|
||||
- 'ScrapeWebsiteTool'
|
||||
screenwriter:
|
||||
backstory: Proficient in translating complex narratives into engaging screenplay
|
||||
format.
|
||||
goal: Transform the storyline into a script
|
||||
role: Screenwriter
|
||||
tasks:
|
||||
script_creation:
|
||||
description: Transform the developed storyline into a script for the movie
|
||||
about cats in Mars.
|
||||
expected_output: Complete script with dialogues, scenes, and stage directions
|
||||
ready for production.
|
||||
tools:
|
||||
- ''
|
||||
director:
|
||||
backstory: Experienced in visual storytelling and bringing scripts to life on
|
||||
screen.
|
||||
goal: Oversee the production of the movie
|
||||
role: Director
|
||||
tasks:
|
||||
movie_production:
|
||||
description: Take the script and lead the team to produce the movie 'Cats
|
||||
in Mars' based on the provided content and script.
|
||||
expected_output: Completed movie ready for distribution with compelling visuals
|
||||
and engaging storytelling.
|
||||
tools:
|
||||
- ''
|
||||
dependencies: []
|
||||
@@ -0,0 +1,18 @@
|
||||
from flask import Flask
|
||||
from praisonai import PraisonAI
|
||||
import markdown
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
def basic():
|
||||
praison_ai = PraisonAI(agent_file="agents.yaml")
|
||||
return praison_ai.main()
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
output = basic()
|
||||
html_output = markdown.markdown(output)
|
||||
return f'<html><body>{html_output}</body></html>'
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
from praisonai import PraisonAI
|
||||
|
||||
def basic():
|
||||
praison_ai = PraisonAI(agent_file="agents.yaml")
|
||||
praison_ai.main()
|
||||
|
||||
def advanced():
|
||||
praison_ai = PraisonAI(
|
||||
agent_file="agents.yaml",
|
||||
framework="autogen",
|
||||
)
|
||||
praison_ai.main()
|
||||
|
||||
def auto():
|
||||
praison_ai = PraisonAI(
|
||||
auto="Create a movie script about car in mars",
|
||||
framework="autogen"
|
||||
)
|
||||
print(praison_ai.framework)
|
||||
praison_ai.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
basic()
|
||||
advanced()
|
||||
auto()
|
||||
@@ -0,0 +1,41 @@
|
||||
framework: "crewai"
|
||||
topic: "Artificial Intelligence"
|
||||
|
||||
roles:
|
||||
researcher:
|
||||
role: "Senior Data Researcher"
|
||||
goal: "Uncover cutting-edge developments in {topic}"
|
||||
backstory: >
|
||||
You're a seasoned researcher with a knack for uncovering the latest
|
||||
developments in {topic}. Known for your ability to find the most relevant
|
||||
information and present it in a clear and concise manner.
|
||||
tools:
|
||||
- search_tool:
|
||||
engine: google
|
||||
tasks:
|
||||
research_task:
|
||||
description: >
|
||||
Conduct thorough research about {topic}, focusing on the latest
|
||||
trends and technologies.
|
||||
expected_output: >
|
||||
A list of 10 bullet points summarizing key findings with links to
|
||||
relevant sources.
|
||||
|
||||
reporting_analyst:
|
||||
role: "Reporting Analyst"
|
||||
goal: "Create detailed reports based on {topic} data analysis and research findings."
|
||||
backstory: >
|
||||
You're a meticulous analyst with a keen eye for detail. You're known for
|
||||
your ability to turn complex data into clear and concise reports, making
|
||||
it easy for others to understand and act on the information you provide.
|
||||
tasks:
|
||||
reporting_task:
|
||||
description: >
|
||||
Review the research findings and create a comprehensive report on
|
||||
{topic}. Include insights, potential opportunities, and recommendations.
|
||||
expected_output: >
|
||||
A well-structured report in Markdown format, ready for distribution.
|
||||
|
||||
dependencies:
|
||||
- task: reporting_task
|
||||
depends_on: research_task
|
||||
@@ -0,0 +1,41 @@
|
||||
framework: "autogen"
|
||||
topic: "Artificial Intelligence"
|
||||
|
||||
roles:
|
||||
narrative_designer:
|
||||
role: "Narrative Designer"
|
||||
goal: "Craft engaging storylines and narratives for {topic}"
|
||||
backstory: >
|
||||
You're a creative visionary skilled in weaving complex narratives and
|
||||
developing engaging story worlds within {topic}. Your expertise lies in
|
||||
conceptualizing the overarching story and ensuring it resonates with the audience.
|
||||
tasks:
|
||||
story_concept_development:
|
||||
description: >
|
||||
Develop a compelling story concept for {topic}, focusing on originality,
|
||||
thematic depth, and audience engagement. Outline the main narrative arcs,
|
||||
characters, and settings.
|
||||
expected_output: >
|
||||
A comprehensive document outlining the story concept, including key narrative
|
||||
arcs, character bios, and settings descriptions.
|
||||
|
||||
scriptwriter:
|
||||
role: "Scriptwriter"
|
||||
goal: "Transform story concepts into detailed scripts for {topic}"
|
||||
backstory: >
|
||||
With a flair for dialogue and a deep understanding of pacing and structure,
|
||||
you excel at bringing narratives to life through scriptwriting. Your work
|
||||
turns story concepts into blueprints for compelling {topic} experiences.
|
||||
tasks:
|
||||
scriptwriting_task:
|
||||
description: >
|
||||
Based on the narrative concept, write a detailed script for {topic}.
|
||||
Include dialogue, stage directions, and scene descriptions that bring
|
||||
the story to life.
|
||||
expected_output: >
|
||||
A detailed script ready for production, including dialogue, stage
|
||||
directions, and scene descriptions.
|
||||
|
||||
dependencies:
|
||||
- task: scriptwriting_task
|
||||
depends_on: story_concept_development
|
||||
Generated
-20043
File diff suppressed because it is too large.
Load diff
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"name": "admin-ui",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@chakra-ui/react": "^2.8.2",
|
||||
"@emotion/react": "^11.11.4",
|
||||
"@emotion/styled": "^11.11.5",
|
||||
"@testing-library/jest-dom": "^5.17.0",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"framer-motion": "^11.2.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-scripts": "5.0.1",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
Generated
+6149
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,2 @@
|
||||
from .cli import PraisonAI
|
||||
from .version import __version__
|
||||
@@ -0,0 +1,10 @@
|
||||
# __main__.py
|
||||
|
||||
from .cli import PraisonAI
|
||||
|
||||
def main():
|
||||
praison_ai = PraisonAI()
|
||||
praison_ai.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,221 @@
|
||||
# agents_generator.py
|
||||
|
||||
import sys
|
||||
from .version import __version__
|
||||
import yaml, os
|
||||
from rich import print
|
||||
from dotenv import load_dotenv
|
||||
from crewai import Agent, Task, Crew
|
||||
load_dotenv()
|
||||
import autogen
|
||||
import gradio as gr
|
||||
import argparse
|
||||
from .auto import AutoGenerator
|
||||
from crewai_tools import *
|
||||
from .tools import *
|
||||
|
||||
class AgentsGenerator:
|
||||
def __init__(self, agent_file, framework, config_list):
|
||||
self.agent_file = agent_file
|
||||
self.framework = framework
|
||||
self.config_list = config_list
|
||||
|
||||
def generate_crew_and_kickoff(self):
|
||||
if self.agent_file == '/app/api:app' or self.agent_file == 'api:app':
|
||||
self.agent_file = 'agents.yaml'
|
||||
try:
|
||||
with open(self.agent_file, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
except FileNotFoundError:
|
||||
print(f"File not found: {self.agent_file}")
|
||||
return
|
||||
|
||||
topic = config['topic']
|
||||
tools_dict = {
|
||||
'CodeDocsSearchTool': CodeDocsSearchTool(),
|
||||
'CSVSearchTool': CSVSearchTool(),
|
||||
'DirectorySearchTool': DirectorySearchTool(),
|
||||
'DOCXSearchTool': DOCXSearchTool(),
|
||||
'DirectoryReadTool': DirectoryReadTool(),
|
||||
'FileReadTool': FileReadTool(),
|
||||
# 'GithubSearchTool': GithubSearchTool(),
|
||||
# 'SeperDevTool': SeperDevTool(),
|
||||
'TXTSearchTool': TXTSearchTool(),
|
||||
'JSONSearchTool': JSONSearchTool(),
|
||||
'MDXSearchTool': MDXSearchTool(),
|
||||
'PDFSearchTool': PDFSearchTool(),
|
||||
# 'PGSearchTool': PGSearchTool(),
|
||||
'RagTool': RagTool(),
|
||||
'ScrapeElementFromWebsiteTool': ScrapeElementFromWebsiteTool(),
|
||||
'ScrapeWebsiteTool': ScrapeWebsiteTool(),
|
||||
'WebsiteSearchTool': WebsiteSearchTool(),
|
||||
'XMLSearchTool': XMLSearchTool(),
|
||||
'YoutubeChannelSearchTool': YoutubeChannelSearchTool(),
|
||||
'YoutubeVideoSearchTool': YoutubeVideoSearchTool()
|
||||
}
|
||||
# config['tools'] = [tools_dict[tool] for tool in config.get('tools', []) if tool in tools_dict]
|
||||
framework = self.framework or config.get('framework')
|
||||
|
||||
agents = {}
|
||||
tasks = []
|
||||
if framework == "autogen":
|
||||
# Load the LLM configuration dynamically
|
||||
# print(self.config_list)
|
||||
llm_config = {"config_list": self.config_list}
|
||||
|
||||
# Assuming the user proxy agent is set up as per your requirements
|
||||
user_proxy = autogen.UserProxyAgent(
|
||||
name="User",
|
||||
human_input_mode="NEVER",
|
||||
is_termination_msg=lambda x: (x.get("content") or "").rstrip().rstrip(".").lower().endswith("terminate") or "TERMINATE" in (x.get("content") or ""),
|
||||
code_execution_config={
|
||||
"work_dir": "coding",
|
||||
"use_docker": False,
|
||||
},
|
||||
# additional setup for the user proxy agent
|
||||
)
|
||||
|
||||
for role, details in config['roles'].items():
|
||||
agent_name = details['role'].format(topic=topic).replace("{topic}", topic)
|
||||
agent_goal = details['goal'].format(topic=topic)
|
||||
# Creating an AssistantAgent for each role dynamically
|
||||
agents[role] = autogen.AssistantAgent(
|
||||
name=agent_name,
|
||||
llm_config=llm_config,
|
||||
system_message=details['backstory'].format(topic=topic)+". Must Reply \"TERMINATE\" in the end when everything is done.",
|
||||
)
|
||||
for tool in details.get('tools', []):
|
||||
if tool in tools_dict:
|
||||
tool_class = globals()[f'autogen_{type(tools_dict[tool]).__name__}']
|
||||
tool_class(agents[role], user_proxy)
|
||||
|
||||
# Preparing tasks for initiate_chats
|
||||
for task_name, task_details in details.get('tasks', {}).items():
|
||||
description_filled = task_details['description'].format(topic=topic)
|
||||
expected_output_filled = task_details['expected_output'].format(topic=topic)
|
||||
|
||||
chat_task = {
|
||||
"recipient": agents[role],
|
||||
"message": description_filled,
|
||||
"summary_method": "last_msg",
|
||||
# Additional fields like carryover can be added based on dependencies
|
||||
}
|
||||
tasks.append(chat_task)
|
||||
|
||||
response = user_proxy.initiate_chats(tasks)
|
||||
result = "### Output ###\n"+response[-1].summary if hasattr(response[-1], 'summary') else ""
|
||||
else:
|
||||
for role, details in config['roles'].items():
|
||||
role_filled = details['role'].format(topic=topic)
|
||||
goal_filled = details['goal'].format(topic=topic)
|
||||
backstory_filled = details['backstory'].format(topic=topic)
|
||||
|
||||
# Adding tools to the agent if exists
|
||||
agent_tools = [tools_dict[tool] for tool in details.get('tools', []) if tool in tools_dict]
|
||||
agent = Agent(role=role_filled, goal=goal_filled, backstory=backstory_filled, tools=agent_tools, allow_delegation=False)
|
||||
agents[role] = agent
|
||||
|
||||
for task_name, task_details in details.get('tasks', {}).items():
|
||||
description_filled = task_details['description'].format(topic=topic)
|
||||
expected_output_filled = task_details['expected_output'].format(topic=topic)
|
||||
|
||||
task = Task(description=description_filled, expected_output=expected_output_filled, agent=agent)
|
||||
tasks.append(task)
|
||||
# print(agents)
|
||||
crew = Crew(
|
||||
agents=list(agents.values()),
|
||||
tasks=tasks,
|
||||
verbose=2
|
||||
)
|
||||
|
||||
response = crew.kickoff()
|
||||
result = f"### Task Output ###\n{response}"
|
||||
return result
|
||||
|
||||
|
||||
# # AutoGen Tools example below
|
||||
# from typing import Any, Optional
|
||||
# import os
|
||||
# from autogen import ConversableAgent
|
||||
# from autogen_tools import autogen_ScrapeWebsiteTool
|
||||
|
||||
# assistant = ConversableAgent(
|
||||
# name="Assistant",
|
||||
# system_message="You are a helpful AI assistant. "
|
||||
# "You can help with website scraping. "
|
||||
# "Return 'TERMINATE' when the task is done.",
|
||||
# llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
||||
# )
|
||||
|
||||
# user_proxy = ConversableAgent(
|
||||
# name="User",
|
||||
# llm_config=False,
|
||||
# is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
||||
# human_input_mode="NEVER",
|
||||
# )
|
||||
|
||||
# autogen_ScrapeWebsiteTool(assistant, user_proxy)
|
||||
|
||||
# chat_result = user_proxy.initiate_chat(assistant, message="Scrape the official Nodejs website.")
|
||||
|
||||
# # CrewAI Tools example below
|
||||
# import os
|
||||
# from crewai import Agent, Task, Crew
|
||||
# # Importing crewAI tools
|
||||
# from crewai_tools import (
|
||||
# DirectoryReadTool,
|
||||
# FileReadTool,
|
||||
# SerperDevTool,
|
||||
# WebsiteSearchTool
|
||||
# )
|
||||
|
||||
# # Set up API keys
|
||||
# os.environ["SERPER_API_KEY"] = "Your Key" # serper.dev API key
|
||||
# os.environ["OPENAI_API_KEY"] = "Your Key"
|
||||
|
||||
# # Instantiate tools
|
||||
# docs_tool = DirectoryReadTool(directory='./blog-posts')
|
||||
# file_tool = FileReadTool()
|
||||
# search_tool = SerperDevTool()
|
||||
# web_rag_tool = WebsiteSearchTool()
|
||||
|
||||
# # Create agents
|
||||
# researcher = Agent(
|
||||
# role='Market Research Analyst',
|
||||
# goal='Provide up-to-date market analysis of the AI industry',
|
||||
# backstory='An expert analyst with a keen eye for market trends.',
|
||||
# tools=[search_tool, web_rag_tool],
|
||||
# verbose=True
|
||||
# )
|
||||
|
||||
# writer = Agent(
|
||||
# role='Content Writer',
|
||||
# goal='Craft engaging blog posts about the AI industry',
|
||||
# backstory='A skilled writer with a passion for technology.',
|
||||
# tools=[docs_tool, file_tool],
|
||||
# verbose=True
|
||||
# )
|
||||
|
||||
# # Define tasks
|
||||
# research = Task(
|
||||
# description='Research the latest trends in the AI industry and provide a summary.',
|
||||
# expected_output='A summary of the top 3 trending developments in the AI industry with a unique perspective on their significance.',
|
||||
# agent=researcher
|
||||
# )
|
||||
|
||||
# write = Task(
|
||||
# description='Write an engaging blog post about the AI industry, based on the research analyst’s summary. Draw inspiration from the latest blog posts in the directory.',
|
||||
# expected_output='A 4-paragraph blog post formatted in markdown with engaging, informative, and accessible content, avoiding complex jargon.',
|
||||
# agent=writer,
|
||||
# output_file='blog-posts/new_post.md' # The final blog post will be saved here
|
||||
# )
|
||||
|
||||
# # Assemble a crew
|
||||
# crew = Crew(
|
||||
# agents=[researcher, writer],
|
||||
# tasks=[research, write],
|
||||
# verbose=2
|
||||
# )
|
||||
|
||||
# # Execute tasks
|
||||
# crew.kickoff()
|
||||
@@ -0,0 +1,155 @@
|
||||
from openai import OpenAI
|
||||
from pydantic import BaseModel
|
||||
from typing import Dict, List
|
||||
import instructor
|
||||
import os
|
||||
import json
|
||||
import yaml
|
||||
from rich import print
|
||||
|
||||
# Define Pydantic models outside of the generate method
|
||||
class TaskDetails(BaseModel):
|
||||
description: str
|
||||
expected_output: str
|
||||
|
||||
class RoleDetails(BaseModel):
|
||||
role: str
|
||||
goal: str
|
||||
backstory: str
|
||||
tasks: Dict[str, TaskDetails]
|
||||
tools: List[str]
|
||||
|
||||
class TeamStructure(BaseModel):
|
||||
roles: Dict[str, RoleDetails]
|
||||
|
||||
class AutoGenerator:
|
||||
def __init__(self, topic="Movie Story writing about AI", agent_file="test.yaml", framework="crewai"):
|
||||
self.config_list = [
|
||||
{
|
||||
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4-turbo-preview"),
|
||||
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
|
||||
}
|
||||
]
|
||||
self.topic = topic
|
||||
self.agent_file = agent_file
|
||||
self.framework = framework
|
||||
if not os.getenv("OPENAI_API_KEY"):
|
||||
raise EnvironmentError("The OPENAI_API_KEY environment variable is not set.")
|
||||
self.client = instructor.patch(
|
||||
OpenAI(
|
||||
base_url=self.config_list[0]['base_url'],
|
||||
api_key=os.getenv("OPENAI_API_KEY"),
|
||||
),
|
||||
mode=instructor.Mode.JSON,
|
||||
)
|
||||
|
||||
import time
|
||||
|
||||
def generate(self):
|
||||
retry_delay = 1 # Start with a 1 second delay
|
||||
max_retries = 5 # Maximum number of retries
|
||||
retries = 0
|
||||
|
||||
while retries < max_retries:
|
||||
try:
|
||||
response = self.client.chat.completions.create(
|
||||
model=self.config_list[0]['model'],
|
||||
response_model=TeamStructure,
|
||||
messages=[
|
||||
{"role": "system", "content": "You are a helpful assistant designed to output complex team structures."},
|
||||
{"role": "user", "content": self.get_user_content()}
|
||||
]
|
||||
)
|
||||
json_data = json.loads(response.model_dump_json())
|
||||
self.convert_and_save(json_data)
|
||||
full_path = os.path.abspath(self.agent_file)
|
||||
return full_path
|
||||
except openai.error.RateLimitError:
|
||||
print(f"RateLimitError: Retrying in {retry_delay} seconds...")
|
||||
time.sleep(retry_delay)
|
||||
retry_delay *= 2 # Exponential backoff
|
||||
retries += 1
|
||||
|
||||
raise Exception("Max retries exceeded for API call")
|
||||
|
||||
def convert_and_save(self, json_data):
|
||||
"""Converts the provided JSON data into the desired YAML format and saves it to a file.
|
||||
|
||||
Args:
|
||||
json_data (dict): The JSON data representing the team structure.
|
||||
topic (str, optional): The topic to be inserted into the YAML. Defaults to "Artificial Intelligence".
|
||||
agent_file (str, optional): The name of the YAML file to save. Defaults to "test.yaml".
|
||||
"""
|
||||
|
||||
yaml_data = {
|
||||
"framework": self.framework,
|
||||
"topic": self.topic,
|
||||
"roles": {},
|
||||
"dependencies": []
|
||||
}
|
||||
|
||||
for role_id, role_details in json_data['roles'].items():
|
||||
yaml_data['roles'][role_id] = {
|
||||
"backstory": "" + role_details['backstory'],
|
||||
"goal": role_details['goal'],
|
||||
"role": role_details['role'],
|
||||
"tasks": {},
|
||||
# "tools": role_details.get('tools', []),
|
||||
"tools": ['']
|
||||
}
|
||||
|
||||
for task_id, task_details in role_details['tasks'].items():
|
||||
yaml_data['roles'][role_id]['tasks'][task_id] = {
|
||||
"description": "" + task_details['description'],
|
||||
"expected_output": "" + task_details['expected_output']
|
||||
}
|
||||
|
||||
# Save to YAML file, maintaining the order
|
||||
with open(self.agent_file, 'w') as f:
|
||||
yaml.dump(yaml_data, f, allow_unicode=True, sort_keys=False)
|
||||
|
||||
def get_user_content(self):
|
||||
user_content = """Generate a team structure for \"""" + self.topic + """\" task.
|
||||
No Input data will be provided to the team.
|
||||
The team will work in sequence. First role will pass the output to the next role, and so on.
|
||||
The last role will generate the final output.
|
||||
Think step by step.
|
||||
With maximum 3 roles, each with 1 task. Include role goals, backstories, task descriptions, and expected outputs.
|
||||
List of Available Tools: CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool, FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool, ScrapeElementFromWebsiteTool, ScrapeWebsiteTool, WebsiteSearchTool, XMLSearchTool, YoutubeChannelSearchTool, YoutubeVideoSearchTool.
|
||||
Only use Available Tools. Do Not use any other tools.
|
||||
Example Below:
|
||||
Use below example to understand the structure of the output.
|
||||
The final role you create should satisfy the provided task: """ + self.topic + """.
|
||||
{
|
||||
"roles": {
|
||||
"narrative_designer": {
|
||||
"role": "Narrative Designer",
|
||||
"goal": "Create AI storylines",
|
||||
"backstory": "Skilled in narrative development for AI, with a focus on story resonance.",
|
||||
"tools": ["ScrapeWebsiteTool"],
|
||||
"tasks": {
|
||||
"story_concept_development": {
|
||||
"description": "Craft a unique AI story concept with depth and engagement using concept from this page the content https://www.asthebirdfliesblog.com/posts/how-to-write-book-story-development .",
|
||||
"expected_output": "Document with narrative arcs, character bios, and settings."
|
||||
}
|
||||
}
|
||||
},
|
||||
"scriptwriter": {
|
||||
"role": "Scriptwriter",
|
||||
"goal": "Write scripts from AI concepts",
|
||||
"backstory": "Expert in dialogue and script structure, translating concepts into scripts.",
|
||||
"tasks": {
|
||||
"scriptwriting_task": {
|
||||
"description": "Turn narrative concepts into scripts, including dialogue and scenes.",
|
||||
"expected_output": "Production-ready script with dialogue and scene details."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
return user_content
|
||||
|
||||
|
||||
# generator = AutoGenerator(framework="crewai", topic="Create a snake game in python")
|
||||
# print(generator.generate())
|
||||
@@ -0,0 +1,172 @@
|
||||
# praisonai/cli.py
|
||||
|
||||
import sys
|
||||
from .version import __version__
|
||||
import yaml, os
|
||||
from rich import print
|
||||
from dotenv import load_dotenv
|
||||
from crewai import Agent, Task, Crew
|
||||
load_dotenv()
|
||||
print(f"Loaded environment variables: OPENAI_MODEL_NAME={os.environ.get('OPENAI_MODEL_NAME')}, OPENAI_API_KEY={os.environ.get('OPENAI_API_KEY')}, OPENAI_API_BASE={os.environ.get('OPENAI_API_BASE')}")
|
||||
import autogen
|
||||
import gradio as gr
|
||||
import argparse
|
||||
from .auto import AutoGenerator
|
||||
from .agents_generator import AgentsGenerator
|
||||
from crewai_tools import *
|
||||
from .tools import *
|
||||
|
||||
class PraisonAI:
|
||||
def __init__(self, agent_file="agents.yaml", framework="crewai", auto=False, init=False):
|
||||
self.config_list = [
|
||||
{
|
||||
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-4-turbo-preview"),
|
||||
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
|
||||
}
|
||||
]
|
||||
self.agent_file = agent_file
|
||||
self.framework = framework
|
||||
self.auto = auto
|
||||
self.init = init
|
||||
|
||||
def main(self):
|
||||
args = self.parse_args()
|
||||
if args is None:
|
||||
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
|
||||
result = agents_generator.generate_crew_and_kickoff()
|
||||
return result
|
||||
if args.deploy:
|
||||
from .deploy import CloudDeployer
|
||||
deployer = CloudDeployer()
|
||||
deployer.run_commands()
|
||||
return
|
||||
invocation_cmd = "praisonai"
|
||||
version_string = f"PraisonAI version {__version__}"
|
||||
|
||||
if args.framework:
|
||||
self.framework = args.framework
|
||||
|
||||
ui = args.ui
|
||||
|
||||
if args.agent_file:
|
||||
if args.agent_file == "tests.test": # Argument used for testing purposes
|
||||
full_path = os.path.abspath("agents.yaml")
|
||||
else:
|
||||
full_path = os.path.abspath(args.agent_file)
|
||||
self.agent_file = full_path
|
||||
else:
|
||||
full_path = os.path.abspath(self.agent_file)
|
||||
self.agent_file = full_path
|
||||
|
||||
if args.auto or args.init:
|
||||
temp_topic = ' '.join(args.auto) if args.auto else ' '.join(args.init)
|
||||
self.topic = temp_topic
|
||||
elif self.auto or self.init: # Use the auto attribute if args.auto is not provided
|
||||
self.topic = self.auto
|
||||
|
||||
if args.auto or self.auto:
|
||||
if not os.environ.get('OPENAI_API_KEY'):
|
||||
print("Error: OPENAI_API_KEY is not set. Please check your .env file.")
|
||||
sys.exit(1)
|
||||
print(f"Debug: OPENAI_API_KEY={os.environ.get('OPENAI_API_KEY')}")
|
||||
self.agent_file = "test.yaml"
|
||||
generator = AutoGenerator(topic=self.topic , framework=self.framework, agent_file=self.agent_file)
|
||||
self.agent_file = generator.generate()
|
||||
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
|
||||
result = agents_generator.generate_crew_and_kickoff()
|
||||
return result
|
||||
elif args.init or self.init:
|
||||
if not os.environ.get('OPENAI_API_KEY'):
|
||||
print("Error: OPENAI_API_KEY is not set. Please check your .env file.")
|
||||
sys.exit(1)
|
||||
print(f"Debug: OPENAI_API_KEY={os.environ.get('OPENAI_API_KEY')}")
|
||||
self.agent_file = "agents.yaml"
|
||||
generator = AutoGenerator(topic=self.topic , framework=self.framework, agent_file=self.agent_file)
|
||||
self.agent_file = generator.generate()
|
||||
print("File {} created successfully".format(self.agent_file))
|
||||
return "File {} created successfully".format(self.agent_file)
|
||||
|
||||
if ui:
|
||||
self.create_gradio_interface()
|
||||
else:
|
||||
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
|
||||
result = agents_generator.generate_crew_and_kickoff()
|
||||
return result
|
||||
|
||||
def parse_args(self):
|
||||
parser = argparse.ArgumentParser(prog="praisonai", description="praisonAI command-line interface")
|
||||
parser.add_argument("--framework", choices=["crewai", "autogen"], default="crewai", help="Specify the framework")
|
||||
parser.add_argument("--ui", action="store_true", help="Enable UI mode")
|
||||
parser.add_argument("--auto", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
|
||||
parser.add_argument("--init", nargs=argparse.REMAINDER, help="Enable auto mode and pass arguments for it")
|
||||
parser.add_argument("agent_file", nargs="?", help="Specify the agent file")
|
||||
parser.add_argument("--deploy", action="store_true", help="Deploy the application") # New argument
|
||||
|
||||
args, unknown_args = parser.parse_known_args()
|
||||
|
||||
if unknown_args and unknown_args[0] == '-b' and unknown_args[1] == 'api:app':
|
||||
args.agent_file = 'agents.yaml'
|
||||
if args.agent_file == 'api:app' or args.agent_file == '/app/api:app':
|
||||
args.agent_file = 'agents.yaml'
|
||||
|
||||
return args
|
||||
|
||||
def create_gradio_interface(self):
|
||||
def generate_crew_and_kickoff_interface(auto_args, framework):
|
||||
self.framework = framework
|
||||
self.agent_file = "test.yaml"
|
||||
generator = AutoGenerator(topic=auto_args , framework=self.framework)
|
||||
self.agent_file = generator.generate()
|
||||
agents_generator = AgentsGenerator(self.agent_file, self.framework, self.config_list)
|
||||
result = agents_generator.generate_crew_and_kickoff()
|
||||
return result
|
||||
|
||||
gr.Interface(
|
||||
fn=generate_crew_and_kickoff_interface,
|
||||
inputs=[gr.Textbox(lines=2, label="Auto Args"), gr.Dropdown(choices=["crewai", "autogen"], label="Framework")],
|
||||
outputs="textbox",
|
||||
title="Praison AI Studio",
|
||||
description="Create Agents and perform tasks",
|
||||
theme="default"
|
||||
).launch()
|
||||
|
||||
if __name__ == "__main__":
|
||||
praison_ai = PraisonAI()
|
||||
praison_ai.main()
|
||||
|
||||
|
||||
|
||||
## agents.yaml
|
||||
# framework: autogen
|
||||
# topic: create movie script about cat in mars
|
||||
# roles:
|
||||
# concept_developer:
|
||||
# backstory: Experienced in creating captivating and original story concepts.
|
||||
# goal: Generate a unique concept for a movie script about a cat in Mars
|
||||
# role: Concept Developer
|
||||
# tools:
|
||||
# - search_tool
|
||||
# tasks:
|
||||
# concept_generation:
|
||||
# description: Develop a unique and engaging concept for a movie script about
|
||||
# a cat in Mars.
|
||||
# expected_output: A detailed concept document for the movie script.
|
||||
# scriptwriter:
|
||||
# backstory: Expert in dialogue and script structure, translating concepts into
|
||||
# scripts.
|
||||
# goal: Write a script based on the movie concept
|
||||
# role: Scriptwriter
|
||||
# tasks:
|
||||
# scriptwriting_task:
|
||||
# description: Turn the movie concept into a script, including dialogue and
|
||||
# scenes.
|
||||
# expected_output: A production-ready script for the movie about a cat in Mars.
|
||||
# director:
|
||||
# backstory: Experienced in visualizing scripts and creating compelling storyboards.
|
||||
# goal: Create a storyboard and visualize the script
|
||||
# role: Director
|
||||
# tasks:
|
||||
# storyboard_creation:
|
||||
# description: Create a storyboard for the movie script about a cat in Mars.
|
||||
# expected_output: A detailed storyboard for the movie about a cat in Mars.
|
||||
# dependencies: []
|
||||
@@ -0,0 +1,66 @@
|
||||
import subprocess
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
class CloudDeployer:
|
||||
def __init__(self):
|
||||
# Load environment variables from .env file or system
|
||||
load_dotenv()
|
||||
self.set_environment_variables()
|
||||
|
||||
def create_dockerfile(self):
|
||||
with open("Dockerfile", "w") as file:
|
||||
file.write("FROM python:3.11-slim\n")
|
||||
file.write("WORKDIR /app\n")
|
||||
file.write("COPY . .\n")
|
||||
file.write("RUN pip install flask praisonai==0.0.18 gunicorn markdown\n")
|
||||
file.write("EXPOSE 8080\n")
|
||||
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')
|
||||
|
||||
def create_api_file(self):
|
||||
with open("api.py", "w") as file:
|
||||
file.write("from flask import Flask\n")
|
||||
file.write("from praisonai import PraisonAI\n")
|
||||
file.write("import markdown\n\n")
|
||||
file.write("app = Flask(__name__)\n\n")
|
||||
file.write("def basic():\n")
|
||||
file.write(" praison_ai = PraisonAI(agent_file=\"agents.yaml\")\n")
|
||||
file.write(" return praison_ai.main()\n\n")
|
||||
file.write("@app.route('/')\n")
|
||||
file.write("def home():\n")
|
||||
file.write(" output = basic()\n")
|
||||
file.write(" html_output = markdown.markdown(output)\n")
|
||||
file.write(" return f'<html><body>{html_output}</body></html>'\n\n")
|
||||
file.write("if __name__ == \"__main__\":\n")
|
||||
file.write(" app.run(debug=True)\n")
|
||||
|
||||
def set_environment_variables(self):
|
||||
"""Sets environment variables with fallback to .env values or defaults."""
|
||||
os.environ["OPENAI_MODEL_NAME"] = os.getenv("OPENAI_MODEL_NAME", "gpt-4-turbo-preview")
|
||||
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY", "Enter your API key")
|
||||
os.environ["OPENAI_API_BASE"] = os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1")
|
||||
|
||||
def run_commands(self):
|
||||
self.create_api_file()
|
||||
self.create_dockerfile()
|
||||
"""Runs a sequence of shell commands for deployment, continues on error."""
|
||||
commands = [
|
||||
"yes | gcloud auth configure-docker us-central1-docker.pkg.dev",
|
||||
"gcloud artifacts repositories create praisonai-repository --repository-format=docker --location=us-central1",
|
||||
"docker build --platform linux/amd64 -t gcr.io/$(gcloud config get-value project)/praisonai-app:latest .",
|
||||
"docker tag gcr.io/$(gcloud config get-value project)/praisonai-app:latest us-central1-docker.pkg.dev/$(gcloud config get-value project)/praisonai-repository/praisonai-app:latest",
|
||||
"docker push us-central1-docker.pkg.dev/$(gcloud config get-value project)/praisonai-repository/praisonai-app:latest",
|
||||
"gcloud run deploy praisonai-service --image us-central1-docker.pkg.dev/$(gcloud config get-value project)/praisonai-repository/praisonai-app:latest --platform managed --region us-central1 --allow-unauthenticated --set-env-vars OPENAI_MODEL_NAME=${OPENAI_MODEL_NAME},OPENAI_API_KEY=${OPENAI_API_KEY},OPENAI_API_BASE=${OPENAI_API_BASE}"
|
||||
]
|
||||
|
||||
for cmd in commands:
|
||||
try:
|
||||
subprocess.run(cmd, shell=True, check=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"ERROR: Command '{e.cmd}' failed with exit status {e.returncode}")
|
||||
print(f"Continuing with the next command...")
|
||||
|
||||
# Usage
|
||||
if __name__ == "__main__":
|
||||
deployer = CloudDeployer()
|
||||
deployer.run_commands()
|
||||
@@ -0,0 +1,93 @@
|
||||
import yaml, os
|
||||
from rich import print
|
||||
from dotenv import load_dotenv
|
||||
from crewai import Agent, Task, Crew
|
||||
load_dotenv()
|
||||
import autogen
|
||||
config_list = [
|
||||
{
|
||||
'model': os.environ.get("OPENAI_MODEL_NAME", "gpt-3.5-turbo"),
|
||||
'base_url': os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1"),
|
||||
}
|
||||
]
|
||||
|
||||
def generate_crew_and_kickoff(agent_file):
|
||||
with open(agent_file, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
|
||||
topic = config['topic']
|
||||
framework = config['framework']
|
||||
|
||||
agents = {}
|
||||
tasks = []
|
||||
if framework == "autogen":
|
||||
# Load the LLM configuration dynamically
|
||||
print(config_list)
|
||||
llm_config = {"config_list": config_list}
|
||||
|
||||
for role, details in config['roles'].items():
|
||||
agent_name = details['role'].format(topic=topic).replace("{topic}", topic)
|
||||
agent_goal = details['goal'].format(topic=topic)
|
||||
# Creating an AssistantAgent for each role dynamically
|
||||
agents[role] = autogen.AssistantAgent(
|
||||
name=agent_name,
|
||||
llm_config=llm_config,
|
||||
system_message=details['backstory'].format(topic=topic)+". Reply \"TERMINATE\" in the end when everything is done.",
|
||||
)
|
||||
|
||||
# Preparing tasks for initiate_chats
|
||||
for task_name, task_details in details.get('tasks', {}).items():
|
||||
description_filled = task_details['description'].format(topic=topic)
|
||||
expected_output_filled = task_details['expected_output'].format(topic=topic)
|
||||
|
||||
chat_task = {
|
||||
"recipient": agents[role],
|
||||
"message": description_filled,
|
||||
"summary_method": "last_msg", # Customize as needed
|
||||
# Additional fields like carryover can be added based on dependencies
|
||||
}
|
||||
tasks.append(chat_task)
|
||||
|
||||
# Assuming the user proxy agent is set up as per your requirements
|
||||
user = autogen.UserProxyAgent(
|
||||
name="User",
|
||||
human_input_mode="NEVER",
|
||||
is_termination_msg=lambda x: (x.get("content") or "").rstrip().endswith("TERMINATE"),
|
||||
code_execution_config={
|
||||
"work_dir": "coding",
|
||||
"use_docker": False,
|
||||
},
|
||||
# additional setup for the user proxy agent
|
||||
)
|
||||
response = user.initiate_chats(tasks)
|
||||
result = "### Output ###\n"+response[-1].summary if hasattr(response[-1], 'summary') else ""
|
||||
else:
|
||||
for role, details in config['roles'].items():
|
||||
role_filled = details['role'].format(topic=topic)
|
||||
goal_filled = details['goal'].format(topic=topic)
|
||||
backstory_filled = details['backstory'].format(topic=topic)
|
||||
|
||||
# Assume tools are loaded and handled here as per your requirements
|
||||
agent = Agent(role=role_filled, goal=goal_filled, backstory=backstory_filled)
|
||||
agents[role] = agent
|
||||
|
||||
for task_name, task_details in details.get('tasks', {}).items():
|
||||
description_filled = task_details['description'].format(topic=topic)
|
||||
expected_output_filled = task_details['expected_output'].format(topic=topic)
|
||||
|
||||
task = Task(description=description_filled, expected_output=expected_output_filled, agent=agent)
|
||||
tasks.append(task)
|
||||
|
||||
crew = Crew(
|
||||
agents=list(agents.values()),
|
||||
tasks=tasks,
|
||||
verbose=2
|
||||
)
|
||||
|
||||
result = crew.kickoff()
|
||||
return result
|
||||
|
||||
if __name__ == "__main__":
|
||||
agent_file = "agents.yaml"
|
||||
result = generate_crew_and_kickoff(agent_file)
|
||||
print(result)
|
||||
@@ -0,0 +1,2 @@
|
||||
from .base_tool import BaseTool, Tool, tool
|
||||
from .autogen_tools import *
|
||||
@@ -0,0 +1,147 @@
|
||||
from crewai_tools import (
|
||||
CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool,
|
||||
FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool,
|
||||
ScrapeElementFromWebsiteTool, ScrapeWebsiteTool, WebsiteSearchTool, XMLSearchTool, YoutubeChannelSearchTool,
|
||||
YoutubeVideoSearchTool
|
||||
)
|
||||
from typing import Any
|
||||
from autogen import register_function
|
||||
|
||||
def autogen_CodeDocsSearchTool(assistant, user_proxy):
|
||||
def register_code_docs_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(docs_url: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(docs_url=docs_url, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_code_docs_search_tool(CodeDocsSearchTool, "code_docs_search_tool", "Search a Code Docs content(search_query: 'string', docs_url: 'string') - A tool that can be used to semantic search a query from a Code Docs content.", assistant, user_proxy)
|
||||
|
||||
def autogen_CSVSearchTool(assistant, user_proxy):
|
||||
def register_csv_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(csv: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(csv=csv, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_csv_search_tool(CSVSearchTool, "csv_search_tool", "Search a CSV's content(search_query: 'string', csv: 'string') - A tool that can be used to semantic search a query from a CSV's content.", assistant, user_proxy)
|
||||
|
||||
def autogen_DirectorySearchTool(assistant, user_proxy):
|
||||
def register_directory_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(directory: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(directory=directory, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_directory_search_tool(DirectorySearchTool, "directory_search_tool", "Search a directory's content(search_query: 'string', directory: 'string') - A tool that can be used to semantic search a query from a directory's content.", assistant, user_proxy)
|
||||
|
||||
def autogen_DOCXSearchTool(assistant, user_proxy):
|
||||
def register_docx_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(docx: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(docx=docx, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_docx_search_tool(DOCXSearchTool, "docx_search_tool", "Search a DOCX's content(search_query: 'string', docx: 'string') - A tool that can be used to semantic search a query from a DOCX's content.", assistant, user_proxy)
|
||||
|
||||
# DirectoryReadTool
|
||||
def autogen_DirectoryReadTool(assistant, user_proxy):
|
||||
def register_directory_read_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(directory: str) -> Any:
|
||||
tool_instance = tool_class(directory=directory)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_directory_read_tool(DirectoryReadTool, "directory_read_tool", "List files in directory(directory: 'string') - A tool that can be used to recursively list a directory's content.", assistant, user_proxy)
|
||||
|
||||
# FileReadTool
|
||||
def autogen_FileReadTool(assistant, user_proxy):
|
||||
def register_file_read_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(file_path: str) -> Any:
|
||||
tool_instance = tool_class(file_path=file_path)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_file_read_tool(FileReadTool, "file_read_tool", "Read a file's content(file_path: 'string') - A tool that can be used to read a file's content.", assistant, user_proxy)
|
||||
|
||||
# TXTSearchTool
|
||||
def autogen_TXTSearchTool(assistant, user_proxy):
|
||||
def register_txt_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(txt: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(txt=txt, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_txt_search_tool(TXTSearchTool, "txt_search_tool", "Search a txt's content(search_query: 'string', txt: 'string') - A tool that can be used to semantic search a query from a txt's content.", assistant, user_proxy)
|
||||
|
||||
def autogen_JSONSearchTool(assistant, user_proxy):
|
||||
def register_json_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(json_path: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(json_path=json_path, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_json_search_tool(JSONSearchTool, "json_search_tool", "Search a JSON's content(search_query: 'string', json_path: 'string') - A tool that can be used to semantic search a query from a JSON's content.", assistant, user_proxy)
|
||||
|
||||
def autogen_MDXSearchTool(assistant, user_proxy):
|
||||
def register_mdx_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(mdx: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(mdx=mdx, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_mdx_search_tool(MDXSearchTool, "mdx_search_tool", "Search a MDX's content(search_query: 'string', mdx: 'string') - A tool that can be used to semantic search a query from a MDX's content.", assistant, user_proxy)
|
||||
|
||||
def autogen_PDFSearchTool(assistant, user_proxy):
|
||||
def register_pdf_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(pdf: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(pdf=pdf, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_pdf_search_tool(PDFSearchTool, "pdf_search_tool", "Search a PDF's content(search_query: 'string', pdf: 'string') - A tool that can be used to semantic search a query from a PDF's content.", assistant, user_proxy)
|
||||
|
||||
def autogen_RagTool(assistant, user_proxy):
|
||||
def register_rag_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(query: str, data: Any) -> Any:
|
||||
tool_instance = tool_class(query=query, data=data)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_rag_tool(RagTool, "rag_tool", "Knowledge base(query: 'string', data: Any) - A knowledge base that can be used to answer questions.", assistant, user_proxy)
|
||||
|
||||
def autogen_ScrapeElementFromWebsiteTool(assistant, user_proxy):
|
||||
def register_scrape_element_from_website_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(website_url: str, element_query: str) -> Any:
|
||||
tool_instance = tool_class(website_url=website_url, element_query=element_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_scrape_element_from_website_tool(ScrapeElementFromWebsiteTool, "scrape_element_from_website_tool", "Scrape an element from a website(element_query: 'string', website_url: 'string') - A tool that can be used to scrape an element from a website.", assistant, user_proxy)
|
||||
|
||||
def autogen_ScrapeWebsiteTool(assistant, user_proxy):
|
||||
def register_scrape_website_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(website_url: str) -> Any:
|
||||
tool_instance = tool_class(website_url=website_url)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_scrape_website_tool(ScrapeWebsiteTool, "scrape_website_tool", "Read website content(website_url: 'string') - A tool that can be used to read content from a specified website.", assistant, user_proxy)
|
||||
|
||||
def autogen_WebsiteSearchTool(assistant, user_proxy):
|
||||
def register_website_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(website: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(website=website, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_website_search_tool(WebsiteSearchTool, "website_search_tool", "Search in a specific website(search_query: 'string', website: 'string') - A tool that can be used to semantic search a query from a specific URL content.", assistant, user_proxy)
|
||||
|
||||
def autogen_XMLSearchTool(assistant, user_proxy):
|
||||
def register_xml_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(xml: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(xml=xml, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_xml_search_tool(XMLSearchTool, "xml_search_tool", "Search a XML's content(search_query: 'string', xml: 'string') - A tool that can be used to semantic search a query from a XML's content.", assistant, user_proxy)
|
||||
|
||||
def autogen_YoutubeChannelSearchTool(assistant, user_proxy):
|
||||
def register_youtube_channel_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(youtube_channel_handle: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(youtube_channel_handle=youtube_channel_handle, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_youtube_channel_search_tool(YoutubeChannelSearchTool, "youtube_channel_search_tool", "Search a Youtube Channels content(search_query: 'string', youtube_channel_handle: 'string') - A tool that can be used to semantic search a query from a Youtube Channels content.", assistant, user_proxy)
|
||||
|
||||
def autogen_YoutubeVideoSearchTool(assistant, user_proxy):
|
||||
def register_youtube_video_search_tool(tool_class, tool_name, tool_description, assistant, user_proxy):
|
||||
def tool_func(youtube_video_url: str, search_query: str) -> Any:
|
||||
tool_instance = tool_class(youtube_video_url=youtube_video_url, search_query=search_query)
|
||||
return tool_instance.run()
|
||||
register_function(tool_func, caller=assistant, executor=user_proxy, name=tool_name, description=tool_description)
|
||||
register_youtube_video_search_tool(YoutubeVideoSearchTool, "youtube_video_search_tool", "Search a Youtube Video content(search_query: 'string', youtube_video_url: 'string') - A tool that can be used to semantic search a query from a Youtube Video content.", assistant, user_proxy)
|
||||
@@ -0,0 +1,146 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any, Callable, Optional, Type
|
||||
|
||||
from langchain_core.tools import StructuredTool
|
||||
from pydantic import BaseModel, ConfigDict, Field, validator
|
||||
from pydantic.v1 import BaseModel as V1BaseModel
|
||||
|
||||
|
||||
class BaseTool(BaseModel, ABC):
|
||||
class _ArgsSchemaPlaceholder(V1BaseModel):
|
||||
pass
|
||||
|
||||
model_config = ConfigDict()
|
||||
|
||||
name: str
|
||||
"""The unique name of the tool that clearly communicates its purpose."""
|
||||
description: str
|
||||
"""Used to tell the model how/when/why to use the tool."""
|
||||
args_schema: Type[V1BaseModel] = Field(default_factory=_ArgsSchemaPlaceholder)
|
||||
"""The schema for the arguments that the tool accepts."""
|
||||
description_updated: bool = False
|
||||
"""Flag to check if the description has been updated."""
|
||||
cache_function: Optional[Callable] = lambda _args, _result: True
|
||||
"""Function that will be used to determine if the tool should be cached, should return a boolean. If None, the tool will be cached."""
|
||||
|
||||
@validator("args_schema", always=True, pre=True)
|
||||
def _default_args_schema(cls, v: Type[V1BaseModel]) -> Type[V1BaseModel]:
|
||||
if not isinstance(v, cls._ArgsSchemaPlaceholder):
|
||||
return v
|
||||
|
||||
return type(
|
||||
f"{cls.__name__}Schema",
|
||||
(V1BaseModel,),
|
||||
{
|
||||
"__annotations__": {
|
||||
k: v for k, v in cls._run.__annotations__.items() if k != "return"
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
def model_post_init(self, __context: Any) -> None:
|
||||
self._generate_description()
|
||||
|
||||
super().model_post_init(__context)
|
||||
|
||||
def run(
|
||||
self,
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
) -> Any:
|
||||
print(f"Using Tool: {self.name}")
|
||||
return self._run(*args, **kwargs)
|
||||
|
||||
@abstractmethod
|
||||
def _run(
|
||||
self,
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
) -> Any:
|
||||
"""Here goes the actual implementation of the tool."""
|
||||
|
||||
def to_langchain(self) -> StructuredTool:
|
||||
self._set_args_schema()
|
||||
return StructuredTool(
|
||||
name=self.name,
|
||||
description=self.description,
|
||||
args_schema=self.args_schema,
|
||||
func=self._run,
|
||||
)
|
||||
|
||||
def _set_args_schema(self):
|
||||
if self.args_schema is None:
|
||||
class_name = f"{self.__class__.__name__}Schema"
|
||||
self.args_schema = type(
|
||||
class_name,
|
||||
(V1BaseModel,),
|
||||
{
|
||||
"__annotations__": {
|
||||
k: v
|
||||
for k, v in self._run.__annotations__.items()
|
||||
if k != "return"
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
def _generate_description(self):
|
||||
args = []
|
||||
for arg, attribute in self.args_schema.schema()["properties"].items():
|
||||
if "type" in attribute:
|
||||
args.append(f"{arg}: '{attribute['type']}'")
|
||||
|
||||
description = self.description.replace("\n", " ")
|
||||
self.description = f"{self.name}({', '.join(args)}) - {description}"
|
||||
|
||||
|
||||
class Tool(BaseTool):
|
||||
func: Callable
|
||||
"""The function that will be executed when the tool is called."""
|
||||
|
||||
def _run(self, *args: Any, **kwargs: Any) -> Any:
|
||||
return self.func(*args, **kwargs)
|
||||
|
||||
|
||||
def to_langchain(
|
||||
tools: list[BaseTool | StructuredTool],
|
||||
) -> list[StructuredTool]:
|
||||
return [t.to_langchain() if isinstance(t, BaseTool) else t for t in tools]
|
||||
|
||||
|
||||
def tool(*args):
|
||||
"""
|
||||
Decorator to create a tool from a function.
|
||||
"""
|
||||
|
||||
def _make_with_name(tool_name: str) -> Callable:
|
||||
def _make_tool(f: Callable) -> BaseTool:
|
||||
if f.__doc__ is None:
|
||||
raise ValueError("Function must have a docstring")
|
||||
if f.__annotations__ is None:
|
||||
raise ValueError("Function must have type annotations")
|
||||
|
||||
class_name = "".join(tool_name.split()).title()
|
||||
args_schema = type(
|
||||
class_name,
|
||||
(V1BaseModel,),
|
||||
{
|
||||
"__annotations__": {
|
||||
k: v for k, v in f.__annotations__.items() if k != "return"
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return Tool(
|
||||
name=tool_name,
|
||||
description=f.__doc__,
|
||||
func=f,
|
||||
args_schema=args_schema,
|
||||
)
|
||||
|
||||
return _make_tool
|
||||
|
||||
if len(args) == 1 and callable(args[0]):
|
||||
return _make_with_name(args[0].__name__)(args[0])
|
||||
if len(args) == 1 and isinstance(args[0], str):
|
||||
return _make_with_name(args[0])
|
||||
raise ValueError("Invalid arguments")
|
||||
@@ -0,0 +1,116 @@
|
||||
from crewai_tools import (
|
||||
CodeDocsSearchTool, CSVSearchTool, DirectorySearchTool, DOCXSearchTool, DirectoryReadTool,
|
||||
FileReadTool, TXTSearchTool, JSONSearchTool, MDXSearchTool, PDFSearchTool, RagTool,
|
||||
ScrapeElementFromWebsiteTool, ScrapeWebsiteTool, WebsiteSearchTool, XMLSearchTool, YoutubeChannelSearchTool,
|
||||
YoutubeVideoSearchTool
|
||||
)
|
||||
import inspect
|
||||
|
||||
# Assuming the tool classes are imported correctly as in the original request
|
||||
|
||||
tools_classes = {
|
||||
'CodeDocsSearchTool': CodeDocsSearchTool,
|
||||
'CSVSearchTool': CSVSearchTool,
|
||||
'DirectorySearchTool': DirectorySearchTool,
|
||||
'DOCXSearchTool': DOCXSearchTool,
|
||||
'DirectoryReadTool': DirectoryReadTool,
|
||||
'FileReadTool': FileReadTool,
|
||||
'TXTSearchTool': TXTSearchTool,
|
||||
'JSONSearchTool': JSONSearchTool,
|
||||
'MDXSearchTool': MDXSearchTool,
|
||||
'PDFSearchTool': PDFSearchTool,
|
||||
'RagTool': RagTool,
|
||||
'ScrapeElementFromWebsiteTool': ScrapeElementFromWebsiteTool,
|
||||
'ScrapeWebsiteTool': ScrapeWebsiteTool,
|
||||
'WebsiteSearchTool': WebsiteSearchTool,
|
||||
'XMLSearchTool': XMLSearchTool,
|
||||
'YoutubeChannelSearchTool': YoutubeChannelSearchTool,
|
||||
'YoutubeVideoSearchTool': YoutubeVideoSearchTool,
|
||||
}
|
||||
|
||||
for tool_name, tool_class in tools_classes.items():
|
||||
# Inspect the constructor (__init__) to get its parameters, excluding 'self'
|
||||
constructor_params = inspect.signature(tool_class.__init__).parameters
|
||||
param_names = [p for p in constructor_params if p != 'self']
|
||||
|
||||
# Attempt to instantiate the tool with dummy or default values for parameters
|
||||
try:
|
||||
# Creating a dummy parameters dict with None or empty values based on parameter name
|
||||
dummy_params = {param: None if param != 'website_url' else 'http://example.com' for param in param_names}
|
||||
instance = tool_class(**dummy_params)
|
||||
tool_description = getattr(instance, "description", "No description attribute")
|
||||
except Exception as e:
|
||||
tool_description = f"Error instantiating tool for description extraction: {str(e)}"
|
||||
|
||||
# Printing tool class name, its constructor parameters, and description
|
||||
print(f"Tool Class: {tool_name}")
|
||||
print(f"Constructor Parameters: {', '.join(param_names)}")
|
||||
print(f"Description: {tool_description}\n")
|
||||
|
||||
# Tool Class: CodeDocsSearchTool
|
||||
# Constructor Parameters: docs_url, kwargs
|
||||
# Description: Search a Code Docs content(search_query: 'string', docs_url: 'string') - A tool that can be used to semantic search a query from a Code Docs content.
|
||||
|
||||
# Tool Class: CSVSearchTool
|
||||
# Constructor Parameters: csv, kwargs
|
||||
# Description: Search a CSV's content(search_query: 'string', csv: 'string') - A tool that can be used to semantic search a query from a CSV's content.
|
||||
|
||||
# Tool Class: DirectorySearchTool
|
||||
# Constructor Parameters: directory, kwargs
|
||||
# Description: Search a directory's content(search_query: 'string', directory: 'string') - A tool that can be used to semantic search a query from a directory's content.
|
||||
|
||||
# Tool Class: DOCXSearchTool
|
||||
# Constructor Parameters: docx, kwargs
|
||||
# Description: Search a DOCX's content(search_query: 'string', docx: 'string') - A tool that can be used to semantic search a query from a DOCX's content.
|
||||
|
||||
# Tool Class: DirectoryReadTool
|
||||
# Constructor Parameters: directory, kwargs
|
||||
# Description: List files in directory(directory: 'string') - A tool that can be used to recursively list a directory's content.
|
||||
|
||||
# Tool Class: FileReadTool
|
||||
# Constructor Parameters: file_path, kwargs
|
||||
# Description: Read a file's content(file_path: 'string') - A tool that can be used to read a file's content.
|
||||
|
||||
# Tool Class: TXTSearchTool
|
||||
# Constructor Parameters: txt, kwargs
|
||||
# Description: Search a txt's content(search_query: 'string', txt: 'string') - A tool that can be used to semantic search a query from a txt's content.
|
||||
|
||||
# Tool Class: JSONSearchTool
|
||||
# Constructor Parameters: json_path, kwargs
|
||||
# Description: Search a JSON's content(search_query: 'string', json_path: 'string') - A tool that can be used to semantic search a query from a JSON's content.
|
||||
|
||||
# Tool Class: MDXSearchTool
|
||||
# Constructor Parameters: mdx, kwargs
|
||||
# Description: Search a MDX's content(search_query: 'string', mdx: 'string') - A tool that can be used to semantic search a query from a MDX's content.
|
||||
|
||||
# Tool Class: PDFSearchTool
|
||||
# Constructor Parameters: pdf, kwargs
|
||||
# Description: Search a PDF's content(query: 'string', pdf: 'string') - A tool that can be used to semantic search a query from a PDF's content.
|
||||
|
||||
# Tool Class: RagTool
|
||||
# Constructor Parameters: data
|
||||
# Description: Knowledge base(query: 'string') - A knowledge base that can be used to answer questions.
|
||||
|
||||
# Tool Class: ScrapeElementFromWebsiteTool
|
||||
# Constructor Parameters: website_url, cookies, css_element, kwargs
|
||||
# Description: Read a website content() - A tool that can be used to read http://example.com's content.
|
||||
|
||||
# Tool Class: ScrapeWebsiteTool
|
||||
# Constructor Parameters: website_url, cookies, kwargs
|
||||
# Description: Read website content() - A tool that can be used to read http://example.com's content.
|
||||
|
||||
# Tool Class: WebsiteSearchTool
|
||||
# Constructor Parameters: website, kwargs
|
||||
# Description: Search in a specific website(search_query: 'string', website: 'string') - A tool that can be used to semantic search a query from a specific URL content.
|
||||
|
||||
# Tool Class: XMLSearchTool
|
||||
# Constructor Parameters: xml, kwargs
|
||||
# Description: Search a XML's content(search_query: 'string', xml: 'string') - A tool that can be used to semantic search a query from a XML's content.
|
||||
|
||||
# Tool Class: YoutubeChannelSearchTool
|
||||
# Constructor Parameters: youtube_channel_handle, kwargs
|
||||
# Description: Search a Youtube Channels content(search_query: 'string', youtube_channel_handle: 'string') - A tool that can be used to semantic search a query from a Youtube Channels content.
|
||||
|
||||
# Tool Class: YoutubeVideoSearchTool
|
||||
# Constructor Parameters: youtube_video_url, kwargs
|
||||
# Description: Search a Youtube Video content(search_query: 'string', youtube_video_url: 'string') - A tool that can be used to semantic search a query from a Youtube Video content.
|
||||
@@ -0,0 +1,38 @@
|
||||
from typing import Any, Optional
|
||||
import os
|
||||
from autogen import ConversableAgent
|
||||
from scrape_website_tool.scrape_website_tool import ScrapeWebsiteTool
|
||||
|
||||
assistant = ConversableAgent(
|
||||
name="Assistant",
|
||||
system_message="You are a helpful AI assistant. "
|
||||
"You can help with website scraping. "
|
||||
"Return 'TERMINATE' when the task is done.",
|
||||
llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
||||
)
|
||||
|
||||
user_proxy = ConversableAgent(
|
||||
name="User",
|
||||
llm_config=False,
|
||||
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
||||
human_input_mode="NEVER",
|
||||
)
|
||||
|
||||
from autogen import register_function
|
||||
from typing import Any
|
||||
|
||||
def register_tool(tool_class, tool_name, tool_description):
|
||||
def tool_func(website_url: str) -> Any:
|
||||
tool_instance = tool_class(website_url=website_url)
|
||||
return tool_instance.run()
|
||||
|
||||
register_function(
|
||||
tool_func,
|
||||
caller=assistant, # The assistant agent can suggest calls to the tool.
|
||||
executor=user_proxy, # The user proxy agent can execute the tool calls.
|
||||
name=tool_name, # By default, the function name is used as the tool name.
|
||||
description=tool_description, # A description of the tool.
|
||||
)
|
||||
register_tool(ScrapeWebsiteTool, "scrape_website_tool", "A tool for scraping specific websites")
|
||||
|
||||
chat_result = user_proxy.initiate_chat(assistant, message="Scrape the official Nodejs website.")
|
||||
@@ -0,0 +1,44 @@
|
||||
from typing import Annotated, Literal
|
||||
import os
|
||||
from autogen import ConversableAgent
|
||||
|
||||
Operator = Literal["+", "-", "*", "/"]
|
||||
|
||||
def calculator(a: int, b: int, operator: Annotated[Operator, "operator"]) -> int:
|
||||
if operator == "+":
|
||||
return a + b
|
||||
elif operator == "-":
|
||||
return a - b
|
||||
elif operator == "*":
|
||||
return a * b
|
||||
elif operator == "/":
|
||||
return int(a / b)
|
||||
else:
|
||||
raise ValueError("Invalid operator")
|
||||
|
||||
assistant = ConversableAgent(
|
||||
name="Assistant",
|
||||
system_message="You are a helpful AI assistant. "
|
||||
"You can help with simple calculations. "
|
||||
"Return 'TERMINATE' when the task is done.",
|
||||
llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
||||
)
|
||||
|
||||
user_proxy = ConversableAgent(
|
||||
name="User",
|
||||
llm_config=False,
|
||||
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
||||
human_input_mode="NEVER",
|
||||
)
|
||||
|
||||
from autogen import register_function
|
||||
# Register the calculator function to the agent and user proxy to add a calculator tool.
|
||||
register_function(
|
||||
calculator,
|
||||
caller=assistant, # The assistant agent can suggest calls to the calculator.
|
||||
executor=user_proxy, # The user proxy agent can execute the calculator calls.
|
||||
name="calculator", # By default, the function name is used as the tool name.
|
||||
description="A simple calculator", # A description of the tool.
|
||||
)
|
||||
|
||||
chat_result = user_proxy.initiate_chat(assistant, message="What is (44232 + 13312 / (232 - 32)) * 5?")
|
||||
@@ -0,0 +1,35 @@
|
||||
from typing import Any, Optional
|
||||
import os
|
||||
from autogen import ConversableAgent
|
||||
from scrape_website_tool.scrape_website_tool import ScrapeWebsiteTool
|
||||
|
||||
def scrape_website_tool(website_url: str) -> Any:
|
||||
scrape_tool = ScrapeWebsiteTool(website_url=website_url)
|
||||
return scrape_tool.run()
|
||||
|
||||
assistant = ConversableAgent(
|
||||
name="Assistant",
|
||||
system_message="You are a helpful AI assistant. "
|
||||
"You can help with website scraping. "
|
||||
"Return 'TERMINATE' when the task is done.",
|
||||
llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
||||
)
|
||||
|
||||
user_proxy = ConversableAgent(
|
||||
name="User",
|
||||
llm_config=False,
|
||||
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
||||
human_input_mode="NEVER",
|
||||
)
|
||||
|
||||
from autogen import register_function
|
||||
# Register the ScrapeWebsiteTool function to the agent and user proxy to add a website scraping tool.
|
||||
register_function(
|
||||
scrape_website_tool,
|
||||
caller=assistant, # The assistant agent can suggest calls to the scrape website tool.
|
||||
executor=user_proxy, # The user proxy agent can execute the scrape website tool calls.
|
||||
name="scrape_website_tool", # By default, the function name is used as the tool name.
|
||||
description="A tool for scraping specific websites", # A description of the tool.
|
||||
)
|
||||
|
||||
chat_result = user_proxy.initiate_chat(assistant, message="Scrape the official Python website.")
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import Any, Optional
|
||||
import os
|
||||
from autogen import ConversableAgent
|
||||
from autogen_tools import autogen_ScrapeWebsiteTool
|
||||
|
||||
assistant = ConversableAgent(
|
||||
name="Assistant",
|
||||
system_message="You are a helpful AI assistant. "
|
||||
"You can help with website scraping. "
|
||||
"Return 'TERMINATE' when the task is done.",
|
||||
llm_config={"config_list": [{"model": "gpt-3.5-turbo", "api_key": os.environ["OPENAI_API_KEY"]}]},
|
||||
)
|
||||
|
||||
user_proxy = ConversableAgent(
|
||||
name="User",
|
||||
llm_config=False,
|
||||
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
|
||||
human_input_mode="NEVER",
|
||||
)
|
||||
|
||||
autogen_ScrapeWebsiteTool(assistant, user_proxy)
|
||||
|
||||
chat_result = user_proxy.initiate_chat(assistant, message="Scrape the official Nodejs website.")
|
||||
@@ -0,0 +1,134 @@
|
||||
|
||||
import os
|
||||
from crewai import Agent, Task, Crew
|
||||
from crewai_tools import (
|
||||
DirectoryReadTool,
|
||||
FileReadTool,
|
||||
SerperDevTool,
|
||||
WebsiteSearchTool
|
||||
)
|
||||
|
||||
os.environ["SERPER_API_KEY"] = "Your Key"
|
||||
os.environ["OPENAI_API_KEY"] = "Your Key"
|
||||
|
||||
docs_tool = DirectoryReadTool(directory='./blog-posts')
|
||||
file_tool = FileReadTool()
|
||||
search_tool = SerperDevTool()
|
||||
web_rag_tool = WebsiteSearchTool()
|
||||
|
||||
researcher = Agent(
|
||||
role='Market Research Analyst',
|
||||
goal='Provide up-to-date market analysis of the AI industry',
|
||||
backstory='An expert analyst with a keen eye for market trends.',
|
||||
tools=[search_tool, web_rag_tool],
|
||||
verbose=True
|
||||
)
|
||||
|
||||
writer = Agent(
|
||||
role='Content Writer',
|
||||
goal='Craft engaging blog posts about the AI industry',
|
||||
backstory='A skilled writer with a passion for technology.',
|
||||
tools=[docs_tool, file_tool],
|
||||
verbose=True
|
||||
)
|
||||
|
||||
research = Task(
|
||||
description='Research the latest trends in the AI industry and provide a summary.',
|
||||
expected_output='A summary of the top 3 trending developments in the AI industry with a unique perspective on their significance.',
|
||||
agent=researcher
|
||||
)
|
||||
|
||||
write = Task(
|
||||
description='Write an engaging blog post about the AI industry, based on the research analyst\'s summary. Draw inspiration from the latest blog posts in the directory.',
|
||||
expected_output='A 4-paragraph blog post formatted in markdown with engaging, informative, and accessible content, avoiding complex jargon.',
|
||||
agent=writer,
|
||||
output_file='blog-posts/new_post.md'
|
||||
)
|
||||
|
||||
crew = Crew(
|
||||
agents=[researcher, writer],
|
||||
tasks=[research, write],
|
||||
verbose=2
|
||||
)
|
||||
|
||||
crew.kickoff()
|
||||
|
||||
from crewai_tools import DirectoryReadTool
|
||||
|
||||
tool = DirectoryReadTool()
|
||||
|
||||
toos = DirectoryReadTool(directory='./directory')
|
||||
|
||||
from crewai_tools import BaseTool
|
||||
|
||||
class MyCustomTool(BaseTool):
|
||||
name: str = "Name of my tool"
|
||||
description: str = "Clear description for what this tool is useful for, you agent will need this information to use it."
|
||||
|
||||
def _run(self, argument: str) -> str:
|
||||
return "Result from custom tool"
|
||||
|
||||
from crewai_tools import tool
|
||||
|
||||
@tool("Name of my tool")
|
||||
def my_tool(question: str) -> str:
|
||||
return "Result from my tool"
|
||||
|
||||
import json
|
||||
import requests
|
||||
from crewai import Agent
|
||||
from crewai.tools import tool
|
||||
from unstructured.partition.html import partition_html
|
||||
|
||||
@tool("Integration with a given API")
|
||||
def integration_tool(argument: str) -> str:
|
||||
return "Results from integration tool"
|
||||
|
||||
agent = Agent(
|
||||
role='Research Analyst',
|
||||
goal='Provide up-to-date market analysis',
|
||||
backstory='An expert analyst with a keen eye for market trends.',
|
||||
tools=[integration_tool]
|
||||
)
|
||||
|
||||
from crewai import Agent
|
||||
from langchain.agents import Tool
|
||||
from langchain.utilities import GoogleSerperAPIWrapper
|
||||
|
||||
os.environ["SERPER_API_KEY"] = "Your Key"
|
||||
|
||||
search = GoogleSerperAPIWrapper()
|
||||
|
||||
serper_tool = Tool(
|
||||
name="Intermediate Answer",
|
||||
func=search.run,
|
||||
description="Useful for search-based queries",
|
||||
)
|
||||
|
||||
agent = Agent(
|
||||
role='Research Analyst',
|
||||
goal='Provide up-to-date market analysis',
|
||||
backstory='An expert analyst with a keen eye for market trends.',
|
||||
tools=[serper_tool]
|
||||
)
|
||||
# Tool Description
|
||||
# CodeDocsSearchTool A RAG tool optimized for searching through code documentation and related technical documents.
|
||||
# CSVSearchTool A RAG tool designed for searching within CSV files, tailored to handle structured data.
|
||||
# DirectorySearchTool A RAG tool for searching within directories, useful for navigating through file systems.
|
||||
# DOCXSearchTool A RAG tool aimed at searching within DOCX documents, ideal for processing Word files.
|
||||
# DirectoryReadTool Facilitates reading and processing of directory structures and their contents.
|
||||
# FileReadTool Enables reading and extracting data from files, supporting various file formats.
|
||||
# GithubSearchTool A RAG tool for searching within GitHub repositories, useful for code and documentation search.
|
||||
# SeperDevTool A specialized tool for development purposes, with specific functionalities under development.
|
||||
# TXTSearchTool A RAG tool focused on searching within text (.txt) files, suitable for unstructured data.
|
||||
# JSONSearchTool A RAG tool designed for searching within JSON files, catering to structured data handling.
|
||||
# MDXSearchTool A RAG tool tailored for searching within Markdown (MDX) files, useful for documentation.
|
||||
# PDFSearchTool A RAG tool aimed at searching within PDF documents, ideal for processing scanned documents.
|
||||
# PGSearchTool A RAG tool optimized for searching within PostgreSQL databases, suitable for database queries.
|
||||
# RagTool A general-purpose RAG tool capable of handling various data sources and types.
|
||||
# ScrapeElementFromWebsiteTool Enables scraping specific elements from websites, useful for targeted data extraction.
|
||||
# ScrapeWebsiteTool Facilitates scraping entire websites, ideal for comprehensive data collection.
|
||||
# WebsiteSearchTool A RAG tool for searching website content, optimized for web data extraction.
|
||||
# XMLSearchTool A RAG tool designed for searching within XML files, suitable for structured data formats.
|
||||
# YoutubeChannelSearchTool A RAG tool for searching within YouTube channels, useful for video content analysis.
|
||||
# YoutubeVideoSearchTool A RAG tool aimed at searching within YouTube videos, ideal for video data extraction.
|
||||
@@ -0,0 +1 @@
|
||||
__version__ = "0.0.1"
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.8 KiB |
@@ -1,43 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB |
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||
@@ -0,0 +1,35 @@
|
||||
[tool.poetry]
|
||||
name = "praisonAI"
|
||||
version = "0.0.18"
|
||||
description = "praisonAI application combines AutoGen and CrewAI or similar frameworks into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration."
|
||||
authors = ["Mervin Praison"]
|
||||
license = ""
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.urls]
|
||||
Homepage = "https://github.com/mervinpraison/praisonAI"
|
||||
Repository = "https://github.com/mervinpraison/praisonAI"
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["praisonAI"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.10,<3.13"
|
||||
rich = ">=13.7"
|
||||
pyautogen = ">=0.2.19"
|
||||
crewai = ">=0.22.5"
|
||||
gradio = ">=4.20.0"
|
||||
Flask = ">=3.0.0"
|
||||
markdown = ">=3.5"
|
||||
crewai-tools = "^0.1.1"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^8.0.0"
|
||||
pre-commit = "^3.7"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
praisonai = "praisonai.__main__:main"
|
||||
@@ -0,0 +1,4 @@
|
||||
rich>=13.7
|
||||
pyautogen>=0.2.19
|
||||
crewai>=0.22.5
|
||||
gradio>=4.20.0
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
import React from 'react';
|
||||
import './App.css';
|
||||
import SettingsForm from './SettingsForm'; // Import the SettingsForm component
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="App">
|
||||
<SettingsForm /> {/* Render the SettingsForm component */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -1,8 +0,0 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import App from './App';
|
||||
|
||||
test('renders learn react link', () => {
|
||||
render(<App />);
|
||||
const linkElement = screen.getByText(/learn react/i);
|
||||
expect(linkElement).toBeInTheDocument();
|
||||
});
|
||||
@@ -1,112 +0,0 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Container,
|
||||
FormControl,
|
||||
FormLabel,
|
||||
Input,
|
||||
Button,
|
||||
VStack,
|
||||
} from '@chakra-ui/react';
|
||||
|
||||
// Mocking wpApiSettings for development purposes. This should be replaced with the actual object provided by WordPress in production.
|
||||
const wpApiSettings = { nonce: 'dev-nonce' }; // This line is added to mock the wpApiSettings object
|
||||
|
||||
const SettingsForm = () => {
|
||||
const [patreonClientId, setPatreonClientId] = useState('');
|
||||
const [patreonClientSecret, setPatreonClientSecret] = useState('');
|
||||
const [youtubeApiKey, setYoutubeApiKey] = useState('');
|
||||
const [file, setFile] = useState(null);
|
||||
|
||||
const handleSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
// Handle the submission logic here
|
||||
// This will involve saving the API credentials to the WordPress database
|
||||
// For now, we'll log the credentials to the console
|
||||
console.log({
|
||||
patreonClientId,
|
||||
patreonClientSecret,
|
||||
youtubeApiKey,
|
||||
});
|
||||
// TODO: Implement API call to save these settings in WordPress
|
||||
};
|
||||
|
||||
const handleFileChange = (event) => {
|
||||
setFile(event.target.files[0]);
|
||||
};
|
||||
|
||||
const handleFileUpload = async (event) => {
|
||||
event.preventDefault();
|
||||
if (file) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
try {
|
||||
const response = await fetch('/wp-json/patreon-youtube/v1/upload_media', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-WP-Nonce': wpApiSettings.nonce,
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('File uploaded successfully:', result);
|
||||
// TODO: Handle the successful upload (e.g., display a success message, clear the form, etc.)
|
||||
} catch (error) {
|
||||
console.error('File upload error:', error);
|
||||
// TODO: Handle the upload error (e.g., display an error message to the user)
|
||||
}
|
||||
} else {
|
||||
console.error('No file selected');
|
||||
// TODO: Inform the user that no file was selected
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<VStack spacing={4}>
|
||||
<FormControl id="patreon-client-id">
|
||||
<FormLabel>Patreon Client ID</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={patreonClientId}
|
||||
onChange={(e) => setPatreonClientId(e.target.value)}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl id="patreon-client-secret">
|
||||
<FormLabel>Patreon Client Secret</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={patreonClientSecret}
|
||||
onChange={(e) => setPatreonClientSecret(e.target.value)}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl id="youtube-api-key">
|
||||
<FormLabel>YouTube API Key</FormLabel>
|
||||
<Input
|
||||
type="text"
|
||||
value={youtubeApiKey}
|
||||
onChange={(e) => setYoutubeApiKey(e.target.value)}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl id="file-upload">
|
||||
<FormLabel>Upload Media</FormLabel>
|
||||
<Input
|
||||
type="file"
|
||||
onChange={handleFileChange}
|
||||
/>
|
||||
<Button onClick={handleFileUpload} colorScheme="blue">Upload</Button>
|
||||
</FormControl>
|
||||
<Button type="submit" colorScheme="blue">Save Settings</Button>
|
||||
</VStack>
|
||||
</form>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingsForm;
|
||||
@@ -1,13 +0,0 @@
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import reportWebVitals from './reportWebVitals';
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
||||
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
@@ -1,13 +0,0 @@
|
||||
const reportWebVitals = onPerfEntry => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry);
|
||||
getFID(onPerfEntry);
|
||||
getFCP(onPerfEntry);
|
||||
getLCP(onPerfEntry);
|
||||
getTTFB(onPerfEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default reportWebVitals;
|
||||
@@ -1,5 +0,0 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check the first argument provided to the script for platform selection
|
||||
if [ "$1" = "groq" ]; then
|
||||
# Check for a second argument for the model name, default to mixtral-8x7b-32768 if not provided
|
||||
MODEL_NAME=${2:-mixtral-8x7b-32768}
|
||||
# Set environment variables for Groq configuration with dynamic model name
|
||||
export OPENAI_MODEL_NAME=$MODEL_NAME
|
||||
export OPENAI_API_BASE=https://api.groq.com/openai/v1
|
||||
export OPENAI_API_KEY=$(echo $GROQ_API_KEY)
|
||||
echo "Groq configuration initiated with model $MODEL_NAME."
|
||||
elif [ "$1" = "openai" ] || [ -z "$1" ]; then
|
||||
# Check for a second argument for the model name, default to gpt-3.5-turbo if not provided
|
||||
MODEL_NAME=${2:-gpt-3.5-turbo}
|
||||
# Set environment variables for OpenAI configuration with dynamic model name
|
||||
export OPENAI_MODEL_NAME=$MODEL_NAME
|
||||
export OPENAI_API_BASE=https://api.openai.com/v1
|
||||
export OPENAI_API_KEY=$(echo $OAI_API_KEY)
|
||||
echo "OpenAI configuration initiated with model $MODEL_NAME."
|
||||
fi
|
||||
Whitespace-only changes.
@@ -0,0 +1,11 @@
|
||||
from praisonai import PraisonAI
|
||||
|
||||
def advanced():
|
||||
praison_ai = PraisonAI(
|
||||
agent_file="agents.yaml",
|
||||
framework="autogen",
|
||||
)
|
||||
praison_ai.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
advanced()
|
||||
@@ -0,0 +1,41 @@
|
||||
framework: "crewai"
|
||||
topic: "Artificial Intelligence"
|
||||
|
||||
roles:
|
||||
narrative_designer:
|
||||
role: "Narrative Designer"
|
||||
goal: "Craft engaging storylines and narratives for {topic}"
|
||||
backstory: >
|
||||
You're a creative visionary skilled in weaving complex narratives and
|
||||
developing engaging story worlds within {topic}. Your expertise lies in
|
||||
conceptualizing the overarching story and ensuring it resonates with the audience.
|
||||
tasks:
|
||||
story_concept_development:
|
||||
description: >
|
||||
Develop a compelling story concept for {topic}, focusing on originality,
|
||||
thematic depth, and audience engagement. Outline the main narrative arcs,
|
||||
characters, and settings.
|
||||
expected_output: >
|
||||
A comprehensive document outlining the story concept, including key narrative
|
||||
arcs, character bios, and settings descriptions.
|
||||
|
||||
scriptwriter:
|
||||
role: "Scriptwriter"
|
||||
goal: "Transform story concepts into detailed scripts for {topic}"
|
||||
backstory: >
|
||||
With a flair for dialogue and a deep understanding of pacing and structure,
|
||||
you excel at bringing narratives to life through scriptwriting. Your work
|
||||
turns story concepts into blueprints for compelling {topic} experiences.
|
||||
tasks:
|
||||
scriptwriting_task:
|
||||
description: >
|
||||
Based on the narrative concept, write a detailed script for {topic}.
|
||||
Include dialogue, stage directions, and scene descriptions that bring
|
||||
the story to life.
|
||||
expected_output: >
|
||||
A detailed script ready for production, including dialogue, stage
|
||||
directions, and scene descriptions.
|
||||
|
||||
dependencies:
|
||||
- task: scriptwriting_task
|
||||
depends_on: story_concept_development
|
||||
@@ -0,0 +1,12 @@
|
||||
from praisonai import PraisonAI
|
||||
|
||||
def auto():
|
||||
praison_ai = PraisonAI(
|
||||
auto="Create a movie script about car in mars",
|
||||
framework="autogen"
|
||||
)
|
||||
print(praison_ai.framework)
|
||||
praison_ai.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
auto()
|
||||
@@ -0,0 +1,41 @@
|
||||
framework: "autogen"
|
||||
topic: "Artificial Intelligence"
|
||||
|
||||
roles:
|
||||
narrative_designer:
|
||||
role: "Narrative Designer"
|
||||
goal: "Craft engaging storylines and narratives for {topic}"
|
||||
backstory: >
|
||||
You're a creative visionary skilled in weaving complex narratives and
|
||||
developing engaging story worlds within {topic}. Your expertise lies in
|
||||
conceptualizing the overarching story and ensuring it resonates with the audience.
|
||||
tasks:
|
||||
story_concept_development:
|
||||
description: >
|
||||
Develop a compelling story concept for {topic}, focusing on originality,
|
||||
thematic depth, and audience engagement. Outline the main narrative arcs,
|
||||
characters, and settings.
|
||||
expected_output: >
|
||||
A comprehensive document outlining the story concept, including key narrative
|
||||
arcs, character bios, and settings descriptions.
|
||||
|
||||
scriptwriter:
|
||||
role: "Scriptwriter"
|
||||
goal: "Transform story concepts into detailed scripts for {topic}"
|
||||
backstory: >
|
||||
With a flair for dialogue and a deep understanding of pacing and structure,
|
||||
you excel at bringing narratives to life through scriptwriting. Your work
|
||||
turns story concepts into blueprints for compelling {topic} experiences.
|
||||
tasks:
|
||||
scriptwriting_task:
|
||||
description: >
|
||||
Based on the narrative concept, write a detailed script for {topic}.
|
||||
Include dialogue, stage directions, and scene descriptions that bring
|
||||
the story to life.
|
||||
expected_output: >
|
||||
A detailed script ready for production, including dialogue, stage
|
||||
directions, and scene descriptions.
|
||||
|
||||
dependencies:
|
||||
- task: scriptwriting_task
|
||||
depends_on: story_concept_development
|
||||
@@ -0,0 +1,8 @@
|
||||
from praisonai import PraisonAI
|
||||
|
||||
def main():
|
||||
praison_ai = PraisonAI(agent_file="agents.yaml")
|
||||
praison_ai.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,41 @@
|
||||
framework: "crewai"
|
||||
topic: "Artificial Intelligence"
|
||||
|
||||
roles:
|
||||
narrative_designer:
|
||||
role: "Narrative Designer"
|
||||
goal: "Craft engaging storylines and narratives for {topic}"
|
||||
backstory: >
|
||||
You're a creative visionary skilled in weaving complex narratives and
|
||||
developing engaging story worlds within {topic}. Your expertise lies in
|
||||
conceptualizing the overarching story and ensuring it resonates with the audience.
|
||||
tasks:
|
||||
story_concept_development:
|
||||
description: >
|
||||
Develop a compelling story concept for {topic}, focusing on originality,
|
||||
thematic depth, and audience engagement. Outline the main narrative arcs,
|
||||
characters, and settings.
|
||||
expected_output: >
|
||||
A comprehensive document outlining the story concept, including key narrative
|
||||
arcs, character bios, and settings descriptions.
|
||||
|
||||
scriptwriter:
|
||||
role: "Scriptwriter"
|
||||
goal: "Transform story concepts into detailed scripts for {topic}"
|
||||
backstory: >
|
||||
With a flair for dialogue and a deep understanding of pacing and structure,
|
||||
you excel at bringing narratives to life through scriptwriting. Your work
|
||||
turns story concepts into blueprints for compelling {topic} experiences.
|
||||
tasks:
|
||||
scriptwriting_task:
|
||||
description: >
|
||||
Based on the narrative concept, write a detailed script for {topic}.
|
||||
Include dialogue, stage directions, and scene descriptions that bring
|
||||
the story to life.
|
||||
expected_output: >
|
||||
A detailed script ready for production, including dialogue, stage
|
||||
directions, and scene descriptions.
|
||||
|
||||
dependencies:
|
||||
- task: scriptwriting_task
|
||||
depends_on: story_concept_development
|
||||
@@ -0,0 +1,21 @@
|
||||
# tests/debug.py
|
||||
import tracemalloc
|
||||
import logging
|
||||
import warnings
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
# Enable Tracemalloc
|
||||
tracemalloc.start()
|
||||
|
||||
# Configure Logging
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s - %(lineno)d - %(message)s')
|
||||
|
||||
# Function to Log Warnings with Traceback
|
||||
def warn_with_traceback(message, category, filename, lineno, file=None, line=None):
|
||||
log = file if hasattr(file, 'write') else sys.stderr
|
||||
traceback.print_stack(file=log)
|
||||
log.write(warnings.formatwarning(message, category, filename, lineno, line))
|
||||
|
||||
# Override showwarning
|
||||
warnings.showwarning = warn_with_traceback
|
||||
@@ -0,0 +1,47 @@
|
||||
# tests/test.py
|
||||
# from .debug import * # Uncomment this line to import the debug.py file for debugging
|
||||
import unittest
|
||||
import os
|
||||
from praisonai.cli import PraisonAI
|
||||
from .advanced_example import advanced
|
||||
from .basic_example import main
|
||||
from .auto_example import auto
|
||||
|
||||
class TestGenerateCrewAndKickoff(unittest.TestCase):
|
||||
def test_generate_crew_and_kickoff_with_autogen_framework(self):
|
||||
praison_ai = PraisonAI(agent_file='tests/autogen-agents.yaml')
|
||||
result = praison_ai.generate_crew_and_kickoff()
|
||||
# Assert the result
|
||||
self.assertIn('### Task Output ###', result)
|
||||
|
||||
def test_generate_crew_and_kickoff_with_custom_framework(self):
|
||||
praison_ai = PraisonAI(agent_file='tests/crewai-agents.yaml')
|
||||
result = praison_ai.generate_crew_and_kickoff()
|
||||
# Assert the result
|
||||
self.assertIn('### Task Output ###', result)
|
||||
class TestPraisonAICommand(unittest.TestCase):
|
||||
def test_praisonai_command(self):
|
||||
command = "praisonai --framework autogen --auto create movie script about cat in mars"
|
||||
result = os.popen(command).read()
|
||||
self.assertIn('### Task Output ###', result)
|
||||
|
||||
class TestPraisonAIInitCommand(unittest.TestCase):
|
||||
def test_praisonai_init_command(self):
|
||||
command = "praisonai --framework autogen --init create movie script about cat in mars"
|
||||
result = os.popen(command).read()
|
||||
self.assertIn('### Task Output ###', result)
|
||||
|
||||
class TestBasicExample(unittest.TestCase):
|
||||
def test_basic_example(self):
|
||||
main()
|
||||
|
||||
class TestAdvancedExample(unittest.TestCase):
|
||||
def test_advanced_example(self):
|
||||
advanced()
|
||||
|
||||
class TestAutoExample(unittest.TestCase):
|
||||
def test_auto_example(self):
|
||||
auto()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,8 @@
|
||||
from duckduckgo_search import DDGS
|
||||
|
||||
@tool("Internet Search Tool")
|
||||
def internet_search_tool(query: str) -> list:
|
||||
"""Search Internet for relevant information based on a query."""
|
||||
ddgs = DDGS()
|
||||
results = ddgs.text(keywords=query, region='wt-wt', safesearch='moderate', max_results=5)
|
||||
return results
|
||||
Reference in new issue
Block a user