You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/agents/includes/quickstart-python.md
+49-79Lines changed: 49 additions & 79 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,104 +48,74 @@ Next, to authenticate your API requests and run the program, use the [az login](
48
48
az login
49
49
```
50
50
51
-
Use the following code to create and run an agent. To run this code, you will need to create a connection string using information from your project. This string is in the format:
51
+
Use the following code to create and run an agent. To run this code, you will need to get the endpoint for your project. This string is in the format:
`HostName` can be found by navigating to your `discovery_url` and removing the leading `https://` and trailing `/discovery`. To find your `discovery_url`, run this CLI command:
58
-
59
-
```azurecli
60
-
az ml workspace show -n {project_name} --resource-group {resource_group_name} --query discovery_url
# The CodeInterpreterTool needs to be included in creation of the agent
84
+
with project_client:
85
+
# Create an agent with custom functions
93
86
agent = project_client.agents.create_agent(
94
-
model="gpt-4o-mini",
87
+
model=os.environ["MODEL_DEPLOYMENT_NAME"],
95
88
name="my-agent",
96
-
instructions="You are helpful agent",
97
-
tools=code_interpreter.definitions,
98
-
tool_resources=code_interpreter.resources,
89
+
instructions="You are a helpful agent"
99
90
)
100
-
print(f"Created agent, agent ID: {agent.id}")
91
+
print(f"Created agent, ID: {agent.id}")
101
92
102
-
# Create a thread
103
-
thread = project_client.agents.create_thread()
104
-
print(f"Created thread, thread ID: {thread.id}")
93
+
# Create a thread for communication
94
+
thread = project_client.agents.threads.create()
95
+
print(f"Created thread, ID: {thread.id}")
105
96
106
-
# Create a message
107
-
message = project_client.agents.create_message(
108
-
thread_id=thread.id,
109
-
role="user",
110
-
content="Could you please create a bar chart for the operating profit using the following data and provide the file to me? Company A: $1.2 million, Company B: $2.5 million, Company C: $3.0 million, Company D: $1.8 million",
0 commit comments