Skip to content

Commit 8c32b02

Browse files
Adam BaloghAdam Balogh
authored andcommitted
cutoff
1 parent d5e4689 commit 8c32b02

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

agent/prompts.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
# We ignore token holdings with a total value of less than $1
1515
MIN_TOKEN_HOLDING_VALUE_USD = 1
1616

17+
# Start filtering out holdings based on MIN_TOKEN_HOLDING_VALUE_USD after this many holdings
18+
NUM_HOLDINGS_CUTOFF = 10
19+
1720

1821
def get_investor_agent_prompt(
1922
tokens: List[WalletTokenHolding],
@@ -28,7 +31,11 @@ def get_investor_agent_prompt(
2831
"amount": token.amount,
2932
}
3033
for token in tokens
31-
if token.total_value_usd is not None and token.total_value_usd > MIN_TOKEN_HOLDING_VALUE_USD
34+
if len(tokens) <= NUM_HOLDINGS_CUTOFF
35+
or (
36+
token.total_value_usd is not None
37+
and token.total_value_usd > MIN_TOKEN_HOLDING_VALUE_USD
38+
)
3239
]
3340

3441
agent_prompt = investor_agent_template.render(
@@ -52,7 +59,11 @@ def get_suggestions_prompt(
5259
"amount": token.amount,
5360
}
5461
for token in tokens
55-
if token.total_value_usd is not None and token.total_value_usd > MIN_TOKEN_HOLDING_VALUE_USD
62+
if len(tokens) <= NUM_HOLDINGS_CUTOFF
63+
or (
64+
token.total_value_usd is not None
65+
and token.total_value_usd > MIN_TOKEN_HOLDING_VALUE_USD
66+
)
5667
]
5768

5869
agent_prompt = suggestions_template.render(
@@ -77,7 +88,11 @@ def get_analytics_prompt(
7788
"amount": token.amount,
7889
}
7990
for token in tokens
80-
if token.total_value_usd is not None and token.total_value_usd > MIN_TOKEN_HOLDING_VALUE_USD
91+
if len(tokens) <= NUM_HOLDINGS_CUTOFF
92+
or (
93+
token.total_value_usd is not None
94+
and token.total_value_usd > MIN_TOKEN_HOLDING_VALUE_USD
95+
)
8196
]
8297

8398
analytics_agent_prompt = analytics_agent_template.render(

server/server.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ def handle_investor_chat_request(
251251

252252
# Prepare message history
253253
message_history = [
254-
convert_to_agent_msg(m) for m in request.context.conversationHistory[-NUM_MESSAGES_TO_KEEP:]
254+
convert_to_agent_msg(m)
255+
for m in request.context.conversationHistory[-NUM_MESSAGES_TO_KEEP:]
255256
]
256257

257258
# Create messages for investor agent
@@ -298,7 +299,8 @@ def handle_suggestions_request(
298299

299300
# Prepare message history (last 10 messages)
300301
message_history = [
301-
convert_to_agent_msg(m) for m in request.context.conversationHistory[-NUM_MESSAGES_TO_KEEP:]
302+
convert_to_agent_msg(m)
303+
for m in request.context.conversationHistory[-NUM_MESSAGES_TO_KEEP:]
302304
]
303305

304306
# Create messages for suggestions agent
@@ -422,7 +424,8 @@ def handle_analytics_chat_request(
422424

423425
# Prepare message history (last 10 messages)
424426
message_history = [
425-
convert_to_agent_msg(m) for m in request.context.conversationHistory[-NUM_MESSAGES_TO_KEEP:]
427+
convert_to_agent_msg(m)
428+
for m in request.context.conversationHistory[-NUM_MESSAGES_TO_KEEP:]
426429
]
427430

428431
# Create messages for analytics agent

0 commit comments

Comments
 (0)