Skip to content

Commit

Permalink
Removed redundant logs and updated fetching global instructions from db
Browse files Browse the repository at this point in the history
  • Loading branch information
itisallgood committed Dec 18, 2024
1 parent f516931 commit 072fbb6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
4 changes: 0 additions & 4 deletions holmes/core/conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ def build_chat_messages(
"content": ask,
},
]
print("MESSAGES BEFORE SENDING")
print(messages)
return messages

if global_instructions and global_instructions.instructions and len(global_instructions.instructions[0]) > 0:
Expand All @@ -357,6 +355,4 @@ def build_chat_messages(
ai, conversation_history_without_tools, number_of_tools
)
truncate_tool_messages(conversation_history, tool_size)
print("CONVERSATION_HISTORY BEFORE SENDING")
print(conversation_history)
return conversation_history
2 changes: 1 addition & 1 deletion holmes/core/investigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def investigate_issues(investigate_request: InvestigateRequest, dal: SupabaseDal
"alert", investigate_request.context.get("issue_type")
)
global_instructions = dal.get_global_instructions_for_account()
print(f"GLOBAL INSTRUCTIONS: {global_instructions}")

raw_data = investigate_request.model_dump()
if context:
raw_data["extra_context"] = context
Expand Down
15 changes: 8 additions & 7 deletions holmes/core/supabase_dal.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ def get_resource_instructions(self, type: str, name: Optional[str]) -> Optional[
return None

def get_global_instructions_for_account(self) -> Optional[Intructions]:
print(self.account_id)
res = (
try:
res = (
self.client
.table(RUNBOOKS_TABLE)
.select("runbook")
Expand All @@ -205,11 +205,12 @@ def get_global_instructions_for_account(self) -> Optional[Intructions]:
.execute()
)

if res.data:
instructions = res.data[0].get("runbook").get("instructions")
print(Intructions(instructions=instructions))
return Intructions(instructions=instructions)

if res.data:
instructions = res.data[0].get("runbook").get("instructions")
return Intructions(instructions=instructions)
except Exception:
logging.exception("Failed to fetch global instructions", exc_info=True)

return None

def create_session_token(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion holmes/core/tool_calling_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def investigate(
user_prompt += f"\n\nGlobal Instructions (use only if relevant): {global_instructions.instructions[0]}\n"

user_prompt = f"{user_prompt}\n This is context from the issue {issue.raw}"
print(user_prompt)

logging.debug(
"Rendered system prompt:\n%s", textwrap.indent(system_prompt, " ")
)
Expand Down
4 changes: 2 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def issue_conversation(issue_chat_request: IssueChatRequest):
load_robusta_api_key(dal=dal, config=config)
ai = config.create_toolcalling_llm(console, dal=dal)
global_instructions = dal.get_global_instructions_for_account()
print(f"GLOBAL INSTRUCTION: {global_instructions}")

messages = build_issue_chat_messages(issue_chat_request, ai, global_instructions)
llm_call = ai.messages_call(messages=messages)

Expand All @@ -193,7 +193,7 @@ def chat(chat_request: ChatRequest):

ai = config.create_toolcalling_llm(console, dal=dal)
global_instructions = dal.get_global_instructions_for_account()
print(f"GLOBAL INSTRUCTION: {global_instructions}")

messages = build_chat_messages(
chat_request.ask, chat_request.conversation_history, ai=ai, global_instructions=global_instructions
)
Expand Down

0 comments on commit 072fbb6

Please sign in to comment.