@@ -199,6 +199,75 @@ def list_threads(
199199 logger .info (thread .as_dict ())
200200
201201
202+ @app .command ()
203+ def create_message (
204+ role : str = typer .Option (
205+ "user" ,
206+ "--role" ,
207+ "-r" ,
208+ help = "The role of the message sender" ,
209+ ),
210+ content : str = typer .Option (
211+ "Hello, world!" ,
212+ "--content" ,
213+ "-c" ,
214+ help = "The content of the message" ,
215+ ),
216+ thread_id : str = typer .Option (
217+ "thread_xxx" ,
218+ "--thread-id" ,
219+ "-t" ,
220+ help = "The ID of the thread to list messages from" ,
221+ ),
222+ verbose : bool = typer .Option (
223+ False ,
224+ "--verbose" ,
225+ "-v" ,
226+ help = "Enable verbose output" ,
227+ ),
228+ ):
229+ # Set up logging
230+ if verbose :
231+ logger .setLevel (logging .DEBUG )
232+
233+ logger .info ("Creating message..." )
234+
235+ project_client = AzureAiFoundryWrapper ().get_ai_project_client ()
236+ message = project_client .agents .messages .create (
237+ thread_id = thread_id ,
238+ role = role ,
239+ content = content ,
240+ )
241+ logger .info (message .as_dict ())
242+
243+
244+ @app .command ()
245+ def list_messages (
246+ thread_id : str = typer .Option (
247+ "thread_xxx" ,
248+ "--thread-id" ,
249+ "-t" ,
250+ help = "The ID of the thread to list messages from" ,
251+ ),
252+ verbose : bool = typer .Option (
253+ False ,
254+ "--verbose" ,
255+ "-v" ,
256+ help = "Enable verbose output" ,
257+ ),
258+ ):
259+ # Set up logging
260+ if verbose :
261+ logger .setLevel (logging .DEBUG )
262+
263+ logger .info ("Listing messages..." )
264+
265+ project_client = AzureAiFoundryWrapper ().get_ai_project_client ()
266+ messages = project_client .agents .messages .list (thread_id = thread_id )
267+ for message in messages :
268+ logger .info (message .as_dict ())
269+
270+
202271if __name__ == "__main__" :
203272 load_dotenv (
204273 override = True ,
0 commit comments