Skip to content

Commit

Permalink
feat: correct url, update example, and linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrriehl committed Jun 22, 2023
1 parent c889e3e commit 011b5ee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
8 changes: 4 additions & 4 deletions examples/09-booking-protocol-demo/restaurant.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

fund_agent_if_low(restaurant.wallet.address())

# build the restaurant agent from stock protocols
restaurant.include(query_proto)
restaurant.include(book_proto)
restaurant.include(proto_query)
# build the restaurant agent from stock protocols and publish their details
restaurant.include(query_proto, publish_manifest=True)
restaurant.include(book_proto, publish_manifest=True)
restaurant.include(proto_query, publish_manifest=True)

TABLES = {
1: TableStatus(seats=2, time_start=16, time_end=22),
Expand Down
18 changes: 13 additions & 5 deletions src/uagents/agent.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import functools
import requests
from typing import Dict, List, Optional, Set, Union, Type, Tuple, Any
import uuid
import requests

from cosmpy.aerial.wallet import LocalWallet, PrivateKey
from cosmpy.crypto.address import Address
Expand All @@ -24,7 +24,7 @@
from uagents.network import get_ledger, get_reg_contract, wait_for_tx_to_complete
from uagents.mailbox import MailboxClient
from uagents.config import (
ALMANAC_API_URL,
AGENTVERSE_URL,
REGISTRATION_FEE,
REGISTRATION_DENOM,
LEDGER_PREFIX,
Expand Down Expand Up @@ -330,12 +330,20 @@ def include(self, protocol: Protocol, publish_manifest: Optional[bool] = False):
self.protocols[protocol.digest] = protocol

if publish_manifest:
self.publish_manifest()
self.publish_manifest(protocol.manifest())

def publish_manifest(self, manifest: Dict[str, Any]):
try:
requests.post(ALMANAC_API_URL + "/v1/almanac/manifests", json=manifest)
except Exception as ex:
resp = requests.post(
AGENTVERSE_URL + "/v1/almanac/manifests", json=manifest, timeout=5
)
if resp.status_code == 200:
self._logger.info(
f"Manifest published successfully: {manifest['metadata']['name']}"
)
else:
self._logger.warning(f"Unable to publish manifest: {resp.text}")
except requests.exceptions.RequestException as ex:
self._logger.warning(f"Unable to publish manifest: {ex}")

async def handle_message(
Expand Down
5 changes: 2 additions & 3 deletions src/uagents/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class AgentNetwork(Enum):
BLOCK_INTERVAL = 5
AGENT_NETWORK = AgentNetwork.FETCHAI_TESTNET

MAILBOX_SERVER_URL = "wss://agentverse.ai"
AGENTVERSE_URL = "https://agentverse.ai"
MAILBOX_POLL_INTERVAL_SECONDS = 1.0
ALMANAC_API_URL = "https://almanac.agentverse.ai"

DEFAULT_ENVELOPE_TIMEOUT_SECONDS = 30

Expand All @@ -48,7 +47,7 @@ def parse_endpoint_config(

def parse_mailbox_config(mailbox: Union[str, Dict[str, str]]) -> Dict[str, str]:
api_key = None
base_url = MAILBOX_SERVER_URL
base_url = AGENTVERSE_URL.replace("https", "wss")
if isinstance(mailbox, str):
if mailbox.count("@") == 1:
api_key, base_url = mailbox.split("@")
Expand Down

0 comments on commit 011b5ee

Please sign in to comment.