@@ -289,7 +289,7 @@ Here is an example to use `tools` and `tool_resources`:
289289``` python
290290file_search_tool = FileSearchTool(vector_store_ids = [vector_store.id])
291291
292- # notices that FileSearchTool as tool and tool_resources must be added or the assistant unable to search the file
292+ # Notices that FileSearchTool as tool and tool_resources must be added or the assistant unable to search the file
293293agent = project_client.agents.create_agent(
294294 model = " gpt-4-1106-preview" ,
295295 name = " my-assistant" ,
@@ -396,7 +396,7 @@ print(f"Uploaded file, file ID: {file.id}")
396396
397397code_interpreter = CodeInterpreterTool(file_ids = [file .id])
398398
399- # create agent with code interpreter tool and tools_resources
399+ # Create agent with code interpreter tool and tools_resources
400400agent = project_client.agents.create_agent(
401401 model = " gpt-4-1106-preview" ,
402402 name = " my-assistant" ,
@@ -432,6 +432,7 @@ with project_client:
432432 name = " my-assistant" ,
433433 instructions = " You are a helpful assistant" ,
434434 tools = bing.definitions,
435+ headers = {" x-ms-enable-preview" : " true" },
435436 )
436437```
437438
@@ -466,6 +467,7 @@ with project_client:
466467 instructions = " You are a helpful assistant" ,
467468 tools = ai_search.definitions,
468469 tool_resources = ai_search.resources,
470+ headers = {" x-ms-enable-preview" : " true" },
469471 )
470472```
471473
@@ -510,7 +512,10 @@ toolset = AsyncToolSet()
510512toolset.add(functions)
511513
512514agent = await project_client.agents.create_agent(
513- model = " gpt-4-1106-preview" , name = " my-assistant" , instructions = " You are a helpful assistant" , toolset = toolset
515+ model = " gpt-4-1106-preview" ,
516+ name = " my-assistant" ,
517+ instructions = " You are a helpful assistant" ,
518+ toolset = toolset,
514519)
515520```
516521
@@ -572,21 +577,14 @@ auth = OpenApiAnonymousAuthDetails()
572577
573578# Initialize agent OpenApi tool using the read in OpenAPI spec
574579openapi = OpenApiTool(
575- name = " get_weather" ,
576- spec = openapi_spec,
577- description = " Retrieve weather information for a location" ,
578- auth = auth
580+ name = " get_weather" , spec = openapi_spec, description = " Retrieve weather information for a location" , auth = auth
579581)
580582
581583# Create agent with OpenApi tool and process assistant run
582584with project_client:
583585 agent = project_client.agents.create_agent(
584- model = " gpt-4o-mini" ,
585- name = " my-assistant" ,
586- instructions = " You are a helpful assistant" ,
587- tools = openapi.definitions
586+ model = " gpt-4o-mini" , name = " my-assistant" , instructions = " You are a helpful assistant" , tools = openapi.definitions
588587 )
589-
590588```
591589
592590<!-- END SNIPPET -->
@@ -670,7 +668,7 @@ Here is an example to pass `CodeInterpreterTool` as tool:
670668<!-- SNIPPET:sample_agents_with_code_interpreter_file_attachment.create_agent_and_message_with_code_interpreter_file_attachment -->
671669
672670``` python
673- # notice that CodeInterpreter must be enabled in the agent creation,
671+ # Notice that CodeInterpreter must be enabled in the agent creation,
674672# otherwise the agent will not be able to see the file attachment for code interpretation
675673agent = project_client.agents.create_agent(
676674 model = " gpt-4-1106-preview" ,
@@ -683,10 +681,10 @@ print(f"Created agent, agent ID: {agent.id}")
683681thread = project_client.agents.create_thread()
684682print (f " Created thread, thread ID: { thread.id} " )
685683
686- # create an attachment
684+ # Create an attachment
687685attachment = MessageAttachment(file_id = file .id, tools = CodeInterpreterTool().definitions)
688686
689- # create a message
687+ # Create a message
690688message = project_client.agents.create_message(
691689 thread_id = thread.id,
692690 role = " user" ,
@@ -697,23 +695,6 @@ message = project_client.agents.create_message(
697695
698696<!-- END SNIPPET -->
699697
700- Azure blob storage can be used as a message attachment. In this case ` VectorStoreDataSource ` have to be used as a data source:
701-
702- <!-- SNIPPET:sample_agents_vector_store_batch_enterprise_file_search.upload_file_and_create_message_with_code_interpreter -->
703-
704- ``` python
705- # We will upload the local file to Azure and will use it for vector store creation.
706- _, asset_uri = project_client.upload_file(" ./product_info_1.md" )
707- ds = VectorStoreDataSource(asset_identifier = asset_uri, asset_type = VectorStoreDataSourceAssetType.URI_ASSET )
708-
709- # Create a message with the attachment
710- attachment = MessageAttachment(data_source = ds, tools = code_interpreter.definitions)
711- message = project_client.agents.create_message(
712- thread_id = thread.id, role = " user" , content = " What does the attachment say?" , attachments = [attachment]
713- )
714- ```
715-
716- <!-- END SNIPPET -->
717698
718699#### Create Run, Run_and_Process, or Stream
719700
@@ -728,9 +709,9 @@ Here is an example of `create_run` and poll until the run is completed:
728709``` python
729710run = project_client.agents.create_run(thread_id = thread.id, assistant_id = agent.id)
730711
731- # poll the run as long as run status is queued or in progress
712+ # Poll the run as long as run status is queued or in progress
732713while run.status in [" queued" , " in_progress" , " requires_action" ]:
733- # wait for a second
714+ # Wait for a second
734715 time.sleep(1 )
735716 run = project_client.agents.get_run(thread_id = thread.id, run_id = run.id)
736717```
0 commit comments