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

469 missing information in ipfsagentresult #521

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion prediction_market_agent_tooling/deploy/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ def update_langfuse_trace_by_processed_market(
]
)

@property
def agent_name(self) -> str:
return self.__class__.__name__

def check_min_required_balance_to_operate(self, market_type: MarketType) -> None:
api_keys = APIKeys()

Expand Down Expand Up @@ -492,7 +496,9 @@ def after_process_market(
processed_market: ProcessedMarket,
) -> None:
keys = APIKeys()
market.store_prediction(processed_market=processed_market, keys=keys)
market.store_prediction(
processed_market=processed_market, keys=keys, agent_name=self.agent_name
)

def before_process_markets(self, market_type: MarketType) -> None:
"""
Expand Down
5 changes: 4 additions & 1 deletion prediction_market_agent_tooling/markets/agent_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ def verify_operational_balance(api_keys: APIKeys) -> bool:
raise NotImplementedError("Subclasses must implement this method")

def store_prediction(
self, processed_market: ProcessedMarket, keys: APIKeys
self,
processed_market: ProcessedMarket,
keys: APIKeys,
agent_name: str,
) -> None:
"""
If market allows to upload predictions somewhere, implement it in this method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def from_tuple(values: tuple[t.Any]) -> "ContractPrediction":

class IPFSAgentResult(BaseModel):
reasoning: str

agent_name: str
model_config = ConfigDict(
extra="forbid",
)
23 changes: 13 additions & 10 deletions prediction_market_agent_tooling/markets/omen/omen.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
ConditionPreparationEvent,
ContractPrediction,
CreatedMarket,
IPFSAgentResult,
OmenBet,
OmenMarket,
OmenUserPosition,
get_bet_outcome,
get_boolean_outcome,
IPFSAgentResult,
)
from prediction_market_agent_tooling.markets.omen.omen_contracts import (
OMEN_DEFAULT_MARKET_FEE_PERC,
Expand Down Expand Up @@ -417,20 +417,23 @@ def verify_operational_balance(api_keys: APIKeys) -> bool:
) > xdai_type(0.001)

def store_prediction(
self, processed_market: ProcessedMarket, keys: APIKeys
self,
processed_market: ProcessedMarket,
keys: APIKeys,
agent_name: str,
) -> None:
reasoning = (
processed_market.answer.reasoning
if processed_market.answer.reasoning
else ""
)

ipfs_hash_decoded = HexBytes(HASH_ZERO)
if keys.enable_ipfs_upload:
logger.info("Storing prediction on IPFS.")
ipfs_hash = IPFSHandler(keys).store_agent_result(
IPFSAgentResult(reasoning=reasoning)
reasoning = (
processed_market.answer.reasoning
if processed_market.answer.reasoning
else ""
)
agent_result = IPFSAgentResult(
reasoning=reasoning, agent_name=self.agent_name
)
ipfs_hash = IPFSHandler(keys).store_agent_result(agent_result)
ipfs_hash_decoded = ipfscidv0_to_byte32(ipfs_hash)

tx_hashes = [
Expand Down
Loading