Skip to content

Commit 2f19cb3

Browse files
author
Xue Cai
committed
fix: web-search-agent local development setup
- Add load_dotenv() to main.py for local .env file support - Fix AzureAIAgentClient parameter names (project_endpoint, credential) - Update README with local development instructions
1 parent 6547276 commit 2f19cb3

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

samples/python/hosted-agents/agent_framework/web-search-agent/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,49 @@
1+
# Web Search Agent
2+
3+
A hosted agent that uses Bing Grounding to search the web for current information.
4+
5+
## Local Development
6+
7+
### Prerequisites
8+
9+
- Python 3.10+
10+
- Azure CLI logged in (`az login`)
11+
- An Azure AI Foundry project with a Bing Grounding connection
12+
13+
### Setup
14+
15+
1. Create a virtual environment and install dependencies:
16+
17+
```bash
18+
python -m venv .venv
19+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
20+
pip install -r requirements.txt
21+
```
22+
23+
2. Create a `.env` file with the following environment variables:
24+
25+
```bash
26+
AZURE_AI_PROJECT_ENDPOINT=https://<your-foundry-account>.services.ai.azure.com/api/projects/<your-project>
27+
AZURE_AI_MODEL_DEPLOYMENT_NAME=<your-model-deployment> # e.g., gpt-4.1-mini
28+
BING_GROUNDING_CONNECTION_ID=/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.CognitiveServices/accounts/<foundry-account>/projects/<project>/connections/<bing-connection-name>
29+
```
30+
31+
### Run the agent locally
32+
33+
```bash
34+
python main.py
35+
```
36+
37+
The server will start on `http://localhost:8088`.
38+
39+
### Test the agent
40+
41+
```bash
42+
curl -X POST http://localhost:8088/responses \
43+
-H "Content-Type: application/json" \
44+
-d '{"input": "What is the latest news in AI?"}' | jq .
45+
```
46+
147
## Troubleshooting
248

349
### Images built on Apple Silicon or other ARM64 machines do not work on our service

samples/python/hosted-agents/agent_framework/web-search-agent/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def create_agent() -> ChatAgent:
1717
)
1818

1919
chat_client = AzureAIAgentClient(
20-
endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
21-
async_credential=DefaultAzureCredential(),
20+
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
21+
credential=DefaultAzureCredential(),
2222
)
2323

2424
bing_search_tool = HostedWebSearchTool(

0 commit comments

Comments
 (0)