Skip to content

Commit

Permalink
Add isort and run on repo
Browse files Browse the repository at this point in the history
  • Loading branch information
evangriffiths committed Feb 15, 2024
1 parent abe9311 commit 7dec7d0
Show file tree
Hide file tree
Showing 19 changed files with 86 additions and 64 deletions.
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions prediction_market_agent/agents/all_agents.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import typing as t
from enum import Enum

from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent.agents.langchain_agent import LangChainAgent
from prediction_market_agent.agents.autogen_agent import AutoGenAgent
from prediction_market_agent.agents.always_yes import AlwaysYesAgent
from prediction_market_agent.agents.llamaindex_agent import LlamaIndexAgent
from prediction_market_agent.agents.metagpt_agent import MetaGPTAgent
from prediction_market_agent.agents.autogen_agent import AutoGenAgent
from prediction_market_agent.agents.crewai_agent import CrewAIAgent
from prediction_market_agent.agents.custom_agent import (
CustomAgentOpenAi,
CustomAgentLlama,
CustomAgentOpenAi,
)
from prediction_market_agent.agents.langchain_agent import LangChainAgent
from prediction_market_agent.agents.llamaindex_agent import LlamaIndexAgent
from prediction_market_agent.agents.metagpt_agent import MetaGPTAgent


class AgentType(str, Enum):
Expand Down
3 changes: 2 additions & 1 deletion prediction_market_agent/agents/always_yes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent_tooling.markets.data_models import AgentMarket

from prediction_market_agent.agents.abstract import AbstractAgent


