-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
530 additions
and
492 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
prediction_market_agent/agents/microchain_agent/jobs_functions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import json | ||
|
||
from microchain import Function | ||
from prediction_market_agent_tooling.jobs.jobs import get_jobs | ||
from prediction_market_agent_tooling.markets.data_models import Currency | ||
from prediction_market_agent_tooling.markets.markets import MarketType | ||
|
||
from prediction_market_agent.utils import APIKeys | ||
|
||
|
||
class JobFunction(Function): | ||
def __init__(self, market_type: MarketType, keys: APIKeys) -> None: | ||
self.keys = keys | ||
self.market_type = market_type | ||
super().__init__() | ||
|
||
@property | ||
def currency(self) -> Currency: | ||
return self.market_type.market_class.currency | ||
|
||
|
||
class GetJobs(JobFunction): | ||
@property | ||
def description(self) -> str: | ||
return f"""Use this function to get available jobs in a JSON dumped format. | ||
You need to provide max bond value in {self.currency}, that is, how much you are willing to bond on the fact that you completed the job as required in the job description. | ||
""" | ||
|
||
@property | ||
def example_args(self) -> list[int]: | ||
return [10] | ||
|
||
def __call__(self, max_bond: float) -> str: | ||
jobs = get_jobs(self.market_type, limit=None) | ||
return json.dumps( | ||
[j.to_simple_job(max_bond=max_bond).model_dump() for j in jobs], | ||
indent=2, | ||
default=str, | ||
) | ||
|
||
|
||
JOB_FUNCTIONS: list[type[JobFunction]] = [ | ||
GetJobs, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters