Skip to content

gnosis/prediction-market-agent

Repository files navigation

Prediction Market Trader Agent

A library for exploring the landscape of AI Agent frameworks, using the example application of a prediction market betting agent. The various agents interact with markets from Manifold, AIOmen and Polymarket.

These agents build on top of the prediction market APIs from https://github.com/gnosis/prediction-market-agent-tooling.

Setup

Install the project dependencies with poetry, using Python >=3.10:

python3.10 -m pip install poetry
python3.10 -m poetry install
python3.10 -m poetry shell

Create a .env file in the root of the repo with the following variables:

MANIFOLD_API_KEY=...
BET_FROM_PRIVATE_KEY=...
OPENAI_API_KEY=...

Depending on the agent you want to run, you may require additional variables. See an exhaustive list in .env.example.

Interactive Streamlit Apps

  • An autonomous agent with function calling. Can be 'prodded' by the user to guide its strategy: streamlit run prediction_market_agent/agents/microchain_agent/app.py (Deployed here)
  • Pick a prediction market question, or create your own, and pick one or more agents to perform research and make a prediction: streamlit run scripts/agent_app.py (Deployed here)

Dune Dashboard

The on-chain activity of the deployed agents from this repo can be tracked on a Dune dashboard here.

Running (deprecated see #211)

Execute main.py with optional arguments:

% python main.py --help
 Usage: main.py [OPTIONS]                                                                    

 Picks one market and answers it, optionally placing a bet.                                  

╭─ Options ─────────────────────────────────────────────────────────────────────────────────╮
│ --market-type                     [manifold|omen|polymarket]  [default: manifold]         │
│ --agent-type                      [langchain|autogen|always_  [default: always_yes]       │
│                                   yes|llamaindex|metagpt|cre                              │
│                                   wai|custom_openai|custom_l                              │
│                                   lama]                                                   │
│ --auto-bet       --no-auto-bet                                [default: no-auto-bet]      │
│ --help                                                        Show this message and exit. |
╰───────────────────────────────────────────────────────────────────────────────────────────╯

Deploying

To deploy an agent to google cloud, see the example in examples/cloud_deployment.

Requires the gcloud cli (see here), and auth to have been completed (i.e. gcloud auth login).

Frameworks implemented

Framework Notes
LangChain Wraps OpenAI function calling API. Equips single agent with tools, makes calls in while loop. Has library of built-in tools, or can make own. Can extend using Python Repl tool to execute ad-hoc generated code.
LlamaIndex Similar to LangChain. Tool library from llama_hub. No tool to execute ad-hoc generated code.
MetaGPT Advertised as a framework for building an agent-based software dev team, but can be general purpose. Can do single-agent or multi-agent (as a Team) execution. Has many predefined agent Roles, pre-equipped with relevant tools.
AutoGen Multi-agent. Can use local model. Easy to explicitly control the execution pattern of the agents. GPTAssistantAgent class wraps the OpenAI Assistant API.
crewAI Similar to AutoGen, except agents<->task mapping is only 1-1 currently. Agents tackly distinct tasks in series. Can use local model (Ollama integration). Agent tool integration with LangChain, so can use its existing tool library.

Contributing

See the Issues for ideas of things that need fixing or implementing. The team is also receptive to new issues and PRs.

An great self-contained first contribution would be to implement an agent using a framework in the 'Other frameworks to try' issue.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages