33import logging
44import uuid
55from abc import ABC
6- from typing import List , Optional , Type , cast
6+ from typing import Any , Dict , List , Optional , Type , cast
77
88from steamship import Block , Steamship , Task
99from steamship .agents .base import AgentContext , BaseTool
@@ -45,7 +45,7 @@ def _make_public_url(self, block):
4545 upload_to_signed_url (signed_url , block .raw ())
4646 return read_signed_url
4747
48- def print_blocks (self , blocks : List [Block ]):
48+ def print_blocks (self , blocks : List [Block ], metadata : Dict [ str , Any ] ):
4949 """Print a list of blocks to console."""
5050 for block in blocks :
5151 if isinstance (block , dict ):
@@ -104,7 +104,7 @@ def colored(message: str, color: str):
104104 print (f"Task: { output .task_id } " )
105105 else :
106106 blocks = cast (List [Block ], output )
107- self .print_blocks (blocks )
107+ self .print_blocks (blocks , {} )
108108
109109 def run (self ):
110110 with self .temporary_workspace () as client :
@@ -114,11 +114,18 @@ def run(self):
114114class AgentREPL (SteamshipREPL ):
115115 agent_class : Type [AgentService ]
116116 client = Steamship
117-
118- def __init__ (self , agent_class : Type [AgentService ], client : Optional [Steamship ] = None ):
117+ config = None
118+
119+ def __init__ (
120+ self ,
121+ agent_class : Type [AgentService ],
122+ agent_package_config : Optional [Dict [str , Any ]],
123+ client : Optional [Steamship ] = None ,
124+ ):
119125 super ().__init__ ()
120126 self .agent_class = agent_class
121127 self .client = client or Steamship ()
128+ self .config = agent_package_config
122129
123130 def run_with_client (self , client : Steamship ):
124131 try :
@@ -134,7 +141,7 @@ def colored(message: str, color: str):
134141 print (f"Chat ID: { chat_id } " )
135142 print ("If you make code changes, restart this REPL. Press CTRL+C to exit at any time.\n " )
136143
137- agent = self .agent_class (client = client )
144+ agent = self .agent_class (client = client , config = self . config )
138145
139146 while True :
140147 input_text = input (colored ("Input: " , "blue" )) # noqa: F821
@@ -151,8 +158,11 @@ def colored(message: str, color: str):
151158 text = input_text
152159 ) # Should this take a Block, instead of creating a block?
153160 message .set_message_id (message_id )
161+ if len (context .emit_funcs ) == 0 :
162+ context .emit_funcs .append (self .print_blocks )
154163 response : Optional [List [Block ]] = agent .run_agent (context )
155- self .print_blocks (response )
164+ if response is not None :
165+ self .print_blocks (response , {})
156166
157167 def run (self ):
158168 with self .temporary_workspace () as client :
0 commit comments