rai-agent-functions-api


Namerai-agent-functions-api JSON
Version 1.0.3 PyPI version JSON
download
home_pageNone
SummaryAzure Functions API client for RAI (Responsible AI) operations including prompt review and testcase generation
upload_time2025-10-07 11:13:57
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords azure functions api responsible-ai rai prompt-review testcase-generation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RAI Agent Functions API

A Python SDK for Azure Functions API that provides Responsible AI (RAI) operations including prompt review and testcase generation.

## Features

- **Prompt Review**: Review and update prompts with AI-powered analysis
- **Testcase Generation**: Generate comprehensive testcases from prompts
- **Azure Integration**: Built for Azure Functions with proper authentication and error handling
- **Async Support**: Full async/await support for non-blocking operations
- **Type Safety**: Complete type hints and mypy compatibility

## Installation

Install the package using pip:

```bash
pip install rai-agent-functions-api
```

## Quick Start

### Basic Usage

```python
from RAI_SDK.rai_agent_functions_api import RAIAgentFunctionsAPI

# Initialize the client
client = RAIAgentFunctionsAPI(
    endpoint="https://your-function-app.azurewebsites.net/api"
)

# Review a prompt
review_result = client.reviewer.post(
    body={"prompt": "Generate a sales forecast for Q4"}
)
print(review_result)

# Generate testcases
testcase_result = client.testcase.generator_post(
    body={
        "prompt": "Create user authentication system",
        "number_of_testcases": 5,
        "user_categories": ["security", "usability", "performance"]
    }
)
print(testcase_result)
```

### Async Usage

```python
from RAI_SDK.rai_agent_functions_api.aio import RAIAgentFunctionsAPI

async def main():
    async with RAIAgentFunctionsAPI(
        endpoint="https://your-function-app.azurewebsites.net/api"
    ) as client:
        # Async operations
        review_result = await client.reviewer.post(
            body={"prompt": "Generate a sales forecast for Q4"}
        )
        print(review_result)

import asyncio
asyncio.run(main())
```

## API Reference

### RAIAgentFunctionsAPI

The main client class for interacting with the RAI Agent Functions API.

#### Parameters

- `endpoint` (str): The base URL of your Azure Functions API. Default: `"https://func-rai-agent-eus.azurewebsites.net/api"`

#### Methods

##### reviewer.post(body)

Review and update a prompt using AI analysis.

**Parameters:**
- `body` (dict): Request payload containing:
  - `prompt` (str): The prompt to review

**Returns:**
- dict: Response containing:
  - `review_of_updated_prompt`: Analysis of the updated prompt
  - `review_result`: Review findings and suggestions
  - `updated_result`: The improved prompt

##### testcase.generator_post(body)

Generate testcases from a given prompt.

**Parameters:**
- `body` (dict): Request payload containing:
  - `prompt` (str): The prompt to generate testcases for
  - `number_of_testcases` (int): Number of testcases to generate
  - `user_categories` (list[str]): Categories for testcase generation

**Returns:**
- dict: Response containing:
  - `result`: Generated testcases and analysis

## Configuration

### Authentication

The SDK uses Azure Core's authentication mechanisms. You can configure authentication using:

```python
from azure.identity import DefaultAzureCredential

client = RAIAgentFunctionsAPI(
    endpoint="https://your-function-app.azurewebsites.net/api",
    credential=DefaultAzureCredential()
)
```

### Custom Headers

```python
client = RAIAgentFunctionsAPI(
    endpoint="https://your-function-app.azurewebsites.net/api",
    headers={"Custom-Header": "value"}
)
```

### Retry Policy

```python
from azure.core.pipeline.policies import RetryPolicy

client = RAIAgentFunctionsAPI(
    endpoint="https://your-function-app.azurewebsites.net/api",
    retry_policy=RetryPolicy(retry_total=3)
)
```

## Error Handling

The SDK provides comprehensive error handling:

```python
from azure.core.exceptions import HttpResponseError, ClientAuthenticationError

try:
    result = client.reviewer.post(body={"prompt": "test"})
except ClientAuthenticationError:
    print("Authentication failed")
except HttpResponseError as e:
    print(f"HTTP error: {e.status_code} - {e.message}")
except Exception as e:
    print(f"Unexpected error: {e}")
```

