Skip to content

Commit 6a64508

Browse files
authored
Merge pull request #27 from RSS3-Network/feat/refactor
Refactor configuration file
2 parents 9e2aa46 + a24c4e5 commit 6a64508

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

src/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ LLM_API_BASE=http://ollama:11434
3939

4040
## A database is required for vector and user management.
4141
## Database connection string
42-
DB_CONNECTION=postgresql+psycopg://postgres:password@vector_db:5434/vec
42+
DB_CONNECTION=postgresql+psycopg://postgres:password@vector_db:5432/openagent
4343

4444
# End of basic configuration
4545
############################

src/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
environment:
2020
POSTGRES_USER: postgres
2121
POSTGRES_PASSWORD: password
22-
POSTGRES_DB: vec
22+
POSTGRES_DB: openagent
2323
ports:
2424
- "15432:5432"
2525
volumes:

src/openagent/agent/function_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def create_tool_call_agent(session_id: str):
152152
async def main():
153153
# Create a tool call agent and use it to handle some inputs
154154
agent = get_agent("123")
155-
await agent.ainvoke({"input": "Swap 1 eth to usdt, from ethereumn to arb"})
155+
await agent.ainvoke({"input": "Swap 1 eth to usdt, from ethereum to arb"})
156156
await agent.ainvoke({"input": "What is the price of ETH?"})
157157
await agent.ainvoke({"input": "What did vitalik.eth do recently?"})
158158

src/openagent/experts/article_expert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from langchain.tools import BaseTool
99
from pydantic import BaseModel, Field
1010

11-
from openagent.index.pgvector_store import store
11+
from openagent.index.pgvector_store import build_vector_store
1212

1313

1414
class ARGS(BaseModel):
@@ -45,6 +45,7 @@ async def _arun(
4545

4646
@staticmethod
4747
def search_articles(keyword: str) -> str:
48+
store = build_vector_store()
4849
retriever = store.as_retriever(
4950
search_type="similarity_score_threshold",
5051
search_kwargs={"score_threshold": 0.8, "k": 3},

src/openagent/experts/swap_expert.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ class ParamSchema(BaseModel):
2121

2222
from_token: str = Field(description="Symbol of the token to swap from, e.g., 'BTC', 'ETH', 'RSS3', 'USDT', 'USDC'. Default: 'ETH'.")
2323
to_token: str = Field(description="Symbol of the token to swap to, e.g., 'BTC', 'ETH', 'RSS3', 'USDT', 'USDC'. Default: 'ETH'.")
24-
from_chain: ChainLiteral = Field(default="ETH", description="Blockchain network to swap from. Default: 'ETH'.")
25-
to_chain: ChainLiteral = Field(default="ETH", description="Blockchain network to swap to. Default: 'ETH'.")
24+
from_chain: ChainLiteral = Field(
25+
default="ETH",
26+
description="Blockchain network to swap from, support networks: 'ETH', 'BSC', 'ARBITRUM', 'OPTIMISM', 'POLYGON'. Default: 'ETH'.",
27+
)
28+
to_chain: ChainLiteral = Field(
29+
default="ETH", description="Blockchain network to swap to, support networks: 'ETH', 'BSC', 'ARBITRUM', 'OPTIMISM', 'POLYGON'. Default: 'ETH'."
30+
)
2631
amount: str = Field(description="Amount of the from-side token to swap, e.g., '0.1', '1', '10'. Default: '1'.")
2732

2833

src/openagent/index/feed_indexing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from openagent.conf.env import settings
1111
from openagent.index.feed_scrape import fetch_iqwiki_feeds, fetch_mirror_feeds
12-
from openagent.index.pgvector_store import store
12+
from openagent.index.pgvector_store import build_vector_store
1313

1414
load_dotenv()
1515

@@ -18,7 +18,7 @@
1818

1919

2020
def _clear():
21-
index([], record_manager, store, cleanup="incremental", source_id_key="id")
21+
index([], record_manager, build_vector_store(), cleanup="incremental", source_id_key="id")
2222

2323

2424
def build_index():
@@ -66,7 +66,7 @@ def save_records(records):
6666
indexing_result = index(
6767
final_docs,
6868
record_manager,
69-
store,
69+
build_vector_store(),
7070
cleanup="incremental",
7171
source_id_key="id",
7272
)

src/openagent/index/pgvector_store.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
from langchain_google_vertexai import VertexAIEmbeddings
44
from langchain_openai import OpenAIEmbeddings
55
from langchain_postgres.vectorstores import PGVector
6+
from toolz import memoize
67

78
from openagent.conf.env import settings
89

910
load_dotenv()
1011

1112

13+
@memoize
1214
def build_vector_store() -> PGVector:
1315
collection_name = "backend"
1416
if settings.MODEL_NAME.startswith("gemini"):
@@ -24,6 +26,3 @@ def build_vector_store() -> PGVector:
2426
connection=settings.DB_CONNECTION,
2527
use_jsonb=True,
2628
)
27-
28-
29-
store = build_vector_store()

0 commit comments

Comments
 (0)