Giter VIP home page Giter VIP logo

citizensfoundation / policy-synth Goto Github PK

View Code? Open in Web Editor NEW
31.0 4.0 4.0 183.1 MB

Policy Synth is a Typescript class library for creating multi-scale AI agent logic flows, API's and state of the art realtime web applications. The drive behind the project is to help governments and citizens make better decisions together by seamlessly integrating collective and artificial intelligence.

Home Page: https://policy-synth.ai

License: MIT License

TypeScript 81.81% JavaScript 16.83% HTML 1.23% Dockerfile 0.11% Shell 0.01%

policy-synth's Introduction

Policy Synth

About

Policy Synth is a Typescript class library for creating multi-scale AI agent logic flows, API's and state of the art, realtime, AI focused web applications.

Paper at ACM Collective Intelligence 2024

Paper: Using Artificial Intelligence to Accelerate Collective Intelligence: Policy Synth and Smarter Crowdsourcing

ACM CI 2024 Program

NPM Modules

The mission & passion behind Policy Synth

Bringing together the best of collective and artificial intelligence

Policy Synth aims to help governments and citizens make better decisions together by seamlessly integrating collective and artificial intelligence. Utilizing our top-rated community engagement solutions, over 50 x LLM agent types, and genetic algorithms. The mission and passion behind Policy Synth represents a distinctive effort to intertwine human insights with artificial intelligence in addressing complex policy dilemmas. We are currently developing a state-of-the-art platform where policymakers, citizens, and AI can partake in collective discourse.

Real life impact

Policy Synth is already having real life impact: https://www.fastcompany.com/91001497/ai-faith-in-democracy

Example Results

Example Policy Synth Multi-Scale Agent Configurations

Smarter Crowdsourcing (Scaling up GovLabs proven methodology)

This agent flow automates and scales GovLabs' crowdsourcing approach to channel expert collective intelligence into actionable policy solutions. It aims to streamline the generation of innovative solutions for complex policy challenges.

Policy Synth v 49

Smarter Crowdsourcing (Preview Policy Synth Agents Operations UI)

image image image image image

Policy Synth Engineer

Policy Synth Engineer is an automated programming tool designed for Typescript projects, utilizing multi scale AI agents to streamline coding tasks such as feature development, bug fixes, and refactoring. It automates extensive web research for coding assistance and is optimized for Typescript due to its syntactical structure and popularity, significantly speeding up programming tasks compared to traditional methods.

PS - Engineer-1

PS - Engineer-2

PS - Engineer-3

PS - Engineer-4

RAG Chatbot

The RAG Chatbot powers the Rebooting Democracy initiative by utilizing hundreds of documents to inform its responses. It serves to engage users effectively by providing well-sourced, context-rich information.

PS - Rebooting Democracy Chatbot-1

PS - Rebooting Democracy Chatbot-2

PS - Rebooting Democracy Chatbot-3

Find Skills-First Policy Barriers (Improve laws & regulation)

This agent flow uses AI to analyze extensive data sets, helping to identify and recommend changes to barriers in skills-first policies in US states. It focuses on enhancing legal frameworks to support skills-based education and employment initiatives.

Skills-First-1

Skills-First AI-2b

Skills-First-3

Integrated with our Top Rated Engagement Tools

Your Priorities

Policy Synth utilizes "Your Priorities", a platform we've been refining since 2008. It's recognized as the world's leading citizen engagement tool.

All Our Ideas

Policy Synth makes use of All Our Ideas, Citizens Foundations open source, human, pairwise voting platform, to provide guidance and input into different AI agents.

All Our Ideas screenshot

Other Tools

Policy Synth is flexible and can work with many other citizen engagment tools, for example Decidim and Consul. As a class based library Policy Synth has no limitations regarding integration with other tools.

Policy Synth AI Agents

About AI Agents

In the context of computational systems, AI agents are autonomous or semi-autonomous entities that interact with digital environments to achieve specific goals or tasks. These agents can range from simple rule-based algorithms to complex systems like Large Language Models (LLMs), capable of processing and generating text and performing simple reasoning. The essence of AI agents lies in their ability to perceive their environment through data, make decisions based on this data, and act upon these decisions to fulfill predefined objectives. In Policy Synth AI agents are used extensively for different tasks.

Fast and Slow Thinking

image

Fast (System 1) and Slow (System 2) thinking, terms popularized by psychologist Daniel Kahneman, offer a useful framework for understanding how AI, especially Large Language Models (LLMs), parallel System 1 thinking, characterized by swift, intuitive cognition without deliberate effort—much like a human's quick calculation of "what is 2+2?". While the best LLMs are also capable of limited form of System 2 thinking then this analogy suggests that LLMs excel in producing responses quickly, leveraging vast databases of information to generate answers that seem instinctive, much as System 1 thinking does for humans in certain contexts. System 2 thinking represents a more deliberate, analytical form of reasoning that humans employ for more complex tasks, such as solving "what is 17*24?" without the aid of calculators. This level of cognitive processing requires significant effort, attention, and mental manipulation of information.

