kodeagent 0.12.2__tar.gz → 0.13.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kodeagent-0.12.2/src/kodeagent.egg-info → kodeagent-0.13.0}/PKG-INFO +7 -7
- {kodeagent-0.12.2 → kodeagent-0.13.0}/requirements.txt +6 -6
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/_version.py +1 -1
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/agents/csv_agent.py +6 -3
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/fca.py +10 -40
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/kodeagent.py +83 -146
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/kutils.py +4 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0/src/kodeagent.egg-info}/PKG-INFO +7 -7
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent.egg-info/requires.txt +6 -6
- {kodeagent-0.12.2 → kodeagent-0.13.0}/LICENSE +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/MANIFEST.in +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/README.md +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/pyproject.toml +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/setup.cfg +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/__init__.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/agents/__init__.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/code_reviewer.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/code_runner.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/examples.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/file_tracker.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/history_formatter.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/models.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/orchestrator.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/pattern_detector.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/agent_plan.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/code_guardrail.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/contextual_summary.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/observation.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/salvage_response.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/system/codeact.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/system/csv_analyst.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/system/function_calling.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/system/observer.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/system/plan_updater.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/system/planner.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/system/react.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/prompts/update_plan.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/tools.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/tracer.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent/usage_tracker.py +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent.egg-info/SOURCES.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent.egg-info/dependency_links.txt +0 -0
- {kodeagent-0.12.2 → kodeagent-0.13.0}/src/kodeagent.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kodeagent
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: A minimalistic approach to building AI agents
|
|
5
5
|
Author-email: Barun Saha <your.email@example.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/barun-saha/kodeagent
|
|
@@ -11,19 +11,19 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: litellm~=1.83.
|
|
14
|
+
Requires-Dist: litellm~=1.83.7
|
|
15
15
|
Requires-Dist: pydantic~=2.12.5
|
|
16
16
|
Requires-Dist: python-dotenv~=1.0.1
|
|
17
|
-
Requires-Dist: e2b-code-interpreter~=2.
|
|
17
|
+
Requires-Dist: e2b-code-interpreter~=2.6.0
|
|
18
18
|
Requires-Dist: requests~=2.33.1
|
|
19
|
-
Requires-Dist: json_repair~=0.
|
|
19
|
+
Requires-Dist: json_repair~=0.59.5
|
|
20
20
|
Requires-Dist: tenacity~=9.1.4
|
|
21
21
|
Requires-Dist: aiohttp~=3.13.4
|
|
22
22
|
Requires-Dist: protobuf~=6.33.5
|
|
23
23
|
Requires-Dist: h11~=0.16.0
|
|
24
|
-
Requires-Dist: rich~=
|
|
25
|
-
Requires-Dist: ddgs~=9.
|
|
26
|
-
Requires-Dist: lxml
|
|
24
|
+
Requires-Dist: rich~=15.0.0
|
|
25
|
+
Requires-Dist: ddgs~=9.14.1
|
|
26
|
+
Requires-Dist: lxml~=6.1.0
|
|
27
27
|
Requires-Dist: beautifulsoup4~=4.14.3
|
|
28
28
|
Requires-Dist: markitdown[docx,pdf,xlsx]~=0.1.5
|
|
29
29
|
Requires-Dist: youtube-transcript-api~=1.2.4
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
litellm~=1.83.
|
|
1
|
+
litellm~=1.83.7 # Higher versions require aiohttp==3.13.3
|
|
2
2
|
pydantic~=2.12.5
|
|
3
3
|
python-dotenv~=1.0.1 # Downgrade to avoid issues with litellm v1.83.2
|
|
4
|
-
e2b-code-interpreter~=2.
|
|
4
|
+
e2b-code-interpreter~=2.6.0
|
|
5
5
|
requests~=2.33.1
|
|
6
|
-
json_repair~=0.
|
|
6
|
+
json_repair~=0.59.5
|
|
7
7
|
tenacity~=9.1.4
|
|
8
8
|
aiohttp~=3.13.4
|
|
9
9
|
protobuf~=6.33.5
|
|
10
10
|
h11~=0.16.0
|
|
11
11
|
|
|
12
12
|
# Dependency for colored display on terminals
|
|
13
|
-
rich~=
|
|
13
|
+
rich~=15.0.0
|
|
14
14
|
|
|
15
15
|
# Dependencies for the tools
|
|
16
|
-
ddgs~=9.
|
|
17
|
-
lxml
|
|
16
|
+
ddgs~=9.14.1
|
|
17
|
+
lxml~=6.1.0
|
|
18
18
|
beautifulsoup4~=4.14.3
|
|
19
19
|
markitdown[pdf, docx, xlsx]~=0.1.5
|
|
20
20
|
youtube-transcript-api~=1.2.4
|
|
@@ -18,7 +18,6 @@ from dotenv import load_dotenv
|
|
|
18
18
|
|
|
19
19
|
load_dotenv()
|
|
20
20
|
|
|
21
|
-
from .. import kutils as ku
|
|
22
21
|
from ..kodeagent import ReActAgent
|
|
23
22
|
from ..models import AgentResponse
|
|
24
23
|
|
|
@@ -487,7 +486,11 @@ def sample_rows(filter_column: str, filter_value: str, n: int = 5) -> str:
|
|
|
487
486
|
|
|
488
487
|
n = min(n, 20)
|
|
489
488
|
try:
|
|
490
|
-
mask =
|
|
489
|
+
mask = (
|
|
490
|
+
df[filter_column]
|
|
491
|
+
.astype(str)
|
|
492
|
+
.str.contains(str(filter_value), case=False, na=False, regex=False)
|
|
493
|
+
)
|
|
491
494
|
subset = df[mask].head(n)
|
|
492
495
|
if len(subset) == 0:
|
|
493
496
|
return f'No rows found where {filter_column} contains "{filter_value}"'
|
|
@@ -635,4 +638,4 @@ async def main() -> None:
|
|
|
635
638
|
if __name__ == '__main__':
|
|
636
639
|
import asyncio
|
|
637
640
|
|
|
638
|
-
asyncio.run(main())
|
|
641
|
+
asyncio.run(main())
|
|
@@ -8,49 +8,18 @@ import json
|
|
|
8
8
|
import logging
|
|
9
9
|
import re
|
|
10
10
|
from collections.abc import AsyncIterator, Callable
|
|
11
|
-
from
|
|
12
|
-
from typing import Any, Literal, TypedDict
|
|
11
|
+
from typing import Any, Literal
|
|
13
12
|
|
|
14
13
|
import litellm
|
|
15
14
|
|
|
16
15
|
from . import kutils as ku
|
|
17
16
|
from . import tools as dtools
|
|
17
|
+
from .models import AgentResponse, Task
|
|
18
18
|
from .orchestrator import Planner
|
|
19
19
|
|
|
20
20
|
logger = logging.getLogger(__name__)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
@dataclass
|
|
24
|
-
class Task:
|
|
25
|
-
"""Represents a task for the agent to solve. A simplified version for SLMs."""
|
|
26
|
-
|
|
27
|
-
id: str | None
|
|
28
|
-
"""Optional unique identifier for the task."""
|
|
29
|
-
description: str
|
|
30
|
-
"""Text description of the task to be solved."""
|
|
31
|
-
result: str | None
|
|
32
|
-
"""Final result or answer after solving the task."""
|
|
33
|
-
steps_taken: int | None
|
|
34
|
-
"""Number of steps taken by the agent to solve the task."""
|
|
35
|
-
files: None = None
|
|
36
|
-
"""Unused placeholder only for compatibility with Planner."""
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class AgentResponse(TypedDict):
|
|
40
|
-
"""Streaming response sent by an agent in the course of solving a task.
|
|
41
|
-
This class is reproduced here to keep this module self-contained and optimized.
|
|
42
|
-
"""
|
|
43
|
-
|
|
44
|
-
type: Literal['step', 'final', 'log']
|
|
45
|
-
"""Type of the response: 'step', 'final', or 'log'."""
|
|
46
|
-
channel: str | None
|
|
47
|
-
"""Optional channel name for the response."""
|
|
48
|
-
value: Any
|
|
49
|
-
"""Value of the response, varies by type."""
|
|
50
|
-
metadata: dict[str, Any] | None
|
|
51
|
-
"""Optional metadata associated with the response."""
|
|
52
|
-
|
|
53
|
-
|
|
54
23
|
FCA_SYSTEM_PROMPT = ku.read_prompt('system/function_calling.txt')
|
|
55
24
|
FINAL_ANSWER_TOOL_NAME = 'final_answer'
|
|
56
25
|
|
|
@@ -411,7 +380,10 @@ class FunctionCallingAgent:
|
|
|
411
380
|
|
|
412
381
|
user_task_msg = ku.combine_user_messages(ku.make_user_message(task_description, task_files))
|
|
413
382
|
self.nudge_count = 0
|
|
414
|
-
|
|
383
|
+
task_kwargs: dict = {'description': task_desc}
|
|
384
|
+
if task_id is not None:
|
|
385
|
+
task_kwargs['id'] = task_id
|
|
386
|
+
self.task = Task(**task_kwargs)
|
|
415
387
|
self.chat_history = [
|
|
416
388
|
{'role': 'system', 'content': self.system_prompt},
|
|
417
389
|
*user_task_msg,
|
|
@@ -424,12 +396,10 @@ class FunctionCallingAgent:
|
|
|
424
396
|
)
|
|
425
397
|
await planner.create_plan(task=self.task, agent_type='fca')
|
|
426
398
|
formatted_plan = planner.get_formatted_plan()
|
|
427
|
-
self.chat_history.append(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
)
|
|
399
|
+
self.chat_history.append({
|
|
400
|
+
'role': 'user',
|
|
401
|
+
'content': f'Here is a plan for this task:\n{formatted_plan}',
|
|
402
|
+
})
|
|
433
403
|
logger.info('Task plan:\n%s\n', formatted_plan)
|
|
434
404
|
|
|
435
405
|
def _format_history_as_text(self) -> str:
|
|
@@ -11,6 +11,7 @@ import uuid
|
|
|
11
11
|
import warnings
|
|
12
12
|
from abc import ABC, abstractmethod
|
|
13
13
|
from collections.abc import AsyncIterator, Callable
|
|
14
|
+
from dataclasses import KW_ONLY, dataclass, field
|
|
14
15
|
from datetime import datetime
|
|
15
16
|
from json import JSONDecodeError
|
|
16
17
|
from typing import Any, ClassVar
|
|
@@ -72,95 +73,74 @@ MAX_RESPONSE_PARSING_ATTEMPTS = 3
|
|
|
72
73
|
MAX_TASK_FILES = 10
|
|
73
74
|
|
|
74
75
|
|
|
76
|
+
@dataclass
|
|
75
77
|
class Agent(ABC):
|
|
76
78
|
"""An abstract agent. Base class for all types of agents."""
|
|
77
79
|
|
|
80
|
+
model_name: str
|
|
81
|
+
_: KW_ONLY
|
|
82
|
+
name: str | None = None
|
|
83
|
+
description: str | None = None
|
|
84
|
+
tools: list[Callable] = field(default_factory=list)
|
|
85
|
+
litellm_params: dict = field(default_factory=dict)
|
|
86
|
+
persona: str | None = None
|
|
87
|
+
system_prompt: str | None = None
|
|
88
|
+
max_iterations: int = 20
|
|
89
|
+
filter_tools_for_task: bool = False
|
|
90
|
+
max_retries: int = ku.DEFAULT_MAX_LLM_RETRIES
|
|
91
|
+
work_dir: str | None = None
|
|
92
|
+
tracing_type: TRACING_TYPES | None = None
|
|
93
|
+
|
|
94
|
+
# Internal state (not in __init__)
|
|
95
|
+
id: uuid.UUID = field(init=False)
|
|
96
|
+
tool_name_to_func: dict[str, Callable] = field(init=False)
|
|
97
|
+
tool_names: set[str] = field(init=False)
|
|
98
|
+
task: Task | None = field(init=False, default=None)
|
|
99
|
+
chat_history: list[dict] = field(init=False, default_factory=list)
|
|
100
|
+
usage_tracker: UsageTracker = field(init=False, default_factory=UsageTracker)
|
|
101
|
+
tracer_manager: tracer.AbstractTracerManager = field(init=False)
|
|
102
|
+
current_trace: tracer.AbstractObservation | None = field(init=False, default=None)
|
|
103
|
+
planner: Planner | None = field(init=False, default=None)
|
|
104
|
+
observer: Observer = field(init=False)
|
|
105
|
+
is_visual_model: bool = field(init=False)
|
|
106
|
+
task_output_files: list[str] = field(init=False, default_factory=list)
|
|
107
|
+
|
|
108
|
+
msg_idx_of_new_task: int = field(init=False, default=0)
|
|
109
|
+
final_answer_found: bool = field(init=False, default=False)
|
|
110
|
+
|
|
111
|
+
_history_formatter: HistoryFormatter | None = field(init=False, default=None)
|
|
112
|
+
_tool_descriptions_cache: dict[frozenset[str], str] = field(init=False, default_factory=dict)
|
|
113
|
+
|
|
78
114
|
response_format_class: ClassVar[type[pyd.BaseModel]] = ChatMessage
|
|
79
115
|
HISTORY_TRUNCATE_CHARS: ClassVar[int] = 1000
|
|
80
116
|
|
|
81
|
-
def
|
|
82
|
-
|
|
83
|
-
name: str,
|
|
84
|
-
model_name: str,
|
|
85
|
-
description: str | None = None,
|
|
86
|
-
tools: list[Callable] | None = None,
|
|
87
|
-
litellm_params: dict | None = None,
|
|
88
|
-
persona: str | None = None,
|
|
89
|
-
system_prompt: str | None = None,
|
|
90
|
-
max_iterations: int = 20,
|
|
91
|
-
filter_tools_for_task: bool = False,
|
|
92
|
-
max_retries: int = ku.DEFAULT_MAX_LLM_RETRIES,
|
|
93
|
-
work_dir: str | None = None,
|
|
94
|
-
tracing_type: TRACING_TYPES | None = None,
|
|
95
|
-
):
|
|
96
|
-
"""Create an agent.
|
|
97
|
-
|
|
98
|
-
Args:
|
|
99
|
-
name: The name of the agent.
|
|
100
|
-
model_name: The (LiteLLM) model name to use.
|
|
101
|
-
description: Optional brief description about the agent.
|
|
102
|
-
tools: An optional list of tools available to the agent.
|
|
103
|
-
litellm_params: LiteLLM parameters.
|
|
104
|
-
persona: Optional persona for the agent. If provided, this gets added to
|
|
105
|
-
the system prompt.
|
|
106
|
-
system_prompt: Optional system prompt for the agent. If not provided, default is used.
|
|
107
|
-
This is mutually exclusive with persona.
|
|
108
|
-
max_iterations: The max iterations an agent can perform to solve a task.
|
|
109
|
-
filter_tools_for_task: Whether the tools should be filtered for a task. Unused.
|
|
110
|
-
max_retries: Maximum number of retries for LLM calls.
|
|
111
|
-
work_dir: Optional local workspace directory.
|
|
112
|
-
tracing_type: Type of tracing to use.
|
|
113
|
-
"""
|
|
117
|
+
def __post_init__(self):
|
|
118
|
+
"""Initialize the agent's internal state after fields are set."""
|
|
114
119
|
self.id = uuid.uuid4()
|
|
115
|
-
self.name: str = name
|
|
116
|
-
self.description = description
|
|
117
|
-
self.model_name: str = model_name
|
|
118
|
-
self.work_dir = work_dir
|
|
119
|
-
|
|
120
|
-
self.tools: list[Callable] = tools or []
|
|
121
|
-
self.filter_tools_for_task = filter_tools_for_task
|
|
122
|
-
self.litellm_params: dict = litellm_params or {}
|
|
123
|
-
self.persona = persona
|
|
124
|
-
self.system_prompt = system_prompt
|
|
125
|
-
self.max_iterations = max_iterations
|
|
126
|
-
self.max_retries = max_retries
|
|
127
|
-
|
|
128
120
|
self.tool_name_to_func = {fn.__name__: fn for fn in self.tools}
|
|
129
121
|
self.tool_names = set(self.tool_name_to_func)
|
|
130
122
|
|
|
131
|
-
|
|
132
|
-
self.
|
|
123
|
+
# Tracing initialization
|
|
124
|
+
self.tracer_manager = create_tracer_manager(self.tracing_type)
|
|
133
125
|
|
|
134
|
-
|
|
135
|
-
self.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
self.final_answer_found = False
|
|
139
|
-
|
|
140
|
-
self.usage_tracker = UsageTracker()
|
|
141
|
-
|
|
142
|
-
# Tracing
|
|
143
|
-
self.tracer_manager: tracer.AbstractTracerManager = create_tracer_manager(tracing_type)
|
|
144
|
-
self.current_trace: tracer.AbstractObservation | None = None
|
|
145
|
-
|
|
146
|
-
self.planner: Planner | None = Planner(
|
|
147
|
-
model_name=model_name,
|
|
148
|
-
litellm_params=litellm_params,
|
|
126
|
+
# Components initialization
|
|
127
|
+
self.planner = Planner(
|
|
128
|
+
model_name=self.model_name,
|
|
129
|
+
litellm_params=self.litellm_params,
|
|
149
130
|
max_retries=self.max_retries,
|
|
150
131
|
usage_tracker=self.usage_tracker,
|
|
151
132
|
tracer_manager=self.tracer_manager,
|
|
152
133
|
)
|
|
153
134
|
self.observer = Observer(
|
|
154
|
-
model_name=model_name,
|
|
155
|
-
litellm_params=litellm_params,
|
|
135
|
+
model_name=self.model_name,
|
|
136
|
+
litellm_params=self.litellm_params,
|
|
156
137
|
tool_names=self.tool_names,
|
|
157
138
|
max_retries=self.max_retries,
|
|
158
139
|
usage_tracker=self.usage_tracker,
|
|
159
140
|
tracer_manager=self.tracer_manager,
|
|
160
141
|
)
|
|
161
142
|
|
|
162
|
-
self.is_visual_model
|
|
163
|
-
self.task_output_files: list[str] = []
|
|
143
|
+
self.is_visual_model = llm_vision_support([self.model_name])[0] or False
|
|
164
144
|
|
|
165
145
|
def __str__(self):
|
|
166
146
|
"""String representation of the agent."""
|
|
@@ -603,44 +583,21 @@ class Agent(ABC):
|
|
|
603
583
|
}
|
|
604
584
|
|
|
605
585
|
|
|
586
|
+
@dataclass
|
|
606
587
|
class ReActAgent(Agent):
|
|
607
588
|
"""Reasoning and Acting agent with thought-action-observation loop."""
|
|
608
589
|
|
|
590
|
+
_: KW_ONLY
|
|
591
|
+
system_prompt: str = REACT_SYSTEM_PROMPT
|
|
592
|
+
|
|
609
593
|
response_format_class: ClassVar[type[pyd.BaseModel]] = ReActChatMessage
|
|
610
594
|
|
|
611
|
-
def
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
model_name: str,
|
|
615
|
-
tools: list,
|
|
616
|
-
description: str | None = None,
|
|
617
|
-
litellm_params: dict | None = None,
|
|
618
|
-
persona: str | None = None,
|
|
619
|
-
system_prompt: str | None = None,
|
|
620
|
-
max_iterations: int = 20,
|
|
621
|
-
filter_tools_for_task: bool = False,
|
|
622
|
-
max_retries: int = ku.DEFAULT_MAX_LLM_RETRIES,
|
|
623
|
-
work_dir: str | None = None,
|
|
624
|
-
tracing_type: TRACING_TYPES | None = None,
|
|
625
|
-
):
|
|
626
|
-
"""Create a ReAct agent."""
|
|
627
|
-
super().__init__(
|
|
628
|
-
name=name,
|
|
629
|
-
model_name=model_name,
|
|
630
|
-
tools=tools,
|
|
631
|
-
litellm_params=litellm_params,
|
|
632
|
-
description=description,
|
|
633
|
-
persona=persona,
|
|
634
|
-
system_prompt=system_prompt or REACT_SYSTEM_PROMPT,
|
|
635
|
-
max_iterations=max_iterations,
|
|
636
|
-
filter_tools_for_task=filter_tools_for_task,
|
|
637
|
-
max_retries=max_retries,
|
|
638
|
-
work_dir=work_dir,
|
|
639
|
-
tracing_type=tracing_type,
|
|
640
|
-
)
|
|
595
|
+
def __post_init__(self):
|
|
596
|
+
"""Perform ReAct-specific setup."""
|
|
597
|
+
super().__post_init__()
|
|
641
598
|
|
|
642
|
-
if tools:
|
|
643
|
-
logger.info('Created agent: %s; tools: %s', name, [t.__name__ for t in tools])
|
|
599
|
+
if self.tools:
|
|
600
|
+
logger.info('Created agent: %s; tools: %s', self.name, [t.__name__ for t in self.tools])
|
|
644
601
|
|
|
645
602
|
self._history_formatter = ReActHistoryFormatter()
|
|
646
603
|
|
|
@@ -1333,7 +1290,11 @@ class ReActAgent(Agent):
|
|
|
1333
1290
|
|
|
1334
1291
|
# Use role='tool' for tool errors too
|
|
1335
1292
|
self.add_to_history(
|
|
1336
|
-
{
|
|
1293
|
+
{
|
|
1294
|
+
'role': 'tool',
|
|
1295
|
+
'content': result,
|
|
1296
|
+
'tool_call_id': tool_call_id,
|
|
1297
|
+
}
|
|
1337
1298
|
)
|
|
1338
1299
|
yield self.response(
|
|
1339
1300
|
rtype='step',
|
|
@@ -1464,67 +1425,43 @@ class ReActAgent(Agent):
|
|
|
1464
1425
|
)
|
|
1465
1426
|
|
|
1466
1427
|
|
|
1428
|
+
@dataclass
|
|
1467
1429
|
class CodeActAgent(ReActAgent):
|
|
1468
1430
|
"""CodeAct agent using Thought-Code-Observation loop."""
|
|
1469
1431
|
|
|
1432
|
+
_: KW_ONLY
|
|
1433
|
+
run_env: CODE_ENV_NAMES = 'host'
|
|
1434
|
+
allowed_imports: list[str] | None = None
|
|
1435
|
+
pip_packages: str | None = None
|
|
1436
|
+
timeout: int = 30
|
|
1437
|
+
env_vars_to_set: dict[str, str] | None = None
|
|
1438
|
+
system_prompt: str = CODE_ACT_SYSTEM_PROMPT
|
|
1439
|
+
|
|
1470
1440
|
response_format_class: ClassVar[type[pyd.BaseModel]] = CodeActChatMessage
|
|
1471
1441
|
|
|
1472
|
-
def
|
|
1473
|
-
self,
|
|
1474
|
-
name: str,
|
|
1475
|
-
model_name: str,
|
|
1476
|
-
run_env: CODE_ENV_NAMES,
|
|
1477
|
-
tools: list[Callable] | None = None,
|
|
1478
|
-
description: str | None = None,
|
|
1479
|
-
litellm_params: dict | None = None,
|
|
1480
|
-
persona: str | None = None,
|
|
1481
|
-
system_prompt: str | None = None,
|
|
1482
|
-
max_iterations: int = 20,
|
|
1483
|
-
allowed_imports: list[str] | None = None,
|
|
1484
|
-
pip_packages: str | None = None,
|
|
1485
|
-
timeout: int = 30,
|
|
1486
|
-
env_vars_to_set: dict[str, str] | None = None,
|
|
1487
|
-
filter_tools_for_task: bool = False,
|
|
1488
|
-
max_retries: int = ku.DEFAULT_MAX_LLM_RETRIES,
|
|
1489
|
-
work_dir: str | None = None,
|
|
1490
|
-
tracing_type: TRACING_TYPES | None = None,
|
|
1491
|
-
):
|
|
1442
|
+
def __post_init__(self):
|
|
1492
1443
|
"""Initialize CodeAct agent."""
|
|
1493
|
-
super().
|
|
1494
|
-
|
|
1495
|
-
model_name=model_name,
|
|
1496
|
-
tools=tools,
|
|
1497
|
-
litellm_params=litellm_params,
|
|
1498
|
-
max_iterations=max_iterations,
|
|
1499
|
-
persona=persona,
|
|
1500
|
-
system_prompt=system_prompt or CODE_ACT_SYSTEM_PROMPT,
|
|
1501
|
-
description=description,
|
|
1502
|
-
filter_tools_for_task=filter_tools_for_task,
|
|
1503
|
-
max_retries=max_retries,
|
|
1504
|
-
work_dir=work_dir,
|
|
1505
|
-
tracing_type=tracing_type,
|
|
1506
|
-
)
|
|
1444
|
+
super().__post_init__()
|
|
1445
|
+
|
|
1507
1446
|
self._history_formatter = CodeActHistoryFormatter()
|
|
1508
1447
|
self.tools_source_code: str = 'from typing import *\n\n'
|
|
1509
1448
|
|
|
1510
|
-
if tools:
|
|
1449
|
+
if self.tools:
|
|
1511
1450
|
for t in self.tools:
|
|
1512
1451
|
self.tools_source_code += inspect.getsource(t).replace('@tool\n', '', 1) + '\n'
|
|
1513
1452
|
|
|
1514
|
-
self.
|
|
1453
|
+
if not self.allowed_imports:
|
|
1454
|
+
self.allowed_imports = []
|
|
1515
1455
|
|
|
1516
|
-
|
|
1517
|
-
allowed_imports = []
|
|
1518
|
-
|
|
1519
|
-
self.allowed_imports = allowed_imports + ['datetime', 'typing', 'mimetypes']
|
|
1456
|
+
self.allowed_imports = self.allowed_imports + ['datetime', 'typing', 'mimetypes']
|
|
1520
1457
|
self.code_runner = CodeRunner(
|
|
1521
|
-
env=run_env,
|
|
1458
|
+
env=self.run_env,
|
|
1522
1459
|
allowed_imports=self.allowed_imports,
|
|
1523
|
-
model_name=model_name,
|
|
1524
|
-
pip_packages=pip_packages,
|
|
1525
|
-
timeout=timeout,
|
|
1526
|
-
env_vars_to_set=env_vars_to_set,
|
|
1527
|
-
litellm_params=litellm_params,
|
|
1460
|
+
model_name=self.model_name,
|
|
1461
|
+
pip_packages=self.pip_packages,
|
|
1462
|
+
timeout=self.timeout,
|
|
1463
|
+
env_vars_to_set=self.env_vars_to_set,
|
|
1464
|
+
litellm_params=self.litellm_params,
|
|
1528
1465
|
work_dir=self.work_dir,
|
|
1529
1466
|
usage_tracker=self.usage_tracker,
|
|
1530
1467
|
tool_names=self.tool_names,
|
|
@@ -45,13 +45,17 @@ LOGGERS_TO_SUPPRESS = [
|
|
|
45
45
|
'hpack',
|
|
46
46
|
'httpx',
|
|
47
47
|
'httpcore',
|
|
48
|
+
'hyper_util',
|
|
49
|
+
'h2',
|
|
48
50
|
'langfuse',
|
|
49
51
|
'LiteLLM',
|
|
50
52
|
'litellm',
|
|
51
53
|
'openai',
|
|
52
54
|
'pdfminer',
|
|
53
55
|
'primp',
|
|
56
|
+
'reqwest',
|
|
54
57
|
'rquest',
|
|
58
|
+
'rustls',
|
|
55
59
|
'urllib3',
|
|
56
60
|
'urllib3.connectionpool',
|
|
57
61
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kodeagent
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: A minimalistic approach to building AI agents
|
|
5
5
|
Author-email: Barun Saha <your.email@example.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/barun-saha/kodeagent
|
|
@@ -11,19 +11,19 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: litellm~=1.83.
|
|
14
|
+
Requires-Dist: litellm~=1.83.7
|
|
15
15
|
Requires-Dist: pydantic~=2.12.5
|
|
16
16
|
Requires-Dist: python-dotenv~=1.0.1
|
|
17
|
-
Requires-Dist: e2b-code-interpreter~=2.
|
|
17
|
+
Requires-Dist: e2b-code-interpreter~=2.6.0
|
|
18
18
|
Requires-Dist: requests~=2.33.1
|
|
19
|
-
Requires-Dist: json_repair~=0.
|
|
19
|
+
Requires-Dist: json_repair~=0.59.5
|
|
20
20
|
Requires-Dist: tenacity~=9.1.4
|
|
21
21
|
Requires-Dist: aiohttp~=3.13.4
|
|
22
22
|
Requires-Dist: protobuf~=6.33.5
|
|
23
23
|
Requires-Dist: h11~=0.16.0
|
|
24
|
-
Requires-Dist: rich~=
|
|
25
|
-
Requires-Dist: ddgs~=9.
|
|
26
|
-
Requires-Dist: lxml
|
|
24
|
+
Requires-Dist: rich~=15.0.0
|
|
25
|
+
Requires-Dist: ddgs~=9.14.1
|
|
26
|
+
Requires-Dist: lxml~=6.1.0
|
|
27
27
|
Requires-Dist: beautifulsoup4~=4.14.3
|
|
28
28
|
Requires-Dist: markitdown[docx,pdf,xlsx]~=0.1.5
|
|
29
29
|
Requires-Dist: youtube-transcript-api~=1.2.4
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
litellm~=1.83.
|
|
1
|
+
litellm~=1.83.7
|
|
2
2
|
pydantic~=2.12.5
|
|
3
3
|
python-dotenv~=1.0.1
|
|
4
|
-
e2b-code-interpreter~=2.
|
|
4
|
+
e2b-code-interpreter~=2.6.0
|
|
5
5
|
requests~=2.33.1
|
|
6
|
-
json_repair~=0.
|
|
6
|
+
json_repair~=0.59.5
|
|
7
7
|
tenacity~=9.1.4
|
|
8
8
|
aiohttp~=3.13.4
|
|
9
9
|
protobuf~=6.33.5
|
|
10
10
|
h11~=0.16.0
|
|
11
|
-
rich~=
|
|
12
|
-
ddgs~=9.
|
|
13
|
-
lxml
|
|
11
|
+
rich~=15.0.0
|
|
12
|
+
ddgs~=9.14.1
|
|
13
|
+
lxml~=6.1.0
|
|
14
14
|
beautifulsoup4~=4.14.3
|
|
15
15
|
markitdown[docx,pdf,xlsx]~=0.1.5
|
|
16
16
|
youtube-transcript-api~=1.2.4
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|