Skip to content

a simple api to run an orchestrated, autonomous, multi-agent system for analyzing economic and fiscal policy (FastAPI + CrewAI)

Notifications You must be signed in to change notification settings

jkaunert/policy-wonks-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

POLICY-WONKS-API

Empowering Policy Insights Through Collaborative Intelligence

license last-commit repo-top-language repo-language-count


Table of Contents


Overview

The policy-wonks-api project addresses the challenge of analyzing economic and fiscal policies by leveraging AI-driven insights. Key features include a collaborative multi-agent system for policy evaluation, user-friendly API endpoints, and robust data management. Targeted at policymakers, economists, and analysts, it enhances decision-making through informed, data-backed assessments.


Features

Feature Summary
βš™οΈ Architecture
  • Utilizes a microservices architecture with a focus on modularity and separation of concerns.
  • Built on the Python programming language, leveraging frameworks like CrewAI for multi-agent collaboration.
  • Employs Docker for containerization, ensuring consistent environments across development and production.
πŸ”© Code Quality
  • Follows best practices in coding standards and style, enhancing readability and maintainability.
  • Utilizes type hints and structured data models for clarity in data handling.
  • Regular code reviews and adherence to a version control system ensure high-quality contributions.
πŸ“„ Documentation
  • Comprehensive documentation is provided, including setup instructions and usage examples.
  • Utilizes Markdown for easy readability and accessibility.
  • Includes detailed comments within the codebase to explain complex logic and functionality.
πŸ”Œ Integrations
  • Integrates with external AI models such as Jamba and Llama for advanced natural language processing tasks.
  • Supports data persistence through SQLite for efficient data management.
  • Utilizes Docker for seamless deployment and integration with CI/CD pipelines.
🧩 Modularity
  • Structured into distinct modules, each responsible for specific functionalities (e.g., models, agents, tasks).
  • Encourages reusability of components across different parts of the application.
  • Facilitates easy updates and maintenance by isolating changes to individual modules.
πŸ§ͺ Testing
  • Includes unit tests to ensure individual components function as expected.
  • Encourages test-driven development (TDD) practices to enhance reliability.
  • Utilizes mocking and stubbing techniques for testing interactions with external services.
⚑️ Performance
  • Optimized for performance with efficient data handling and processing techniques.
  • Utilizes asynchronous programming where applicable to enhance responsiveness.
  • Employs caching strategies to reduce database load and improve response times.
πŸ›‘οΈ Security
  • Implements secure handling of sensitive data, including API keys and user information.
  • Regular security audits and updates to dependencies to mitigate vulnerabilities.
  • Utilizes environment variables for configuration to prevent hardcoding sensitive information.

Project Structure

└── policy-wonks-api/
    β”œβ”€β”€ Dockerfile
    β”œβ”€β”€ README.md
    β”œβ”€β”€ db
    β”‚   β”œβ”€β”€ chroma.sqlite3
    β”‚   └── e7ff8a0b-e613-4d01-814d-cd82b1795e23
    β”œβ”€β”€ knowledge
    β”‚   └── user_preference.txt
    β”œβ”€β”€ pyproject.toml
    β”œβ”€β”€ src
    β”‚   └── policy_wonks
    └── uv.lock

Project Index