Policy Synth Agent Approach

In contrast to striving for fully autonomous System 2 capabilities with AI, Policy Synth approaches the challenge by manually constructing and integrating System 2 thinking processes through a multi-scale AI agent framework. This methodological choice allows for the deliberate orchestration of AI processes that implement a deeper System 2 thinking by combining specialized agents in a structured manner. Since GPT-4o Policy Synth has introduced Engineer that has limited scope of autonomy in the context of automatic programming.

Example Agent Queue Configuration

Policy Synth v 42a

Draft Developer Guide

Draft Policy Synth Developer Guide

First test run: Democracy in Distress

The first test run is entirely automated, except for the problem statement provided by us. All sub-problems, entities, and solutions—complete with pros and cons—are generated using GPT-4 and GPT-3.5. These models run highly specialized agents that are, at the moment, very basic and therefore reliable, and should not be confused with ongoing, and exciting, LLM autonomous agent experiments. The context for solutions is obtained through curated web searches. This setup allows us to explore how human and AI-driven insights can work together to solve complex problems.

We're also experimenting with genetic algorithms to foster a co-evolution of solutions between AI and citizens. We use large language models to implement random mutations and crossover, creating a vibrant and diverse pool of potential policy solutions. Fitness ranking is performed by both humans and AI, with the human ranking weighting higher.

To further enrich our evolving solution space, we introduce fresh random immigration through solutions acquired via web searches. This process infuses new ideas and perspectives into our evolving policy generation, enhancing its capacity to tackle a wide range of issues.

For the real-world application of our platform, a series of expert and mass citizen crowdsourcing stages will be integrated. These stages are designed to accompany the AI-generated and ranked options. This multifaceted approach combines collective human insights, expert opinions, and machine intelligence. Our model leverages technology to harness collective wisdom, effectively facilitating the development and implementation of well-informed policy decisions.

policy-synth's People

Contributors

rbjarnason avatar stephan-schmidt avatar maxpinheiro avatar ayushpissurlenkar avatar

Stargazers

Keyth M Citizen  avatar  avatar Onur Akdeniz avatar Mahendra Kutare avatar  avatar profsquirrel avatar  avatar Logan Kirkland avatar Gissur @ Skývafnir avatar Stijn Tonk avatar Christiansen MEREL avatar Alexander Kledal avatar  avatar  avatar Artem avatar Teodor Mironov avatar  avatar franklin stewart avatar Chafik HADJ ABDOU RAZACK avatar  avatar  avatar  avatar Vedfolnir (Ketus IX) avatar HuFeiHu avatar James Pether Sörling avatar Parth Kabra avatar Jordan Moshcovitis avatar  avatar  avatar xocu avatar Vincent avatar

Watchers

 avatar Gissur @ Skývafnir avatar  avatar Kostas Georgiou avatar

policy-synth's Issues

Refactor LLM model classes with a new typedef

