Skip to content

Commit 56dc306

Browse files
rushilpatel0github-actions[bot]
authored andcommitted
Automated pre-commit update
1 parent 55c0c08 commit 56dc306

File tree

6 files changed

+83
-460
lines changed

6 files changed

+83
-460
lines changed

src/codegen/agents/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

src/codegen/agents/code_agent.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from langchain_core.runnables.config import RunnableConfig
88
from langgraph.graph.graph import CompiledGraph
99
from langsmith import Client
10-
from langchain_core.messages import AIMessage
11-
from codegen.agents.loggers import ExternalLogger
10+
11+
from codegen.agents.loggers import ExternalLogger
1212
from codegen.agents.tracer import MessageStreamTracer
1313
from codegen.extensions.langchain.agent import create_codebase_agent
1414
from codegen.extensions.langchain.utils.get_langsmith_url import (
@@ -86,7 +86,6 @@ def __init__(
8686
self.project_name = os.environ.get("LANGCHAIN_PROJECT", "RELACE")
8787
print(f"Using LangSmith project: {self.project_name}")
8888

89-
9089
# Store SWEBench metadata if provided
9190
self.run_id = metadata.get("run_id")
9291
self.instance_id = metadata.get("instance_id")
@@ -125,8 +124,6 @@ def run(self, prompt: str) -> str:
125124
"recursion_limit": 100,
126125
}
127126

128-
129-
130127
# this message has a reducer which appends the current message to the existing history
131128
# see more https://langchain-ai.github.io/langgraph/concepts/low_level/#reducers
132129
input = {"query": prompt}
@@ -136,7 +133,6 @@ def run(self, prompt: str) -> str:
136133

137134
stream = self.agent.stream(input, config=config, stream_mode="values")
138135

139-
140136
_tracer = MessageStreamTracer(logger=self.logger)
141137

142138
# Process the stream with the tracer

src/codegen/agents/data.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,68 @@
1-
from typing import List, Optional
21
from dataclasses import dataclass, field
32
from datetime import datetime
3+
from typing import Optional
4+
45

56
# Base dataclass for all message types
67
@dataclass
78
class BaseMessage:
89
"""Base class for all message types."""
10+
911
type: str
1012
timestamp: str = field(default_factory=lambda: datetime.now().isoformat())
1113
content: str = ""
1214

15+
1316
@dataclass
1417
class UserMessage(BaseMessage):
1518
"""Represents a message from the user."""
19+
1620
type: str = field(default="user")
1721

22+
1823
@dataclass
1924
class SystemMessageData(BaseMessage):
2025
"""Represents a system message."""
26+
2127
type: str = field(default="system")
2228

29+
2330
@dataclass
2431
class ToolCall:
2532
"""Represents a tool call within an assistant message."""
33+
2634
name: Optional[str] = None
2735
arguments: Optional[str] = None
2836
id: Optional[str] = None
2937

38+
3039
@dataclass
3140
class AssistantMessage(BaseMessage):
3241
"""Represents a message from the assistant."""
42+
3343
type: str = field(default="assistant")
34-
tool_calls: List[ToolCall] = field(default_factory=list)
44+
tool_calls: list[ToolCall] = field(default_factory=list)
45+
3546

3647
@dataclass
3748
class ToolMessageData(BaseMessage):
3849
"""Represents a tool response message."""
50+
3951
type: str = field(default="tool")
4052
tool_name: Optional[str] = None
4153
tool_response: Optional[str] = None
4254
tool_id: Optional[str] = None
4355

56+
4457
@dataclass
4558
class FunctionMessageData(BaseMessage):
4659
"""Represents a function message."""
60+
4761
type: str = field(default="function")
4862

63+
4964
@dataclass
5065
class UnknownMessage(BaseMessage):
5166
"""Represents an unknown message type."""
52-
type: str = field(default="unknown")
67+
68+
type: str = field(default="unknown")

src/codegen/agents/loggers.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import json
2-
from typing import Dict, List, Any, Union, Protocol
3-
from dataclasses import asdict
1+
from typing import Any, Protocol, Union
2+
43
from .data import BaseMessage
54

5+
66
# Define the interface for ExternalLogger
77
class ExternalLogger(Protocol):
88
"""Protocol defining the interface for external loggers."""
9-
10-
def log(self, data: Union[Dict[str, Any], BaseMessage]) -> None:
11-
"""
12-
Log structured data to an external system.
13-
9+
10+
def log(self, data: Union[dict[str, Any], BaseMessage]) -> None:
11+
"""Log structured data to an external system.
12+
1413
Args:
1514
data: The structured data to log, either as a dictionary or a BaseMessage
1615
"""
17-
pass
16+
pass

0 commit comments

Comments
 (0)