Skip to content

Commit 0f6f3b9

Browse files
authored
Merge pull request #40 from pattern-tech/fix/config-file
Fix/config file
2 parents fa676c3 + 026593f commit 0f6f3b9

File tree

10 files changed

+132
-149
lines changed

10 files changed

+132
-149
lines changed

.github/workflows/dev.yml

+9-12
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ jobs:
6262
--name pattern-core-api \
6363
--network pattern_core_network \
6464
-p 5001:8000 \
65-
-e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \
6665
-e POSTGRES_HOST=api-postgres-1 \
6766
-e POSTGRES_PORT=5432 \
6867
-e POSTGRES_DB=pattern-core \
@@ -71,17 +70,15 @@ jobs:
7170
-e JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} \
7271
-e QDRANT_HOST=http://qdrant:6333 \
7372
-e QDRANT_COLLECTION=pattern-core \
74-
-e LANGCHAIN_API_KEY=${{ secrets.LANGCHAIN_API_KEY }} \
75-
-e GOOGLE_SEARCH_URL=https://google.serper.dev/search \
76-
-e REDDIT_SEARCH_URL=https://reddit-scraper2.p.rapidapi.com/search_posts \
77-
-e LINKEDIN_SEARCH_URL=https://linkedin-data-api.p.rapidapi.com/search-posts \
78-
-e WEATHER_URL=https://api.weatherapi.com/v1/current.json \
79-
-e ETH_RPC=https://ethereum-rpc.publicnode.com \
80-
-e GOLDRUSH_URL=https://api.covalenthq.com \
81-
-e EXA_URL=https://api.exa.ai \
82-
-e PERPLEXITY_URL=https://api.perplexity.ai \
83-
-e TAVILY_URL=https://api.tavily.com \
84-
-e SECRET_KEY=${{ secrets.SECRET_KEY }} \
73+
-e MORALIS_API_KEY=${{ secrets.MORALIS_API_KEY }} \
74+
-e ETHER_SCAN_API_KEY=${{ secrets.ETHER_SCAN_API_KEY }} \
75+
-e GOLDRUSH_API_KEY=${{ secrets.GOLDRUSH_API_KEY }} \
76+
-e ETH_RPC_URL=${{ secrets.ETH_RPC_URL }} \
77+
-e LLM_PROVIDER=${{ secrets.LLM_PROVIDER }} \
78+
-e LLM_MODEL=${{ secrets.LLM_MODEL }} \
79+
-e LLM_API_KEY=${{ secrets.LLM_API_KEY }} \
80+
-e AGENTS=${{ secrets.AGENTS }} \
81+
-e SENTRY_DNS=${{ secrets.SENTRY_DNS }} \
8582
patterntechnology/pattern-core-api:latest
8683
8784
# Wait a few seconds to give the container time to start

api/.env.sample

+42-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,45 @@ log_max_bytes=5242880 # 5 * 1024 * 1024
2020
#------------------------
2121
# SENTRY (Optional)
2222
#------------------------
23-
SENTRY_DSN=
23+
SENTRY_DNS=
24+
25+
26+
#------------------------
27+
# LLM
28+
#------------------------
29+
30+
# +-------------+------------------------------------------------+
31+
# | Provider | Recommended Model |
32+
# +-------------+------------------------------------------------+
33+
# | openai | gpt-4o-mini |
34+
# | google | gemini-2.0-flash |
35+
# | together | deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free |
36+
# | ollama | llama3.3 |
37+
# | groq | llama-3.3-70b-versatile |
38+
# | firework | accounts/fireworks/models/firefunction-v2 |
39+
# | huggingface | meta-llama/Llama-3.3-70B-Instruct |
40+
# +-------------+------------------------------------------------+
41+
LLM_PROVIDER=openai
42+
LLM_MODEL=gpt-4o-mini
43+
LLM_API_KEY=
44+
LLM_HOST=
45+
LLM_MODELS_PATH=
46+
47+
48+
#------------------------
49+
# SERVICES
50+
#------------------------
51+
ETHER_SCAN_API_KEY=
52+
GOLDRUSH_API_KEY=
53+
MORALIS_API_KEY=
54+
EXA_API_KEY=
55+
PERPLEXITY_API_KEY=
56+
TAVILY_API_KEY=
57+
58+
ETH_RPC_URL=
59+
60+
61+
#------------------------
62+
# Agents
63+
#------------------------
64+
AGENTS=ETHER_SCAN,GOLDRUSH,MORALIS

api/README.md

+2-43
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,16 @@ To install the required dependencies, run:
88

99
```sh
1010
cp .env.example .env
11-
cp config.json.example config.json
1211
pip install -r requirements.txt
1312
```
1413

15-
Note: Fill up the .env and config.json file according to your config
14+
Note: Fill up the `.env` file according to your config
1615

17-
### Configuration
18-
Configuration file is in `config.json`. Edit it according to your needs.
1916

