Skip to content

Commit 8b2ac20

Browse files
authored
og sdk dep updates (#131)
* dep updates * dockerfile update * dep updates * dep updates * sdk dep update
1 parent dce35c1 commit 8b2ac20

4 files changed

Lines changed: 22 additions & 92 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WORKDIR /app
66

77
# Install system dependencies
88
RUN apt-get update && \
9-
apt-get install -y --no-install-recommends gcc python3-dev curl && \
9+
apt-get install -y --no-install-recommends gcc python3-dev curl git build-essential && \
1010
rm -rf /var/lib/apt/lists/*
1111

1212
# Copy requirements first to leverage Docker cache

agent/agent_executors.py

Lines changed: 19 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,47 @@
11
import os
2-
import httpx
3-
import logging
42

5-
from langchain_openai import ChatOpenAI
3+
import opengradient as og
64
from langgraph.prebuilt import create_react_agent
7-
from langchain_google_genai import ChatGoogleGenerativeAI
85
from langchain_core.language_models.chat_models import BaseChatModel
96

107
from agent.tools import create_investor_agent_toolkit, create_analytics_agent_toolkit
118
from onchain.tokens.metadata import TokenMetadataRepo
129
from server import config
13-
from web3 import Web3
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)
26-
27-
WEB3_CONFIG = Web3(Web3.HTTPProvider(config.OG_RPC_URL))
28-
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-
43-
44-
TIMEOUT = httpx.Timeout(
45-
timeout=90.0,
46-
connect=15.0,
47-
read=15.0,
48-
write=30.0,
49-
pool=10.0,
50-
)
51-
52-
LIMITS = httpx.Limits(
53-
max_keepalive_connections=100,
54-
max_connections=500,
55-
keepalive_expiry=60 * 20, # 20 minutes
56-
)
5710

5811

5912
##
6013
# OpenRouter LLM Configuration
6114
##
6215

63-
GOOGLE_GEMINI_25_PRO_MODEL = "gemini-2.5-pro"
64-
GOOGLE_GEMINI_25_FLASH_MODEL = "gemini-2.5-flash"
65-
GROK_MODEL = "x-ai/grok-2-1212" # $2/M input tokens; $10/M output tokens
66-
67-
x402_http_client = x402HttpxClientv2(
68-
x402_client,
69-
timeout=TIMEOUT,
70-
limits=LIMITS,
71-
http2=False,
72-
follow_redirects=False,
73-
verify=False,
74-
)
75-
7616
# Select model based on configuration
77-
SUGGESTIONS_MODEL = GOOGLE_GEMINI_25_FLASH_MODEL
78-
REASONING_MODEL = GOOGLE_GEMINI_25_PRO_MODEL
17+
SUGGESTIONS_MODEL = og.TEE_LLM.GEMINI_2_5_FLASH
18+
REASONING_MODEL = og.TEE_LLM.GEMINI_2_5_PRO
19+
20+
opengradient_client = og.LLM(
21+
private_key=config.WALLET_PRIV_KEY,
22+
rpc_url=config.OG_RPC_URL,
23+
)
7924

8025

8126
def create_suggestions_model() -> BaseChatModel:
82-
return ChatOpenAI(
83-
model=SUGGESTIONS_MODEL,
27+
return og.agents.langchain_adapter(
28+
client=opengradient_client,
29+
model_cid=SUGGESTIONS_MODEL,
8430
temperature=0.3,
8531
max_tokens=1000,
86-
api_key=config.DUMMY_X402_API_KEY,
87-
http_async_client=x402_http_client,
88-
stream_usage=True,
89-
streaming=True,
90-
base_url=config.LLM_SERVER_URL,
9132
)
9233

9334

9435
def create_investor_executor() -> any:
95-
openai_model = ChatOpenAI(
96-
model=REASONING_MODEL,
36+
model = og.agents.langchain_adapter(
37+
client=opengradient_client,
38+
model_cid=REASONING_MODEL,
9739
temperature=0.1,
98-
api_key=config.DUMMY_X402_API_KEY,
99-
http_async_client=x402_http_client,
100-
stream_usage=True,
101-
streaming=True,
102-
base_url=config.LLM_SERVER_URL,
10340
max_tokens=16384,
10441
)
10542

10643
agent_executor = create_react_agent(
107-
model=openai_model, tools=create_investor_agent_toolkit()
44+
model=model, tools=create_investor_agent_toolkit()
10845
)
10946

11047
return agent_executor
@@ -114,23 +51,19 @@ def create_analytics_executor(
11451
token_metadata_repo: TokenMetadataRepo,
11552
extra_tools: list = None,
11653
) -> any:
117-
openai_model = ChatOpenAI(
118-
model=REASONING_MODEL,
54+
model = og.agents.langchain_adapter(
55+
client=opengradient_client,
56+
model_cid=REASONING_MODEL,
11957
temperature=0.1,
12058
max_tokens=16384,
121-
api_key=config.DUMMY_X402_API_KEY,
122-
http_async_client=x402_http_client,
123-
stream_usage=True,
124-
streaming=True,
125-
base_url=config.LLM_SERVER_URL,
12659
)
12760

12861
tools = create_analytics_agent_toolkit(token_metadata_repo)
12962
if extra_tools:
13063
tools.extend(extra_tools)
13164

13265
analytics_executor = create_react_agent(
133-
model=openai_model,
66+
model=model,
13467
tools=tools,
13568
)
13669

requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
opengradient>=0.4.11
21
langgraph==0.5.3
32
langchain-community==0.3.14
43
fastapi>=0.110.0
@@ -27,8 +26,8 @@ aioboto3>=1.38.0
2726
async_lru>=2.0.0
2827
aiolimiter>=1.2.0
2928
pytest-asyncio>=0.21.0
30-
og-test-v2-x402==0.0.11.dev3
3129
eth-account>=0.13.4
3230
web3>=7.3.0
3331
cachetools>=6.2.4
34-
langchain-mcp-adapters==0.1.14
32+
langchain-mcp-adapters==0.1.14
33+
opengradient==0.9.5

server/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
SKIP_TOKEN_AUTH_HEADER = os.getenv("SKIP_TOKEN_AUTH_HEADER")
44
SKIP_TOKEN_AUTH_KEY = os.getenv("SKIP_TOKEN_AUTH_KEY")
55

6-
DUMMY_X402_API_KEY = os.getenv("DUMMY_X402_API_KEY", "dummy")
7-
LLM_SERVER_URL: str = os.getenv("LLM_SERVER_URL", "https://llm.opengradient.ai/v1")
86
OG_RPC_URL: str = os.getenv("OG_RPC_URL", "https://ogevmdevnet.opengradient.ai")
97
WALLET_PRIV_KEY: str = os.getenv("WALLET_PRIV_KEY")
108

0 commit comments

Comments
 (0)