Skip to content

Commit a99e939

Browse files
authored
fix: slack types and minor agent fixes (#719)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed
1 parent 988dc43 commit a99e939

File tree

3 files changed

+60
-15
lines changed

3 files changed

+60
-15
lines changed

src/codegen/agents/code_agent.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
if TYPE_CHECKING:
1313
from codegen import Codebase
1414

15-
# Remove logger configuration
16-
# logger = logging.getLogger(__name__)
17-
1815

1916
class CodeAgent:
2017
"""Agent for interacting with a codebase."""
@@ -95,3 +92,21 @@ def run(self, prompt: str, thread_id: Optional[str] = None) -> str:
9592
print(separator)
9693

9794
return result
95+
96+
def get_agent_trace_url(self) -> str | None:
97+
"""Get the URL for the most recent agent run in LangSmith.
98+
99+
Returns:
100+
The URL for the run in LangSmith if found, None otherwise
101+
"""
102+
try:
103+
# TODO - this is definitely not correct, we should be able to get the URL directly...
104+
return find_and_print_langsmith_run_url(client=self.langsmith_client, project_name=self.project_name)
105+
except Exception as e:
106+
separator = "=" * 60
107+
print(f"\n{separator}\nCould not retrieve LangSmith URL: {e}")
108+
import traceback
109+
110+
print(traceback.format_exc())
111+
print(separator)
112+
return None

src/codegen/extensions/slack/types.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,33 @@ class SlackWebhookPayload(BaseModel):
4242
event_time: int | None = Field(None)
4343
challenge: str | None = Field(None)
4444
subtype: str | None = Field(None)
45+
46+
47+
class SlackMessageReaction(BaseModel):
48+
"""Model for a reaction on a Slack message."""
49+
50+
name: str
51+
users: list[str]
52+
count: int
53+
54+
55+
class SlackMessage(BaseModel):
56+
"""Model for a message in a Slack conversation."""
57+
58+
user: str
59+
type: str
60+
ts: str
61+
client_msg_id: str | None = None
62+
text: str
63+
team: str | None = None
64+
blocks: list[Block] | None = None
65+
language: dict | None = None
66+
reactions: list[SlackMessageReaction] | None = None
67+
thread_ts: str | None = None
68+
reply_count: int | None = None
69+
reply_users_count: int | None = None
70+
latest_reply: str | None = None
71+
reply_users: list[str] | None = None
72+
is_locked: bool | None = None
73+
subscribed: bool | None = None
74+
parent_user_id: str | None = None

uv.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)