## Development

### Prerequisites

- Python 3.8+
- Azure Functions Core Tools (for local development)

### Installation for Development

```bash
git clone https://github.com/yourusername/rai-agent-functions-api.git
cd rai-agent-functions-api
pip install -e ".[dev]"
```

### Running Tests

```bash
pytest
```

### Code Formatting

```bash
black .
flake8 .
mypy .
```

## Examples

### Complete Example

```python
from RAI_SDK.rai_agent_functions_api import RAIAgentFunctionsAPI

def main():
    # Initialize client
    client = RAIAgentFunctionsAPI()
    
    # Example 1: Review a business prompt
    business_prompt = "Create a marketing strategy for our new product launch"
    review_response = client.reviewer.post(body={"prompt": business_prompt})
    
    print("Original prompt:", business_prompt)
    print("Review result:", review_response.get("review_result"))
    print("Updated prompt:", review_response.get("updated_result"))
    
    # Example 2: Generate testcases for a technical requirement
    technical_prompt = "Implement user authentication with multi-factor authentication"
    testcase_response = client.testcase.generator_post(
        body={
            "prompt": technical_prompt,
            "number_of_testcases": 3,
            "user_categories": ["security", "usability", "edge-cases"]
        }
    )
    
    print("Generated testcases:", testcase_response.get("result"))

if __name__ == "__main__":
    main()
```

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## Support

For support and questions:

- Create an issue on GitHub
- Check the documentation
- Review the examples

## Changelog

### 1.0.0

