Skip to content

Commit

Permalink
Refactor message history limits and streamline response context in Di…
Browse files Browse the repository at this point in the history
…scord and Telegram clients

- Reduced MAX_HISTORY_MESSAGES from 99999 to 50 in both Discord and Telegram clients to improve performance and manageability.
- Removed verbose context logging for message history in Discord and Telegram clients to enhance response conciseness.
- Updated trading recommendation prompt in DirectClient to remove specific market cap criteria, focusing on broader analysis for token trends.
  • Loading branch information
cornip committed Jan 18, 2025
1 parent c78b78f commit 272a67e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion rina-core/src/clients/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl<E: EmbeddingModel + 'static> DirectClient<E> {
fn create_trends_prompt(&self, token_trending: &str, knowledge_context: &[Trade]) -> String {
format!(
"Analyze the token trends and provide your trading recommendation in JSON format. \
Consider market cap (ONLY target tokens with <5M market cap), smart money movement, holder distribution, volume, and liquidity. \
Consider market cap, smart money movement, holder distribution, volume, and liquidity. \
Focus on microcap gems for higher potential returns given the small portfolio size. \
If no good trading opportunities are found, use action 'hold'. \
Provide a brief, concise reason (max 100 characters). \
Expand Down
9 changes: 1 addition & 8 deletions rina-core/src/clients/discord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{

const MIN_CHUNK_LENGTH: usize = 100;
const MAX_MESSAGE_LENGTH: usize = 1500;
const MAX_HISTORY_MESSAGES: i64 = 99999;
const MAX_HISTORY_MESSAGES: i64 = 50;

#[derive(Clone)]
pub struct DiscordClient<M: CompletionModel, E: EmbeddingModel + 'static> {
Expand Down Expand Up @@ -138,13 +138,6 @@ impl<M: CompletionModel + 'static, E: EmbeddingModel + 'static> EventHandler
chrono::Local::now().format("%I:%M:%S %p, %Y-%m-%d")
))
.context("Please keep your responses concise and under 2000 characters when possible.")
.context(&format!(
"Your response should be based on the latest messages: {:?}"
,context.history.iter()
.map(|(_, msg)| format!("- {}", msg))
.collect::<Vec<_>>()
.join("\n"),
))
.build();

let discord_prompt = format!("Generate a reply to this message: {}", msg.content);
Expand Down
9 changes: 1 addition & 8 deletions rina-core/src/clients/telegram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use teloxide::{
};
use tracing::{debug, error, info};

const MAX_HISTORY_MESSAGES: i64 = 99999;
const MAX_HISTORY_MESSAGES: i64 = 50;

pub struct TelegramClient<M: CompletionModel, E: EmbeddingModel + 'static> {
agent: Agent<M, E>,
Expand Down Expand Up @@ -114,13 +114,6 @@ impl<M: CompletionModel + 'static, E: EmbeddingModel + 'static> TelegramClient<M
chrono::Local::now().format("%I:%M:%S %p, %Y-%m-%d")
))
.context("Please keep your responses concise and under 4096 characters when possible.")
.context(&format!(
"Your response should be based on the latest messages: {:?}"
,context.history.iter()
.map(|(_, msg)| format!("- {}", msg))
.collect::<Vec<_>>()
.join("\n"),
))
.build();
let telegram_prompt = format!("Generate a reply to this message: {}", text);
let response = match agent.prompt(&telegram_prompt).await {
Expand Down

0 comments on commit 272a67e

Please sign in to comment.