Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First commit for microchain agent #52

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 190 additions & 1 deletion poetry.lock

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

11 changes: 5 additions & 6 deletions prediction_market_agent/agents/general_agent/deploy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dotenv import load_dotenv

load_dotenv()
from prediction_market_agent_tooling.deploy.agent import DeployableAgent
from prediction_market_agent_tooling.markets.agent_market import AgentMarket
Expand All @@ -16,16 +17,14 @@ class DeployableGeneralAgentAgent(DeployableAgent):
agent = GeneralAgent()

def run(self, market_type: MarketType, _place_bet: bool = True) -> None:
print (f"Agent {self.__class__} starting")
print(f"Agent {self.__class__} starting")
self.agent.run()
print (f"Agent {self.__class__} finishing")
print(f"Agent {self.__class__} finishing")


if __name__ == "__main__":
load_dotenv()
agent = DeployableGeneralAgentAgent()
agent.deploy_local(
market_type=MarketType.OMEN,
sleep_time=60,
timeout=540,
place_bet=False
market_type=MarketType.OMEN, sleep_time=60, timeout=540, place_bet=False
)
19 changes: 10 additions & 9 deletions prediction_market_agent/agents/general_agent/general_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from crewai import Agent, Task, Process, Crew
from crewai import Agent, Crew, Process, Task
from crewai_tools import BaseTool

from prediction_market_agent.agents.abstract import AbstractAgent
from prediction_market_agent.agents.general_agent.omen_functions import GetBinaryMarketsTool
from prediction_market_agent.agents.general_agent.omen_functions import (
GetBinaryMarketsTool,
)


class GeneralAgent(AbstractAgent):
Expand All @@ -15,8 +18,7 @@ def __init__(self) -> None:
tools=self.get_tools(),
)


def run(self):
def run(self) -> None:
"""
Method where agent should reason and execute actions on Omen.
"""
Expand All @@ -26,18 +28,17 @@ def run(self):
tasks=[task],
process=Process.sequential, # Optional: Sequential task execution is default
)
result = crew.kickoff(inputs={'topic': 'AI in healthcare'})
result = crew.kickoff(inputs={"topic": "AI in healthcare"})
print(result)


def get_tools(self):
def get_tools(self) -> list[BaseTool]:
return [GetBinaryMarketsTool()]

def prepare_task(self) -> Task:
return Task(
description=(
"Find 1 or more markets on Omen that you could place bets on."
),
expected_output='A list of 1 or more markets, only displaying the market title.',
expected_output="A list of 1 or more markets, only displaying the market title.",
agent=self.gambler,
)
)
15 changes: 10 additions & 5 deletions prediction_market_agent/agents/general_agent/omen_functions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import sys
import typing as t

from crewai_tools import BaseTool
from prediction_market_agent_tooling.markets.agent_market import AgentMarket, FilterBy
from prediction_market_agent_tooling.markets.markets import get_binary_markets, MarketType
from prediction_market_agent_tooling.markets.markets import (
MarketType,
get_binary_markets,
)


# ToDo - Add filters as arguments to this function call, add it to description.
class GetBinaryMarketsTool(BaseTool):
name: str = "Tool for fetching binary markets"
description: str = "This tool returns all the markets on the prediction market platform Omen."
description: str = (
"This tool returns all the markets on the prediction market platform Omen."
)

def _run(self) -> list[AgentMarket]:
# Implementation goes here
Expand All @@ -19,6 +24,6 @@ def _run(self) -> list[AgentMarket]:
)
return markets

def cache_function(self, args, result) -> bool:
def cache_function(self, args: list[t.Any], result: t.Any) -> bool:
# ToDo - implement caching if result was > 1 and depending on filter.
return False
return False
Loading
Loading