Task Description
We want to create a new typedef called PsModelChatItem to replace {role:string,message:string}`,

Task Instructions

  1. Add new interface PsModelChatItem {role:string,message:string} to src/streamingLlms.d.ts
  2. Replace {role:string,message:string} with PsModelChatItem in src/models/baseChatModel.ts and src/models/openAiChat.ts, src/models/claudeOpusChat.ts and src/models/googleGeminiChat.ts

Design data types to search for the Root Causes web research agents

Here are two relevant test prompts:
https://chat.openai.com/share/a015bc27-f3e7-42c8-be7d-507cc58c6168
https://chat.openai.com/share/bc62c60f-245f-4d72-9ccd-fd5938e53a65

Here is the evidence search query GPT-4 prompt (in the format the new prompts needs to be in)
https://platform.openai.com/playground/p/qcsfzJ2zNqJKNDa3nhqLosrh

And example GPT-3.5 16k for scanning a website (you'll need to copy paste some text into :
https://platform.openai.com/playground/p/KewOzWddGXxXCjoQPEEOGHeY

Add maxTokensOut property to LLM base modelmodel and use modelName for tiktoken counts where needed

Task Description
Use modelName for Tiktoken token counts in the LLM models classes and add maxTokensOut to base model and constructors of the sub classes

Task Instructions

  1. Change src/models/baseChatModel.ts to add a maxTokensOut string property, as number = 4096 and should be set in the constructor and default to 4096 but the users of sub classes must be able to change it
  2. Change src/models/clauseOpusChat.ts to use maxTokensOut and this.modelName for the Tiktoken encoding_for_model function instead of cl100k_base (as this does not work for gpt-4o and possibly future models)
  3. Change src/models/azureOpenAiChat.ts to use maxTokensOut and this.modelName for the Tiktoken encoding_for_model function instead of cl100k_base
  4. Change src/models/openAiChat.ts to use maxTokensOut and this.modelName for the Tiktoken encoding_for_model function instead of cl100k_base
  5. Change src/models/googleGeminiChat.ts to use maxTokensOut and this.modelName and keep on using the built in Gemini token count method

Add a new LLM model class for OpenAI on Azure

Task Description
We want to add a new model class into src/models/azureOpenAiChat.ts using the @azure/openai npm module.

Task Instructions
Add a new model class in src/models/azureOpenAiChat.ts using the @azure/openai npm module based on src/models/baseChatModel.ts parent class.

Refactor baseAgent.ts class

Task Description
Refactor the baseAgent class for smaller and clearer functions, especially all the JSON parsing in callLlm but also other best practices. Consider if splitting out some functionality into smaller classes, then do that but do not split callLlm into a separate class. The child classes should not have to change and all the code should work exactly the same.

Task Instructions

  1. Refactor the src/models/baseChatModel.ts class but not in a way that requires changes to child classes the extend this class.

Create LLM Abstractions for OpenAI, Claude Opus and Google Gemini with a common base class

Task Description
Create LLM classes for OpenAI, Claude Opus and Google Gemini, with a design that allows easy addition of other models in the future. This is a typescript based es module NodeJS modern server application.

Task Instructions
1. Create a new base chat class src/models/baseChatModel.ts in a new file.
2. Then create src/models/openAiChat.ts, src/models/claudeOpusChat.ts and src/models/googleGeminiChat.ts for chat only
3. For the cloudeOpus use the @anthropic-ai/sdk npm
4. For the googleGemini use the @google/generative-ai npm
5. For the openAi use the openai npm
6. The baseChatModel and the child classes should only implement those two methods:
generate([{role:string,message:string}], streaming: boolean | undefined, streamingCallback: Function | undefined)
getNumTokensFromMessages([{role:string,message:string}])

Update LLM model base class for model name and set default for all LLM models

Task Description
Update src/models/baseChatModel.ts, src/models/clauseOpusChat.ts, src/models/azureOpenAiChat.ts and src/models/openAiChat.ts to use this.modelName

Task Instructions

  1. Change src/models/baseChatModel.ts to add a modelName string attribute string | TiktokenModel and should be set in the constructor
  2. Change src/models/clauseOpusChat.ts to default to "claude-3-opus-20240229" for this.modelName
  3. Change src/models/azureOpenAiChat.ts to default to "gpt-4o"
  4. Change src/models/openAiChat.ts also to default to "gpt-4o"
  5. Change src/models/googleGeminiChat.ts to default to "gemini-pro" for this.modelName in its constructor but use can provide their own, same for the other models

Subclass the evidence GPT3.5 & GPT4 web scanning modules from the policy evidence search and implement the new root causes prompt and datatypes

Those two files:
agentQueue/src/agents/policies/web/getEvidenceWebPages.ts
agentQueue/src/agents/policies/web/getRefinedEvidence.ts

Easiest to start by copying them to:
agentQueue/src/agents/problems/web/getRootCausesWebPages.ts
agentQueue/src/agents/problems/web/getRefinedRootCauses.ts

Then remove all the common methods and override methods for the Root Causes logic and data types.

Also copy the evidencExamplePrompts.ts over to the problems/web folder and modify based on your data types with one-shot example for GPT3.5 16k
(hint: You can use GPT-4 in the OpenAI Playground or ChatGPT 4 to create the examples)

Refine prompt example:
https://platform.openai.com/playground/p/hMFPbfsAPafVw5vihG29sqER?model=gpt-4

Convert AI Model classes constructors to take typedefed config objects

Task Description
We've created those constructor model options typedefs:
interface PSModelConfig {
apiKey: string;
modelName?: string;
maxTokensOut?: number;
};

interface PSAzureModelConfig extends PSModelConfig {
endpoint: string;
deploymentName: string;
};

interface PSOpenAiModelConfig extends PSModelConfig {
projectId?: string;
};

We need to change the underlying models but we can keep the base class the same do not change it.

Task Instructions

  1. Change src/models/clauseOpusChat.ts to use new options instead of function parameters and setup the rest of function in best possible way
  2. Change src/models/azureOpenAiChat.ts to use new options instead of function parameters and setup the rest of function in best possible way
  3. Change src/models/openAiChat.ts to use new options instead of function parameters and setup the rest of function in best possible way
  4. Change src/models/googleGeminiChat.ts to use new options instead of function parameters and setup the rest of function in best possible way

Improve getNumTokensFromMessages in Policy Synth src/model classes

Task Description
Update src/models/clauseOpusChat.ts, src/models/azureOpenAiChat.ts and src/models/openAiChat.ts to use a more effective token count mechanism for the getNumTokensFromMessages method
Task Instructions

  1. Change src/models/clauseOpusChat.ts to use something else than just characters, maybe use tiktoken or something?
  2. Change src/models/azureOpenAiChat.ts to use something else than calling the api
  3. Change src/models/openAiChat.ts also to use something else than calling the api

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.