2017
Notes:
2118
- Add your own tool services or use existing ones
22-
- Add provided agents. (on top of each service tool is an agent so the name of agent should be same as service name)
19+
- Add provided agents (currently : ``ETHER_SCAN, MORALIS, GOLDRUSH``)
2320
- Choose the llm provider
24-
<table>
25-
<thead>
26-
<tr>
27-
<th>Supported Provider</th>
28-
<th>Recommended Model</th>
29-
</tr>
30-
</thead>
31-
<tbody>
32-
<tr>
33-
<td>openai</td>
34-
<td>gpt-4o-mini</td>
35-
</tr>
36-
<tr>
37-
<td>google</td>
38-
<td>gemini-2.0-flash</td>
39-
</tr>
40-
<tr>
41-
<td>together</td>
42-
<td>deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free</td>
43-
</tr>
44-
<tr>
45-
<td>ollama</td>
46-
<td>llama3.3</td>
47-
</tr>
48-
<tr>
49-
<td>groq</td>
50-
<td>llama-3.3-70b-versatile</td>
51-
</tr>
52-
<tr>
53-
<td>firework</td>
54-
<td>accounts/fireworks/models/firefunction-v2</td>
55-
</tr>
56-
<tr>
57-
<td>huggingface</td>
58-
<td>meta-llama/Llama-3.3-70B-Instruct</td>
59-
</tr>
60-
</tbody>
61-
</table>
6221

6322
### Running the Application
6423

api/config.json.sample

-53
This file was deleted.

api/src/agentflow/agents/hub.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class AgentHub:
1616

1717
def __init__(self):
1818
self.agents = {
19-
"etherscan": ether_scan_agent.etherscan_agent,
20-
"goldrush": goldrush_agent.goldrush_agent,
21-
"moralis": moralis_agent.moralis_agent
19+
"ETHER_SCAN": ether_scan_agent.etherscan_agent,
20+
"GOLDRUSH": goldrush_agent.goldrush_agent,
21+
"MORALIS": moralis_agent.moralis_agent
2222
}
2323

2424
def get_agents(self, agent_names: List[str]) -> List[Any]:

api/src/agentflow/providers/ether_scan_tools.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414

1515
_config = Config.get_config()
16-
_eth_rpc_config = Config.get_service_config(_config, "eth_rpc")
17-
_ether_scan_config = Config.get_service_config(_config, "etherscan")
16+
_ether_scan_config = Config.get_service_config(_config, "ETHER_SCAN")
1817

18+
_ETHERSCAN_URL = "https://api.etherscan.io/v2/api"
19+
_ETH_RPC = os.environ["ETH_RPC"]
1920

