Skip to content

Commit

Permalink
feat: add log_size parameter to MonitorRunner and main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
peterxcli committed Jan 27, 2024
1 parent 54cb406 commit 21bb856
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def stopped(self):
discord_bot_token = os.getenv("DISCORD_BOT_TOKEN")
discord_dst_channel_id = int(os.getenv("DISCORD_DST_CHANNEL_ID"))
pinecone_api_key = os.getenv("PINECONE_API_KEY")
log_size = os.getenv("LOG_SIZE", 10)
service_name = "consumer-latest"

# init discord client
Expand Down Expand Up @@ -64,6 +65,7 @@ def stopped(self):
discord_thread_manager=discord_thread_manager,
target_service_name=service_name,
cloudrun_manager=cloudrun_manager,
log_size=log_size,
)

discord_bot = DiscordBot(
Expand Down
6 changes: 5 additions & 1 deletion monitor/monitor_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ def __init__(
discord_thread_manager: DiscordThreadManager,
target_service_name="consumer-latest",
cloudrun_manager: CloudRunManager = CloudRunManager(),
log_size=10,
):
self.llm_log_analyzer = llm_log_analyzer
self.discord_client = client
self.channel_id = channel_id
self.cloudrun_manager = cloudrun_manager
self.discord_thread_manager = discord_thread_manager
self.target_service_name = target_service_name
self.log_size = log_size

def get_agent_response(self, conversion_id: str, user_message: str):
return self.llm_log_analyzer.chat(conversion_id, user_message)
Expand All @@ -83,7 +85,9 @@ async def create_thread(self, message: discord.Message):
def fetch_and_process_logs(self):
log_df = pd.DataFrame()
# Assume log.tail_log_entry is an async function
for log_line in log.tail_log_entry(self.target_service_name, max_results=10):
for log_line in log.tail_log_entry(
self.target_service_name, max_results=self.log_size
):
parse_df = parser(log_line)
log_df = pd.concat([log_df, parse_df])
return log_df
Expand Down

0 comments on commit 21bb856

Please sign in to comment.