* refactor(ai): use responses API for OpenAI/Azure, create 'other' provider for completion endpoint - Created new 'other.rs' provider using the OpenAI-compatible completion endpoint - Refactored 'openai.rs' to use the Responses API for both text and image output - Updated query_builder to route OpenAI/AzureOpenAI to OpenAIQueryBuilder - All other providers (Mistral, DeepSeek, Groq, etc.) now use OtherQueryBuilder - Updated OpenRouter to delegate to OtherQueryBuilder instead of OpenAIQueryBuilder This prepares the codebase for adding websearch tool support using the Responses API. Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * feat(ai): add websearch as AI agent tool type - Added WebsearchToolValue to ToolValue enum in flows.rs - Updated all pattern matches to handle websearch tool type - Added has_websearch parameter to run_agent function - Websearch tools don't require additional configuration This prepares the backend for provider-specific websearch implementations. Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * feat(frontend): add websearch as tool option in AI agent UI - Added WebsearchTool type and utility functions to agentToolUtils.ts - Added "Web Search" option in tool insertion menu (InsertModuleInner) - Updated NewAIToolNode to handle pickWebsearchTool event - Updated AIToolNode to render websearch tools properly - Updated FlowModuleSchemaMap to create websearch tools Users can now add websearch tools to AI agents through the UI. Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * feat(ai): implement websearch for OpenAI provider - Added has_websearch parameter to BuildRequestArgs - OpenAI provider now adds web_search tool to requests when enabled - Uses OpenAI Responses API web_search tool type - Websearch tool is added before other custom tools in the request Implements websearch functionality for OpenAI and Azure OpenAI providers. Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * feat(ai): implement websearch for Anthropic provider - Created anthropic.rs provider with native Anthropic API format - Added web_search tool to Anthropic requests when enabled - Anthropic uses /messages endpoint with x-api-key authentication - Updated query_builder to route Anthropic to new provider Implements websearch functionality for Anthropic Claude models. Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * feat(ai): implement websearch for Gemini/GoogleAI provider - GoogleAI now uses completion endpoint (other.rs) for text instead of responses API - Added Google Search grounding when websearch is enabled - Uses google_search_retrieval tool in request when has_websearch is true - Updated parse methods to use OtherQueryBuilder for completion endpoint Implements websearch functionality for Google Gemini models. Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * fix frontend * fix anthropic and openai * better for gemini * structured output * cleaning * fix validate tool * fixes * cleaning * cleaning * fix for openai * no responses api for azure * fixes * fix * add tests for ai agent * avoid panic * better tests * test user images * fix tool choice * always use streaming backend side * big cleaning * show annotations plus agent action for open ai websearch use * show annotations plus agent action for anthropic websearch use * show annotations plus agent action for google websearch use * nit forntend * rm * fix * add test for image ouptut * fix for azure * add in openflow * fix * fix * nit tests * fixes --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> Co-authored-by: centdix <farhadg110@gmail.com>
135 lines
3.5 KiB
Markdown
135 lines
3.5 KiB
Markdown
# AI Agents Integration Tests
|
|
|
|
Integration tests for Windmill AI agents using the `preview_flow` endpoint.
|
|
|
|
## Quick Start
|
|
|
|
1. Create and activate a virtual environment:
|
|
```bash
|
|
cd integration_tests/ai_agent_tests
|
|
python -m venv .venv
|
|
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
```
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Create `.env` file with your API keys:
|
|
```
|
|
OPENAI_API_KEY=sk-...
|
|
ANTHROPIC_API_KEY=sk-ant-...
|
|
GOOGLE_AI_API_KEY=...
|
|
OPENROUTER_API_KEY=sk-or-...
|
|
BEDROCK_API_KEY=...
|
|
```
|
|
|
|
4. Run a single test to verify:
|
|
```bash
|
|
pytest test_basic_completion.py::TestOpenAI::test_openai_completion -v -s
|
|
```
|
|
|
|
## Prerequisites
|
|
|
|
1. A running Windmill instance (default: `http://localhost:8000`)
|
|
2. Python 3.10+
|
|
3. API keys for the providers you want to test
|
|
|
|
## How It Works
|
|
|
|
### Provider Setup
|
|
|
|
The `setup_providers` fixture automatically creates Windmill variables and resources from your environment variables:
|
|
|
|
| Provider | Variable Path | Resource Path | Resource Type |
|
|
|----------|--------------|---------------|---------------|
|
|
| OpenAI | `u/admin/openai_api_key` | `u/admin/openai` | openai |
|
|
| Anthropic | `u/admin/anthropic_api_key` | `u/admin/anthropic` | anthropic |
|
|
| Google AI | `u/admin/google_ai_api_key` | `u/admin/googleai` | googleai |
|
|
| OpenRouter | `u/admin/openrouter_api_key` | `u/admin/openrouter` | openrouter |
|
|
| Bedrock | `u/admin/bedrock_api_key` | `u/admin/bedrock` | aws_bedrock |
|
|
|
|
### Tools
|
|
|
|
Tools use **rawscript** with inline content instead of creating actual scripts. This means:
|
|
- No script creation/deployment needed
|
|
- Scripts are embedded directly in the flow definition
|
|
- Faster test execution
|
|
|
|
## Running Tests
|
|
|
|
All commands assume you're in the `integration_tests/ai_agent_tests` directory with the venv activated.
|
|
|
|
### Run all AI agent tests
|
|
|
|
```bash
|
|
pytest . -v -s
|
|
```
|
|
|
|
### Run only basic completion tests
|
|
|
|
```bash
|
|
pytest test_basic_completion.py -v -s
|
|
```
|
|
|
|
### Run only tool calling tests
|
|
|
|
```bash
|
|
pytest test_tool_calling.py -v -s
|
|
```
|
|
|
|
### Run tests for a specific provider
|
|
|
|
```bash
|
|
# Only Anthropic tests
|
|
pytest . -v -s -k "anthropic"
|
|
|
|
# Only OpenAI tests
|
|
pytest . -v -s -k "openai"
|
|
```
|
|
|
|
### Run a single test
|
|
|
|
```bash
|
|
# OpenAI basic completion
|
|
pytest test_basic_completion.py::TestOpenAI::test_openai_completion -v -s
|
|
|
|
# Anthropic basic completion
|
|
pytest test_basic_completion.py::TestAnthropic::test_anthropic_completion -v -s
|
|
|
|
# Parametrized test for one provider
|
|
pytest test_basic_completion.py::TestBasicCompletion::test_simple_prompt[openai] -v -s
|
|
```
|
|
|
|
## Test Structure
|
|
|
|
- `conftest.py` - Test fixtures and utilities
|
|
- `AIAgentTestClient` - HTTP client for preview_flow
|
|
- `create_ai_agent_flow()` - Creates AI agent flow definitions
|
|
- `create_rawscript_tool()` - Creates inline script tools
|
|
- `setup_providers` - Sets up variables and resources
|
|
- `providers.py` - Provider configurations (OpenAI, Anthropic, Google AI, Bedrock, OpenRouter)
|
|
- `test_basic_completion.py` - Basic AI completion tests
|
|
- `test_tool_calling.py` - Tool calling tests with inline scripts
|
|
|
|
## Troubleshooting
|
|
|
|
### Tests fail with authentication error
|
|
|
|
Make sure Windmill is running and you can login with the default credentials:
|
|
- Email: `admin@windmill.dev`
|
|
- Password: `changeme`
|
|
|
|
### Tests skip due to missing API keys
|
|
|
|
Ensure the environment variables are set correctly:
|
|
|
|
```bash
|
|
echo $OPENAI_API_KEY
|
|
```
|
|
|
|
### Resource creation fails
|
|
|
|
If resources already exist with different values, you may need to delete them manually via the Windmill UI or API before running tests again.
|