- Initial release
- Prompt review functionality
- Testcase generation capabilities
- Full async support
- Comprehensive error handling

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rai-agent-functions-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "azure, functions, api, responsible-ai, rai, prompt-review, testcase-generation",
    "author": null,
    "author_email": "Divyanshu Rastogi <divyanshur@maqsoftware.com>",
    "download_url": "https://files.pythonhosted.org/packages/48/18/04409d05892f47068a49ddb14d55358690c7c29e27521913f2a45bcd4d17/rai_agent_functions_api-1.0.3.tar.gz",
    "platform": null,
    "description": "# RAI Agent Functions API\r\n\r\nA Python SDK for Azure Functions API that provides Responsible AI (RAI) operations including prompt review and testcase generation.\r\n\r\n## Features\r\n\r\n- **Prompt Review**: Review and update prompts with AI-powered analysis\r\n- **Testcase Generation**: Generate comprehensive testcases from prompts\r\n- **Azure Integration**: Built for Azure Functions with proper authentication and error handling\r\n- **Async Support**: Full async/await support for non-blocking operations\r\n- **Type Safety**: Complete type hints and mypy compatibility\r\n\r\n## Installation\r\n\r\nInstall the package using pip:\r\n\r\n```bash\r\npip install rai-agent-functions-api\r\n```\r\n\r\n## Quick Start\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom RAI_SDK.rai_agent_functions_api import RAIAgentFunctionsAPI\r\n\r\n# Initialize the client\r\nclient = RAIAgentFunctionsAPI(\r\n    endpoint=\"https://your-function-app.azurewebsites.net/api\"\r\n)\r\n\r\n# Review a prompt\r\nreview_result = client.reviewer.post(\r\n    body={\"prompt\": \"Generate a sales forecast for Q4\"}\r\n)\r\nprint(review_result)\r\n\r\n# Generate testcases\r\ntestcase_result = client.testcase.generator_post(\r\n    body={\r\n        \"prompt\": \"Create user authentication system\",\r\n        \"number_of_testcases\": 5,\r\n        \"user_categories\": [\"security\", \"usability\", \"performance\"]\r\n    }\r\n)\r\nprint(testcase_result)\r\n```\r\n\r\n### Async Usage\r\n\r\n```python\r\nfrom RAI_SDK.rai_agent_functions_api.aio import RAIAgentFunctionsAPI\r\n\r\nasync def main():\r\n    async with RAIAgentFunctionsAPI(\r\n        endpoint=\"https://your-function-app.azurewebsites.net/api\"\r\n    ) as client:\r\n        # Async operations\r\n        review_result = await client.reviewer.post(\r\n            body={\"prompt\": \"Generate a sales forecast for Q4\"}\r\n        )\r\n        print(review_result)\r\n\r\nimport asyncio\r\nasyncio.run(main())\r\n```\r\n\r\n## API Reference\r\n\r\n### RAIAgentFunctionsAPI\r\n\r\nThe main client class for interacting with the RAI Agent Functions API.\r\n\r\n#### Parameters\r\n\r\n- `endpoint` (str): The base URL of your Azure Functions API. Default: `\"https://func-rai-agent-eus.azurewebsites.net/api\"`\r\n\r\n#### Methods\r\n\r\n##### reviewer.post(body)\r\n\r\nReview and update a prompt using AI analysis.\r\n\r\n**Parameters:**\r\n- `body` (dict): Request payload containing:\r\n  - `prompt` (str): The prompt to review\r\n\r\n**Returns:**\r\n- dict: Response containing:\r\n  - `review_of_updated_prompt`: Analysis of the updated prompt\r\n  - `review_result`: Review findings and suggestions\r\n  - `updated_result`: The improved prompt\r\n\r\n##### testcase.generator_post(body)\r\n\r\nGenerate testcases from a given prompt.\r\n\r\n**Parameters:**\r\n- `body` (dict): Request payload containing:\r\n  - `prompt` (str): The prompt to generate testcases for\r\n  - `number_of_testcases` (int): Number of testcases to generate\r\n  - `user_categories` (list[str]): Categories for testcase generation\r\n\r\n**Returns:**\r\n- dict: Response containing:\r\n  - `result`: Generated testcases and analysis\r\n\r\n## Configuration\r\n\r\n### Authentication\r\n\r\nThe SDK uses Azure Core's authentication mechanisms. You can configure authentication using:\r\n\r\n```python\r\nfrom azure.identity import DefaultAzureCredential\r\n\r\nclient = RAIAgentFunctionsAPI(\r\n    endpoint=\"https://your-function-app.azurewebsites.net/api\",\r\n    credential=DefaultAzureCredential()\r\n)\r\n```\r\n\r\n### Custom Headers\r\n\r\n```python\r\nclient = RAIAgentFunctionsAPI(\r\n    endpoint=\"https://your-function-app.azurewebsites.net/api\",\r\n    headers={\"Custom-Header\": \"value\"}\r\n)\r\n```\r\n\r\n### Retry Policy\r\n\r\n```python\r\nfrom azure.core.pipeline.policies import RetryPolicy\r\n\r\nclient = RAIAgentFunctionsAPI(\r\n    endpoint=\"https://your-function-app.azurewebsites.net/api\",\r\n    retry_policy=RetryPolicy(retry_total=3)\r\n)\r\n```\r\n\r\n## Error Handling\r\n\r\nThe SDK provides comprehensive error handling:\r\n\r\n```python\r\nfrom azure.core.exceptions import HttpResponseError, ClientAuthenticationError\r\n\r\ntry:\r\n    result = client.reviewer.post(body={\"prompt\": \"test\"})\r\nexcept ClientAuthenticationError:\r\n    print(\"Authentication failed\")\r\nexcept HttpResponseError as e:\r\n    print(f\"HTTP error: {e.status_code} - {e.message}\")\r\nexcept Exception as e:\r\n    print(f\"Unexpected error: {e}\")\r\n```\r\n\r\n## Development\r\n\r\n### Prerequisites\r\n\r\n- Python 3.8+\r\n- Azure Functions Core Tools (for local development)\r\n\r\n### Installation for Development\r\n\r\n```bash\r\ngit clone https://github.com/yourusername/rai-agent-functions-api.git\r\ncd rai-agent-functions-api\r\npip install -e \".[dev]\"\r\n```\r\n\r\n### Running Tests\r\n\r\n```bash\r\npytest\r\n```\r\n\r\n### Code Formatting\r\n\r\n```bash\r\nblack .\r\nflake8 .\r\nmypy .\r\n```\r\n\r\n## Examples\r\n\r\n### Complete Example\r\n\r\n```python\r\nfrom RAI_SDK.rai_agent_functions_api import RAIAgentFunctionsAPI\r\n\r\ndef main():\r\n    # Initialize client\r\n    client = RAIAgentFunctionsAPI()\r\n    \r\n    # Example 1: Review a business prompt\r\n    business_prompt = \"Create a marketing strategy for our new product launch\"\r\n    review_response = client.reviewer.post(body={\"prompt\": business_prompt})\r\n    \r\n    print(\"Original prompt:\", business_prompt)\r\n    print(\"Review result:\", review_response.get(\"review_result\"))\r\n    print(\"Updated prompt:\", review_response.get(\"updated_result\"))\r\n    \r\n    # Example 2: Generate testcases for a technical requirement\r\n    technical_prompt = \"Implement user authentication with multi-factor authentication\"\r\n    testcase_response = client.testcase.generator_post(\r\n        body={\r\n            \"prompt\": technical_prompt,\r\n            \"number_of_testcases\": 3,\r\n            \"user_categories\": [\"security\", \"usability\", \"edge-cases\"]\r\n        }\r\n    )\r\n    \r\n    print(\"Generated testcases:\", testcase_response.get(\"result\"))\r\n\r\nif __name__ == \"__main__\":\r\n    main()\r\n```\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the LICENSE file for details.\r\n\r\n## Contributing\r\n\r\n1. Fork the repository\r\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\r\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\r\n4. Push to the branch (`git push origin feature/amazing-feature`)\r\n5. Open a Pull Request\r\n\r\n## Support\r\n\r\nFor support and questions:\r\n\r\n- Create an issue on GitHub\r\n- Check the documentation\r\n- Review the examples\r\n\r\n## Changelog\r\n\r\n### 1.0.0\r\n\r\n- Initial release\r\n- Prompt review functionality\r\n- Testcase generation capabilities\r\n- Full async support\r\n- Comprehensive error handling\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Azure Functions API client for RAI (Responsible AI) operations including prompt review and testcase generation",
    "version": "1.0.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/DivyanshuMaq/rai-agent-functions-api/issues",
        "Documentation": "https://github.com/DivyanshuMaq/rai-agent-functions-api#readme",
        "Homepage": "https://github.com/DivyanshuMaq/rai-agent-functions-api",
        "Repository": "https://github.com/DivyanshuMaq/rai-agent-functions-api.git"
    },
    "split_keywords": [
        "azure",
        " functions",
        " api",
        " responsible-ai",
        " rai",
        " prompt-review",
        " testcase-generation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "379af677c411b501a1a5aaa6f8e1a8b02cfb27273d7f79b563973419a705f90f",
                "md5": "c84ba29dfde09a4b33eb1f6648553993",
                "sha256": "34db17e5b9fb0eca66e62f64e9c09298de5b33494d15ca854700cbe7cf3bc603"
            },
            "downloads": -1,
            "filename": "rai_agent_functions_api-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c84ba29dfde09a4b33eb1f6648553993",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 36840,
            "upload_time": "2025-10-07T11:13:55",
            "upload_time_iso_8601": "2025-10-07T11:13:55.872332Z",
            "url": "https://files.pythonhosted.org/packages/37/9a/f677c411b501a1a5aaa6f8e1a8b02cfb27273d7f79b563973419a705f90f/rai_agent_functions_api-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "481804409d05892f47068a49ddb14d55358690c7c29e27521913f2a45bcd4d17",
                "md5": "9a76f4a4c0e775e4bc103a90be2bc7bc",
                "sha256": "2a3b09b028884aaf99e45ad5ed73d327846353d66abb92b0501ecd6e2f6f8968"
            },
            "downloads": -1,
            "filename": "rai_agent_functions_api-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "9a76f4a4c0e775e4bc103a90be2bc7bc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 31376,
            "upload_time": "2025-10-07T11:13:57",
            "upload_time_iso_8601": "2025-10-07T11:13:57.604263Z",
            "url": "https://files.pythonhosted.org/packages/48/18/04409d05892f47068a49ddb14d55358690c7c29e27521913f2a45bcd4d17/rai_agent_functions_api-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-07 11:13:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DivyanshuMaq",
    "github_project": "rai-agent-functions-api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "rai-agent-functions-api"
}
        
Elapsed time: 0.89204s