|
27 | 27 | Message, |
28 | 28 | TokenMetadata, |
29 | 29 | SolanaVerifyRequest, |
| 30 | + Context, |
| 31 | + UserMessage, |
30 | 32 | ) |
31 | 33 | from agent.agent_executors import ( |
32 | 34 | create_investor_executor, |
@@ -483,11 +485,50 @@ async def subnet_query_endpoint( |
483 | 485 | # Parse the request data into QuantQuery object |
484 | 486 | quant_query = QuantQuery(**request_data) |
485 | 487 |
|
486 | | - # Call the actual subnet query function |
487 | | - quant_response = await asyncio.to_thread(subnet_query, quant_query) |
| 488 | + # Convert QuantQuery to AgentChatRequest format |
| 489 | + # Use userID as wallet address |
| 490 | + wallet_address = quant_query.userID |
488 | 491 |
|
489 | | - if quant_response is None: |
490 | | - raise HTTPException(status_code=500, detail="Subnet query failed") |
| 492 | + # Create AgentChatRequest structure |
| 493 | + agent_request = AgentChatRequest( |
| 494 | + context=Context( |
| 495 | + address=wallet_address, |
| 496 | + conversationHistory=[], |
| 497 | + miner_token=None |
| 498 | + ), |
| 499 | + message=UserMessage( |
| 500 | + message=quant_query.query |
| 501 | + ), |
| 502 | + agent=None, # Let router decide |
| 503 | + captchaToken=None # No captcha for subnet |
| 504 | + ) |
| 505 | + |
| 506 | + # Get portfolio for the wallet address |
| 507 | + portfolio = await portfolio_fetcher.get_portfolio( |
| 508 | + wallet_address=wallet_address |
| 509 | + ) |
| 510 | + |
| 511 | + # Process the request using the same logic as run_agent |
| 512 | + response = await handle_agent_chat_request( |
| 513 | + token_metadata_repo=token_metadata_repo, |
| 514 | + protocol_registry=protocol_registry, |
| 515 | + request=agent_request, |
| 516 | + portfolio=portfolio, |
| 517 | + investor_agent=investor_agent, |
| 518 | + analytics_agent=analytics_agent, |
| 519 | + router_model=router_model, |
| 520 | + ) |
| 521 | + |
| 522 | + # Convert response to QuantResponse format |
| 523 | + quant_response = QuantResponse( |
| 524 | + response=response.message, |
| 525 | + signature=b"", # Empty signature for now |
| 526 | + proofs=[], # Empty proofs for now |
| 527 | + metadata={ |
| 528 | + "pools": [pool.model_dump() for pool in response.pools], |
| 529 | + "tokens": [token.model_dump() for token in response.tokens] |
| 530 | + } |
| 531 | + ) |
491 | 532 |
|
492 | 533 | return quant_response.model_dump() |
493 | 534 |
|
|
0 commit comments