File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ async def test_view(tmp_path):
191191 )
192192 result = output .result
193193 assert result == content
194- output = await tool .run (input = ViewToolInput (path = test_file , view_range = ( 2 , - 1 ) )).middleware (
194+ output = await tool .run (input = ViewToolInput (path = test_file , view_range = [ 2 , - 1 ] )).middleware (
195195 GlobalTrajectoryMiddleware (pretty = True )
196196 )
197197 result = output .result
@@ -204,7 +204,7 @@ async def test_view(tmp_path):
204204 """
205205 )[1 :]
206206 )
207- output = await tool .run (input = ViewToolInput (path = test_file , view_range = ( 1 , 2 ) )).middleware (
207+ output = await tool .run (input = ViewToolInput (path = test_file , view_range = [ 1 , 2 ] )).middleware (
208208 GlobalTrajectoryMiddleware (pretty = True )
209209 )
210210 result = output .result
Original file line number Diff line number Diff line change 11import asyncio
22from pathlib import Path
33
4- from pydantic import BaseModel , Field
4+ from pydantic import BaseModel , Field , field_validator
55
66from beeai_framework .context import RunContext
77from beeai_framework .emitter import Emitter
@@ -39,15 +39,22 @@ async def _run(
3939
4040class ViewToolInput (BaseModel ):
4141 path : Path = Field (description = "Absolute path to a file or directory to view" )
42- view_range : tuple [ int , int ] | None = Field (
42+ view_range : list [ int ] | None = Field (
4343 description = """
44- Tuple of two integers specifying the start and end line numbers to view.
44+ List of two integers specifying the start and end line numbers to view.
4545 Line numbers are 1-indexed, and -1 for the end line means read to the end of the file.
4646 This argument only applies when viewing files, not directories.
4747 """ ,
4848 default = None ,
4949 )
5050
51+ @field_validator ("view_range" , mode = "after" )
52+ @classmethod
53+ def validate_view_range (cls , view_range : list [int ] | None ) -> list [int ] | None :
54+ if view_range is not None and len (view_range ) != 2 :
55+ raise ValueError ("`view_range` must be a list of two integers" )
56+ return view_range
57+
5158
5259class ViewTool (Tool [ViewToolInput , ToolRunOptions , StringToolOutput ]):
5360 name = "view"
You can’t perform that action at this time.
0 commit comments