Skip to content

Commit 1f52e1b

Browse files
committed
create/delete/list thread
1 parent b83270d commit 1f52e1b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

scripts/azure_ai_foundry_operator.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,71 @@ def list_agents(
134134
logger.info(f"Agent ID: {agent.id}, Name: {agent.name}")
135135

136136

137+
@app.command()
138+
def create_thread(
139+
verbose: bool = typer.Option(
140+
False,
141+
"--verbose",
142+
"-v",
143+
help="Enable verbose output",
144+
),
145+
):
146+
# Set up logging
147+
if verbose:
148+
logger.setLevel(logging.DEBUG)
149+
150+
logger.info("Creating thread...")
151+
152+
project_client = AzureAiFoundryWrapper().get_ai_project_client()
153+
thread = project_client.agents.threads.create()
154+
logger.info(thread.as_dict())
155+
156+
157+
@app.command()
158+
def delete_thread(
159+
thread_id: str = typer.Option(
160+
"thread_xxx",
161+
"--thread-id",
162+
"-t",
163+
help="The ID of the thread to delete",
164+
),
165+
verbose: bool = typer.Option(
166+
False,
167+
"--verbose",
168+
"-v",
169+
help="Enable verbose output",
170+
),
171+
):
172+
# Set up logging
173+
if verbose:
174+
logger.setLevel(logging.DEBUG)
175+
176+
logger.info("Deleting thread...")
177+
project_client = AzureAiFoundryWrapper().get_ai_project_client()
178+
project_client.agents.threads.delete(thread_id=thread_id)
179+
180+
181+
@app.command()
182+
def list_threads(
183+
verbose: bool = typer.Option(
184+
False,
185+
"--verbose",
186+
"-v",
187+
help="Enable verbose output",
188+
),
189+
):
190+
# Set up logging
191+
if verbose:
192+
logger.setLevel(logging.DEBUG)
193+
194+
logger.info("Listing threads...")
195+
196+
project_client = AzureAiFoundryWrapper().get_ai_project_client()
197+
threads = project_client.agents.threads.list()
198+
for thread in threads:
199+
logger.info(thread.as_dict())
200+
201+
137202
if __name__ == "__main__":
138203
load_dotenv(
139204
override=True,

0 commit comments

Comments
 (0)