class AlwaysYesAgent(AbstractAgent):
"""
Expand Down
4 changes: 2 additions & 2 deletions prediction_market_agent/agents/autogen_agent.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import autogen
import re
import typing as t

import autogen
from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent
from prediction_market_agent_tooling.markets.data_models import AgentMarket

from prediction_market_agent import utils
from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent.tools.google_search import GoogleSearchTool
from prediction_market_agent.tools.web_scrape import WebScrapingTool
from prediction_market_agent_tooling.markets.data_models import AgentMarket


class AutoGenAgent(AbstractAgent):
Expand Down
7 changes: 4 additions & 3 deletions prediction_market_agent/agents/crewai_agent.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent_tooling.markets.data_models import AgentMarket

from langchain_community.tools import DuckDuckGoSearchRun
from prediction_market_agent_tooling.markets.data_models import AgentMarket

from prediction_market_agent.agents.abstract import AbstractAgent

# TODO can use langchain's @tool decorator on our own tool methods to create a
# tool useable by a crew agent
Expand Down Expand Up @@ -32,7 +33,7 @@ def __init__(self) -> None:
)

def answer_binary_market(self, market: AgentMarket) -> bool:
from crewai import Task, Crew
from crewai import Crew, Task

task1 = Task(
description=(
Expand Down
18 changes: 10 additions & 8 deletions prediction_market_agent/agents/custom_agent.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import json
import requests
from typing import Optional

import requests
from prediction_market_agent_tooling.markets.data_models import AgentMarket
from prediction_market_agent_tooling.tools.utils import (
check_not_none,
should_not_happen,
)

from prediction_market_agent import utils
from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent.ai_models.abstract_ai_models import (
Message,
AbstractAiChatModel,
Message,
)
from prediction_market_agent.ai_models.llama_ai_models import ChatReplicateLLamaModel
from prediction_market_agent.ai_models.openai_ai_models import ChatOpenAIModel
from prediction_market_agent.tools.google_search import google_search
from prediction_market_agent.tools.tool_exception_handler import tool_exception_handler
from prediction_market_agent.tools.web_scrape_structured import (
web_scrape_structured_and_summarized,
)
from prediction_market_agent.tools.tool_exception_handler import tool_exception_handler
from prediction_market_agent_tooling.tools.utils import (
check_not_none,
should_not_happen,
)
from prediction_market_agent_tooling.markets.data_models import AgentMarket


class CustomAgent(AbstractAgent):
Expand Down
6 changes: 2 additions & 4 deletions prediction_market_agent/agents/langchain_agent.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.agents import AgentType, initialize_agent, load_tools
from langchain_community.llms import OpenAI
from prediction_market_agent_tooling.markets.data_models import AgentMarket

from prediction_market_agent import utils
from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent_tooling.markets.data_models import AgentMarket


class LangChainAgent(AbstractAgent):
Expand Down
4 changes: 2 additions & 2 deletions prediction_market_agent/agents/llamaindex_agent.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from llama_index.agent import OpenAIAgent
from llama_index.llms import OpenAI
from llama_index.tools import FunctionTool
from prediction_market_agent_tooling.markets.data_models import AgentMarket

from prediction_market_agent import utils
from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent.tools.google_search import google_search
from prediction_market_agent.tools.web_scrape import web_scrape
from prediction_market_agent import utils
from prediction_market_agent_tooling.markets.data_models import AgentMarket


class LlamaIndexAgent(AbstractAgent):
Expand Down
7 changes: 4 additions & 3 deletions prediction_market_agent/agents/metagpt_agent.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import asyncio
import dotenv
import json
import os

from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent_tooling.tools.utils import check_not_none
import dotenv
from prediction_market_agent_tooling.markets.data_models import AgentMarket
from prediction_market_agent_tooling.tools.utils import check_not_none

from prediction_market_agent.agents.abstract import AbstractAgent


class MetaGPTAgent(AbstractAgent):
Expand Down
1 change: 1 addition & 0 deletions prediction_market_agent/ai_models/abstract_ai_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Optional

from pydantic import BaseModel


Expand Down
10 changes: 6 additions & 4 deletions prediction_market_agent/ai_models/llama_ai_models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from enum import Enum
from typing import Literal, Optional

import replicate
from prediction_market_agent_tooling.tools.utils import should_not_happen

from prediction_market_agent.ai_models.abstract_ai_models import (
AbstractAiChatModel,
Message,
)
from enum import Enum
from typing import Optional, Literal
from prediction_market_agent_tooling.tools.utils import should_not_happen
import replicate


class LlamaRole(Enum):
Expand Down
12 changes: 7 additions & 5 deletions prediction_market_agent/ai_models/openai_ai_models.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from prediction_market_agent.ai_models.abstract_ai_models import (
AbstractAiChatModel,
Message,
)
from enum import Enum
from typing import Literal, Optional

from openai import OpenAI
from typing import Optional, Literal
from openai.types.chat.chat_completion import ChatCompletion
from openai.types.chat.chat_completion_message_param import (
ChatCompletionMessageParam,
ChatCompletionSystemMessageParam,
ChatCompletionUserMessageParam,
)

from prediction_market_agent.ai_models.abstract_ai_models import (
AbstractAiChatModel,
Message,
)

ROLE_KEY = "role"
CONTENT_KEY = "content"

Expand Down
24 changes: 10 additions & 14 deletions prediction_market_agent/tools/betting_strategies.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import typing as t
from decimal import Decimal
from functools import reduce
import numpy as np
import typing as t
from web3 import Web3
from prediction_market_agent_tooling.markets.data_models import (
BetAmount,
Currency,
)

import numpy as np
from prediction_market_agent_tooling.gtypes import Probability, wei_type, xDai
from prediction_market_agent_tooling.markets.data_models import BetAmount, Currency
from prediction_market_agent_tooling.markets.markets import MarketType
from prediction_market_agent_tooling.markets.omen import (
omen_calculate_buy_amount,
OmenMarket,
omen_calculate_buy_amount,
)
from prediction_market_agent_tooling.markets.markets import MarketType
from prediction_market_agent_tooling.tools.gnosis_rpc import GNOSIS_RPC_URL
from prediction_market_agent_tooling.tools.utils import check_not_none
from prediction_market_agent_tooling.tools.web3_utils import (
xdai_to_wei,
wei_to_xdai,
ONE_XDAI,
wei_to_xdai,
xdai_to_wei,
)
from prediction_market_agent_tooling.gtypes import Probability, xDai, wei_type
from prediction_market_agent_tooling.tools.utils import check_not_none

from web3 import Web3

OutcomeIndex = t.Literal[0, 1]

Expand Down
3 changes: 1 addition & 2 deletions prediction_market_agent/tools/web_scrape.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import bs4
import requests

from langchain.chains.summarize import load_summarize_chain
from langchain_openai import ChatOpenAI
from langchain.prompts import PromptTemplate
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_openai import ChatOpenAI


def _summary(objective: str, content: str) -> str:
Expand Down
1 change: 1 addition & 0 deletions prediction_market_agent/tools/web_scrape_structured.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requests
from bs4 import BeautifulSoup, Comment, Tag

from prediction_market_agent.tools.web_scrape import _summary


Expand Down
3 changes: 2 additions & 1 deletion prediction_market_agent/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import typing as t

from prediction_market_agent_tooling.config import APIKeys as APIKeysBase
from prediction_market_agent_tooling.tools.utils import (
check_not_none,
should_not_happen,
)
from prediction_market_agent_tooling.config import APIKeys as APIKeysBase


class APIKeys(APIKeysBase):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ cron-validator = "^1.0.8"
prediction-market-agent-tooling = { git = "https://github.com/gnosis/prediction-market-agent-tooling.git", branch = "peter/fix-apikeys" }
pydantic-settings = "^2.1.0"
autoflake = "^2.2.1"
isort = "^5.13.2"

[build-system]
requires = ["poetry-core"]
Expand Down
4 changes: 2 additions & 2 deletions tests/ai_models/test_llama_ai_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from prediction_market_agent.ai_models.llama_ai_models import (
construct_llama_prompt,
Message,
LlamaRole,
Message,
construct_llama_prompt,
)


Expand Down
15 changes: 8 additions & 7 deletions tests/tools/test_betting_strategies.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import pytest
import numpy as np
from prediction_market_agent_tooling.markets.markets import omen
import pytest
from prediction_market_agent_tooling.gtypes import (
Probability,
xdai_type,
wei_type,
usd_type,
HexAddress,
OmenOutcomeToken,
HexStr,
OmenOutcomeToken,
Probability,
Wei,
usd_type,
wei_type,
xDai,
xdai_type,
)
from prediction_market_agent_tooling.markets.markets import omen

from prediction_market_agent.tools.betting_strategies import (
get_kelly_criterion_bet,
get_market_moving_bet,
Expand Down

0 comments on commit 7dec7d0

Please sign in to comment.