Skip to content

Commit 427015e

Browse files
authored
updates (#110)
1 parent 50afcce commit 427015e

4 files changed

Lines changed: 32 additions & 71 deletions

File tree

agent/agent_executors.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
22
import httpx
3+
import logging
34

4-
from openai import OpenAI
5+
from langchain_openai import ChatOpenAI
56
from langgraph.prebuilt import create_react_agent
67
from langchain_google_genai import ChatGoogleGenerativeAI
78
from langchain_core.language_models.chat_models import BaseChatModel
@@ -10,13 +11,35 @@
1011
from onchain.tokens.metadata import TokenMetadataRepo
1112
from server import config
1213
from web3 import Web3
13-
from x402.clients.base import x402Client
14-
from x402.types import x402PaymentRequiredResponse
15-
from langchain_openai import ChatOpenAI
16-
from .x402 import X402Auth
14+
15+
from x402v2 import x402Client as x402Clientv2
16+
from x402v2.http.clients import x402HttpxClient as x402HttpxClientv2
17+
from x402v2.mechanisms.evm import EthAccountSigner as EthAccountSignerv2
18+
from x402v2.mechanisms.evm.exact.register import (
19+
register_exact_evm_client as register_exact_evm_clientv2,
20+
)
21+
from x402v2.mechanisms.evm.upto.register import (
22+
register_upto_evm_client as register_upto_evm_clientv2,
23+
)
24+
25+
logging.getLogger("x402.httpx").setLevel(logging.DEBUG)
1726

1827
WEB3_CONFIG = Web3(Web3.HTTPProvider(config.OG_RPC_URL))
1928
WALLET_ACCOUNT = WEB3_CONFIG.eth.account.from_key(config.WALLET_PRIV_KEY)
29+
BASE_TESTNET_NETWORK = "eip155:84532"
30+
31+
x402_client = x402Clientv2()
32+
register_exact_evm_clientv2(
33+
x402_client,
34+
EthAccountSignerv2(WALLET_ACCOUNT),
35+
networks=[BASE_TESTNET_NETWORK],
36+
)
37+
register_upto_evm_clientv2(
38+
x402_client,
39+
EthAccountSignerv2(WALLET_ACCOUNT),
40+
networks=[BASE_TESTNET_NETWORK],
41+
)
42+
2043

2144
TIMEOUT = httpx.Timeout(
2245
timeout=90.0,
@@ -48,14 +71,12 @@
4871
)
4972
GROK_MODEL = "x-ai/grok-2-1212" # $2/M input tokens; $10/M output tokens
5073

51-
x402_http_client = httpx.AsyncClient(
52-
base_url=config.LLM_SERVER_URL,
53-
headers={"Authorization": f"Bearer {config.DUMMY_X402_API_KEY}"},
74+
x402_http_client = x402HttpxClientv2(
75+
x402_client,
5476
timeout=TIMEOUT,
5577
limits=LIMITS,
5678
http2=False,
5779
follow_redirects=False,
58-
auth=X402Auth(account=WALLET_ACCOUNT), # type: ignore
5980
)
6081

6182
# Select model based on configuration

agent/x402.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ aioboto3>=1.38.0
2727
async_lru>=2.0.0
2828
aiolimiter>=1.2.0
2929
pytest-asyncio>=0.21.0
30-
og-test-x402==0.0.9
30+
og-test-v2-x402==0.0.9
3131
eth-account>=0.13.4
3232
web3>=7.3.0
3333
cachetools>=6.2.4

server/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SKIP_TOKEN_AUTH_KEY = os.getenv("SKIP_TOKEN_AUTH_KEY")
55

66
DUMMY_X402_API_KEY = os.getenv("DUMMY_X402_API_KEY", "dummy")
7-
LLM_SERVER_URL: str = os.getenv("LLM_SERVER_URL", "https://llmogevm.opengradient.ai/v1")
7+
LLM_SERVER_URL: str = os.getenv("LLM_SERVER_URL", "https://llm.opengradient.ai/v1")
88
OG_RPC_URL: str = os.getenv("OG_RPC_URL", "https://ogevmdevnet.opengradient.ai")
99
WALLET_PRIV_KEY: str = os.getenv("WALLET_PRIV_KEY")
1010

0 commit comments

Comments
 (0)