**`POLICY-WONKS-API/`**
**root**
**[Dockerfile](https://github.com/jkaunert/policy-wonks-api/blob/master/Dockerfile)** \- Facilitates the containerization of a Python application by establishing a lightweight environment using a slim Python image \- It integrates the UV tool for dependency management and ensures the application is ready for execution \- By setting the working directory and environment variables, it streamlines the deployment process, allowing the app to run efficiently on a specified host and port.
**[pyproject.toml](https://github.com/jkaunert/policy-wonks-api/blob/master/pyproject.toml)** \- Defines the project configuration for "policy\_wonks," a tool leveraging crewAI to facilitate policy analysis and management \- It specifies essential metadata, dependencies, and scripts for various functionalities such as running, training, and testing the application \- This foundational setup ensures compatibility with Python versions 3.10 to 3.13 and establishes the build system, enabling seamless integration and deployment within the broader codebase architecture.
**knowledge**
**[user\_preference.txt](https://github.com/jkaunert/policy-wonks-api/blob/master/knowledge/user_preference.txt)** \- Captures user preferences and background information, specifically tailored for an AI Engineer named John Doe \- This data serves to personalize interactions within the project, enhancing user experience by aligning features and recommendations with the user's interests in AI Agents \- It plays a crucial role in the overall architecture by facilitating targeted content and functionality based on user profiles.
**db**
**[chroma.sqlite3](https://github.com/jkaunert/policy-wonks-api/blob/master/db/chroma.sqlite3)** \- The code file located at \`db/chroma.sqlite3\` serves as a database for the project, specifically utilizing SQLite as its storage engine \- Its primary purpose is to manage and persist data efficiently within the overall architecture of the codebase \- This database file is integral to the project's functionality, enabling the storage, retrieval, and manipulation of data that the application relies on \- By providing a structured way to handle data, it supports the project's objectives and enhances its performance and scalability.
**e7ff8a0b-e613-4d01-814d-cd82b1795e23**
**[link\_lists.bin](https://github.com/jkaunert/policy-wonks-api/blob/master/db/e7ff8a0b-e613-4d01-814d-cd82b1795e23/link_lists.bin)** \- Facilitates the storage and retrieval of linked list data structures within the project’s database \- By managing serialized binary representations, it enhances data persistence and efficiency, allowing other components of the codebase to access and manipulate linked lists seamlessly \- This functionality is crucial for maintaining the integrity and performance of the overall architecture.
**[header.bin](https://github.com/jkaunert/policy-wonks-api/blob/master/db/e7ff8a0b-e613-4d01-814d-cd82b1795e23/header.bin)** \- Facilitates the storage and retrieval of header information within the database architecture, ensuring efficient data management and integrity \- This component plays a crucial role in maintaining the overall structure and accessibility of data, contributing to the seamless operation of the project by enabling quick access to essential metadata associated with stored records.
**src**
**policy_wonks**
**[models.py](https://github.com/jkaunert/policy-wonks-api/blob/master/src/policy_wonks/models.py)** \- Defines data models for handling requests and responses related to economic policy analysis \- The PolicyWonksRequest model captures key topics and economic variables for evaluation by an economist and a financial analyst, while the PolicyWonksResponse model structures their respective outputs \- This facilitates clear communication and data management within the broader architecture of the project, enhancing the interaction between different components focused on economic policy insights.
**[crew.py](https://github.com/jkaunert/policy-wonks-api/blob/master/src/policy_wonks/crew.py)** \- Defines the PolicyWonks crew, orchestrating a collaborative environment for agents specializing in economics and financial analysis \- It configures agents with specific models and tools, establishes tasks for each role, and integrates them into a cohesive crew that utilizes advanced language models for planning and execution \- This structure enhances the project's capability to address complex policy-related inquiries effectively.
**[app.py](https://github.com/jkaunert/policy-wonks-api/blob/master/src/policy_wonks/app.py)** \- Facilitates the Policy Wonks API, an orchestrated multi-agent system designed for analyzing economic and fiscal policies using the CrewAI framework \- It enables users to submit policy topics and economic variables, triggering a collaborative analysis from both an economist and a financial analyst \- The API also includes health-check and welcome endpoints, ensuring robust interaction and user engagement with the system.
**[main.py](https://github.com/jkaunert/policy-wonks-api/blob/master/src/policy_wonks/main.py)** \- Facilitates the execution and management of policy simulations within the project \- It allows users to run simulations, train models with specified iterations, replay past executions, and test outcomes based on economic variables and policy topics \- This functionality is essential for analyzing the impact of different policies, thereby enhancing decision-making processes in economic contexts.
**[llm\_config.py](https://github.com/jkaunert/policy-wonks-api/blob/master/src/policy_wonks/llm_config.py)** \- Configuration of various language models is achieved, enabling the project to leverage advanced AI capabilities \- By integrating models such as Jamba and Llama, the architecture supports diverse natural language processing tasks \- Utilizing environment variables for API keys ensures secure access to these models, facilitating seamless interactions with the inference service and enhancing the overall functionality of the codebase.
**config**
**[agents.yaml](https://github.com/jkaunert/policy-wonks-api/blob/master/src/policy_wonks/config/agents.yaml)** \- Defines roles and objectives for key economic agents within the project, specifically an economist and a financial analyst \- Each agent is tasked with analyzing the impacts of specific policy topics on economic and financial metrics, providing insights to policymakers and the public \- This structure enhances the overall codebase by facilitating informed decision-making through expert analysis and clear communication of complex concepts.
**[tasks.yaml](https://github.com/jkaunert/policy-wonks-api/blob/master/src/policy_wonks/config/tasks.yaml)** \- Defines tasks for economic analysis within the project, specifically targeting the evaluation of government policies and their market implications \- It outlines roles for an economist and a financial analyst, detailing their responsibilities in providing comprehensive assessments based on specified economic variables \- This structure facilitates informed decision-making for policymakers by ensuring thorough and objective evaluations of economic conditions and policy impacts.

Getting Started

Prerequisites

Before getting started with policy-wonks-api, ensure your runtime environment meets the following requirements:

  • Programming Language: Python 3.12
  • Dependency Management: UV
  • Container Runtime: Docker

Installation

Install policy-wonks-api using one of the following methods:

Build from source:

  1. Clone the policy-wonks-api repository:
❯ git clone https://github.com/jkaunert/policy-wonks-api
  1. Navigate to the project directory:
❯ cd policy-wonks-api
  1. Install the project dependencies:
❯ uv sync

Using docker Β 

❯ DOCKER_BUILDKIT=1 docker build -t {image_name} .

From Docker Hub Β 

❯ docker pull jkaunert/policy-wonks-api-v1:local

Usage

Run policy-wonks-api using the following command: Using docker locally Β 

❯ docker run -p 8000:8000 policy-wonks-api-v1:local

Render Deployment Β 

Policy Wonks API

Project Roadmap

  • Task 1: Upload to Docker Hub.
  • Task 2: Deploy API to Render.
  • Task 3: Deploy Streamlit App.

Contributing

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.

  2. Clone Locally: Clone the forked repository to your local machine using a git client.

    git clone https://github.com/jkaunert/policy-wonks-api
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.

    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.

  5. Commit Your Changes: Commit with a clear message describing your updates.

    git commit -m 'Implemented new feature x.'
  6. Push to github: Push the changes to your forked repository.

    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.

  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!

Contributor Graph
![](https://contrib.rocks/image?repo=jkaunert/policy-wonks-api)

License

This project is protected under the GNU General Public License v3.0 - For more details, refer to the LICENSE page.


Acknowledgments

About

a simple api to run an orchestrated, autonomous, multi-agent system for analyzing economic and fiscal policy (FastAPI + CrewAI)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published