Skip to content

Commit d9513cc

Browse files
Move load_dotenv() before docstrings in all samples per SAMPLE_GUIDELINES ordering
Co-authored-by: eavanvalkenburg <[email protected]>
1 parent 8d6d986 commit d9513cc

193 files changed

Lines changed: 580 additions & 579 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎python/samples/01-get-started/01_hello_agent.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from azure.identity import AzureCliCredential
88
from dotenv import load_dotenv
99

10+
# Load environment variables from .env file
11+
load_dotenv()
12+
1013
"""
1114
Hello Agent — Simplest possible agent
1215
@@ -20,9 +23,6 @@
2023
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME — Model deployment name (e.g. gpt-4o)
2124
"""
2225

23-
# Load environment variables from .env file
24-
load_dotenv()
25-
2626

2727
async def main() -> None:
2828
# <create_agent>

‎python/samples/01-get-started/02_add_tools.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
from dotenv import load_dotenv
1212
from pydantic import Field
1313

14+
# Load environment variables from .env file
15+
load_dotenv()
16+
1417
"""
1518
Add Tools — Give your agent a function tool
1619
@@ -22,9 +25,6 @@
2225
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME — Model deployment name (e.g. gpt-4o)
2326
"""
2427

25-
# Load environment variables from .env file
26-
load_dotenv()
27-
2828

2929
# <define_tool>
3030
# NOTE: approval_mode="never_require" is for sample brevity.

‎python/samples/01-get-started/03_multi_turn.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from azure.identity import AzureCliCredential
88
from dotenv import load_dotenv
99

10+
# Load environment variables from .env file
11+
load_dotenv()
12+
1013
"""
1114
Multi-Turn Conversations — Use AgentSession to maintain context
1215
@@ -18,9 +21,6 @@
1821
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME — Model deployment name (e.g. gpt-4o)
1922
"""
2023

21-
# Load environment variables from .env file
22-
load_dotenv()
23-
2424

2525
async def main() -> None:
2626
# <create_agent>

‎python/samples/01-get-started/04_memory.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from azure.identity import AzureCliCredential
1010
from dotenv import load_dotenv
1111

12+
# Load environment variables from .env file
13+
load_dotenv()
14+
1215
"""
1316
Agent Memory with Context Providers
1417
@@ -21,9 +24,6 @@
2124
AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME — Model deployment name (e.g. gpt-4o)
2225
"""
2326

24-
# Load environment variables from .env file
25-
load_dotenv()
26-
2727

2828
# <context_provider>
2929
class UserNameProvider(BaseContextProvider):

‎python/samples/01-get-started/06_host_your_agent.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
from azure.identity import AzureCliCredential
77
from dotenv import load_dotenv
88

9+
# Load environment variables from .env file
10+
load_dotenv()
11+
912
"""Host your agent with Azure Functions.
1013
1114
This sample shows the Python hosting pattern used in docs:
@@ -21,9 +24,6 @@
2124
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
2225
"""
2326

24-
# Load environment variables from .env file
25-
load_dotenv()
26-
2727

2828
# <create_agent>
2929
def _create_agent() -> Any:

‎python/samples/02-agents/background_responses.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
from agent_framework.openai import OpenAIResponsesClient
77
from dotenv import load_dotenv
88

9+
# Load environment variables from .env file
10+
load_dotenv()
11+
912
"""Background Responses Sample.
1013
1114
This sample demonstrates long-running agent operations using the OpenAI
@@ -21,9 +24,6 @@
2124
- A model that benefits from background execution (e.g. ``o3``).
2225
"""
2326

24-
# Load environment variables from .env file
25-
load_dotenv()
26-
2727

2828
# 1. Create the agent with an OpenAI Responses client.
2929
agent = Agent(

‎python/samples/02-agents/chat_client/built_in_chat_clients.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
from dotenv import load_dotenv
1717
from pydantic import Field
1818

19+
# Load environment variables from .env file
20+
load_dotenv()
21+
1922
"""
2023
Built-in Chat Clients Example
2124
@@ -36,9 +39,6 @@
3639
- azure_ai_agent
3740
"""
3841

39-
# Load environment variables from .env file
40-
load_dotenv()
41-
4242
ClientName = Literal[
4343
"openai_chat",
4444
"openai_responses",

‎python/samples/02-agents/chat_client/chat_response_cancellation.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
from agent_framework.openai import OpenAIChatClient
66
from dotenv import load_dotenv
77

8+
# Load environment variables from .env file
9+
load_dotenv()
10+
811
"""
912
Chat Response Cancellation Example
1013
1114
Demonstrates proper cancellation of streaming chat responses during execution.
1215
Shows asyncio task cancellation and resource cleanup techniques.
1316
"""
1417

15-
# Load environment variables from .env file
16-
load_dotenv()
17-
1818

1919
async def main() -> None:
2020
"""

‎python/samples/02-agents/context_providers/azure_ai_search/azure_ai_with_search_context_agentic.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from azure.identity.aio import AzureCliCredential
99
from dotenv import load_dotenv
1010

11+
# Load environment variables from .env file
12+
load_dotenv()
13+
1114
"""
1215
This sample demonstrates how to use Azure AI Search with agentic mode for RAG
1316
(Retrieval Augmented Generation) with Azure AI agents.
@@ -40,9 +43,6 @@
4043
- AZURE_OPENAI_RESOURCE_URL: Azure OpenAI resource URL (e.g., "https://myresource.openai.azure.com")
4144
"""
4245

43-
# Load environment variables from .env file
44-
load_dotenv()
45-
4646
# Sample queries to demonstrate agentic RAG
4747
USER_INPUTS = [
4848
"What information is available in the knowledge base?",

‎python/samples/02-agents/context_providers/azure_ai_search/azure_ai_with_search_context_semantic.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
from azure.identity.aio import AzureCliCredential
99
from dotenv import load_dotenv
1010

11+
# Load environment variables from .env file
12+
load_dotenv()
13+
1114
"""
1215
This sample demonstrates how to use Azure AI Search with semantic mode for RAG
1316
(Retrieval Augmented Generation) with Azure AI agents.
@@ -29,9 +32,6 @@
2932
- AZURE_AI_MODEL_DEPLOYMENT_NAME: Your model deployment name (e.g., "gpt-4o")
3033
"""
3134

32-
# Load environment variables from .env file
33-
load_dotenv()
34-
3535
# Sample queries to demonstrate RAG
3636
USER_INPUTS = [
3737
"What information is available in the knowledge base?",

0 commit comments

Comments
 (0)