2021
@handle_exceptions
2122
def fetch_contract_abi(contract_address: str, api_key: str) -> Dict:
@@ -29,7 +30,7 @@ def fetch_contract_abi(contract_address: str, api_key: str) -> Dict:
2930
Returns:
3031
Dict: A dictionary representing the contract ABI.
3132
"""
32-
url = _ether_scan_config["url"]
33+
url = _ETHERSCAN_URL
3334
params = {
3435
"chainid": "1",
3536
"module": "contract",
@@ -58,7 +59,7 @@ def fetch_contract_source_code(contract_address: str, api_key: str) -> str:
5859
Returns:
5960
str: The contract source code.
6061
"""
61-
url = _ether_scan_config["url"]
62+
url = _ETHERSCAN_URL
6263
params = {
6364
"chainid": "1",
6465
"module": "contract",
@@ -100,7 +101,7 @@ def timestamp_to_block_number(timestamp: int, api_key: str) -> int:
100101
Returns:
101102
int: The closest block number.
102103
"""
103-
url = _ether_scan_config["url"]
104+
url = _ETHERSCAN_URL
104105
params = {
105106
"chainid": "1",
106107
"module": "block",
@@ -229,7 +230,7 @@ def get_contract_events(
229230
api_key = _ether_scan_config["api_key"]
230231
abi = fetch_contract_abi(contract_address, api_key)
231232

232-
web3 = Web3(Web3.HTTPProvider(_eth_rpc_config["url"]))
233+
web3 = Web3(Web3.HTTPProvider(_ETH_RPC))
233234
contract = web3.eth.contract(address=contract_address, abi=abi)
234235

235236
# Resolve the actual event name case-insensitively
@@ -262,7 +263,7 @@ def get_latest_eth_block_number() -> int:
262263
Returns:
263264
int: The current block number on the Ethereum mainnet.
264265
"""
265-
web3 = Web3(Web3.HTTPProvider(_eth_rpc_config["url"]))
266+
web3 = Web3(Web3.HTTPProvider(_ETH_RPC))
266267
return web3.eth.block_number
267268

268269

api/src/agentflow/providers/goldrush_tools.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010

1111
_config = Config.get_config()
12-
_goldrush_config = Config.get_service_config(_config, "goldrush")
12+
_goldrush_config = Config.get_service_config(_config, "GOLDRUSH")
13+
14+
_GOLDRUSH_URL = "https://api.covalenthq.com"
1315

1416

1517
def _call_goldrush_api(url: str, params: Optional[Dict[str, Any]] = None) -> Dict:
@@ -49,7 +51,7 @@ def get_wallet_activity(wallet_address: str, output_include: list[str]) -> List[
4951
- name, chain_id, is_testnet, db_schema_name, label, category_label, logo_url,
5052
black_logo_url, white_logo_url, color_theme, is_appchain, appchain_of, last_seen_at
5153
"""
52-
base_url = _goldrush_config["url"]
54+
base_url = _GOLDRUSH_URL
5355
url = f"{base_url}/v1/address/{wallet_address}/activity/"
5456
data = _call_goldrush_api(url)
5557
results = data["data"]["items"]
@@ -82,7 +84,7 @@ def get_balance_for_address(wallet_address: str, output_include: list[str]) -> s
8284
supports_erc, logo_url, logo_urls, last_transferred_at, native_token, type, is_spam, balance, balance_24h,
8385
quote_rate, quote_rate_24h, quote, quote_24h, pretty_quote, pretty_quote_24h, protocol_metadata.
8486
"""
85-
base_url = _goldrush_config["url"]
87+
base_url = _GOLDRUSH_URL
8688
chain_name = "eth-mainnet"
8789
url = f"{base_url}/v1/{chain_name}/address/{wallet_address}/balances_v2/"
8890
data = _call_goldrush_api(url)
@@ -117,7 +119,7 @@ def get_wallet_transactions(wallet_address: str, output_include: List[str], page
117119
gas_offered, gas_spent, gas_price, fees_paid, gas_quote, pretty_gas_quote, gas_quote_rate, explorers,
118120
log_events
119121
"""
120-
base_url = _goldrush_config["url"]
122+
base_url = _GOLDRUSH_URL
121123
chain_name = "eth-mainnet"
122124
url = f"{base_url}/v1/{chain_name}/address/{wallet_address}/transactions_v3/page/{page}/"
123125
data = _call_goldrush_api(url)
@@ -142,7 +144,7 @@ def get_transactions_summary(wallet_address: str) -> Dict:
142144
Returns:
143145
Dict: The transactions summary data.
144146
"""
145-
base_url = _goldrush_config["url"]
147+
base_url = _GOLDRUSH_URL
146148
chain_name = "eth-mainnet"
147149
url = f"{base_url}/v1/{chain_name}/address/{wallet_address}/transactions_summary/"
148150
data = _call_goldrush_api(url)
@@ -170,7 +172,7 @@ def get_transaction_detail(tx_hash: str, output_include: List[str]) -> List[Dict
170172
gas_offered, gas_spent, gas_price, fees_paid, gas_quote, pretty_gas_quote, gas_quote_rate, explorers,
171173
log_events, internal_transfers, state_changes, input_data
172174
"""
173-
base_url = _goldrush_config["url"]
175+
base_url = _GOLDRUSH_URL
174176
chain_name = "eth-mainnet"
175177
url = f"{base_url}/v1/{chain_name}/transaction_v2/{tx_hash}/"
176178
data = _call_goldrush_api(url)
@@ -203,7 +205,7 @@ def get_token_approvals(wallet_address: str, output_include: List[str]) -> Dict:
203205
quote_rate, balance, balance_quote, pretty_balance_quote, value_at_risk, value_at_risk_quote,
204206
pretty_value_at_risk_quote, spenders
205207
"""
206-
base_url = _goldrush_config["url"]
208+
base_url = _GOLDRUSH_URL
207209
chain_name = "eth-mainnet"
208210
url = f"{base_url}/v1/{chain_name}/approvals/{wallet_address}/"
209211
data = _call_goldrush_api(url)

api/src/agentflow/providers/moralis_tools.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
from src.agentflow.utils.shared_tools import handle_exceptions
99

1010
_config = Config.get_config()
11-
_moralis_config = Config.get_service_config(_config, "moralis")
11+
_moralis_config = Config.get_service_config(_config, "MORALIS")
1212

13+
_MORALIS_URL = "https://deep-index.moralis.io/api/v2"
1314

1415
@tool
1516
@handle_exceptions
@@ -226,7 +227,7 @@ def get_token_approvals(wallet_address: str, output_include: list[str], cursor:
226227
227228
- block_number, block_timestamp, transaction_hash, value, value_formatted, token, spender
228229
"""
229-
base_url = _moralis_config["url"]
230+
base_url = _MORALIS_URL
230231
api_url = f"{base_url}/wallets/{wallet_address}/approvals"
231232

232233
params = {'chain': 'eth'}

api/src/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
load_dotenv()
1717
_logger = Logging().get_logger()
1818

19-
if os.environ.get("SENTRY_DSN"):
19+
if os.environ.get("SENTRY_DNS"):
2020
# Initialize Sentry with your DSN
2121
sentry_sdk.init(
22-
dsn=os.environ.get("SENTRY_DSN"),
22+
dsn=os.environ.get("SENTRY_DNS"),
2323
# Add data like request headers and IP for users,
2424
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
2525
send_default_pii=True,

0 commit comments

Comments
 (0)