Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Auquan

**Tool Description:**
Utilize Auquan agents to perform your financial data crunching. The Auquan Risk Agent is an expert system designed to provide comprehensive risk analysis and timeline tracking for companies. It specializes in analyzing company risks across multiple dimensions including operational, financial, regulatory, and sustainability metrics. The tool processes structured risk data from Auquan's API, generates detailed timelines, and provides actionable insights through well-formatted json responses.

**Prerequisites**
Obtain an API key for your Auquan Risk Agent by contacting us.
You can contact us via this page : https://www.auquan.com/cta


**Setup**
1. Go to Azure AI Foundry portal and select your AI Project. Select Management Center.
2. Select +new connection in the settings page.
3. Select custom keys in other resource types.
4. Enter the following information to create a connection to store your AuquanRiskAnalyzer key:
5. Set Custom keys to "x-api-key", with the value being your AuquanRiskAnalyzer API key.
6. Make sure is secret is checked.
7. Set the connection name to your connection name. You use this connection name in your sample code or Foundry Portal later.
8. For the Access setting, you can choose either this project only or shared to all projects. Just make sure in your code, the connection string of the project you entered has access to this connection.

**Sample Queries**

- "Do a risk analysis for Darktrace"
- "What are the critical risks identified for Openai"
- "Generate a sustainability analysis for ClimatePartner"
- "What is the overall risk range of Zoom?"
- "What are the recent themes around Coursera and what are their impacts?"
- "What are the recent risks for Autodesk ?"

**Note**
If you encounter a "rate limit exceeded" error, navigate to the "Models + Endpoints" tab in the Foundry Portal and increase the TPM (tokens per minute) limit for your model. We recommend setting it to around 100,000 to start with.


**Customer Support Contact**
[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
"openapi": "3.0.0",
"info": {
"title": "Auquan Risk Analyzer API",
"version": "1.0.0",
"description": "API for company risk analysis and query processing"
},
"servers": [
{
"url": "https://agents.auquan.com",
"description": "Auquan Server"
}
],
"components": {
"securitySchemes": {
"apiKeyHeader": {
"type": "apiKey",
"name": "x-api-key",
"in": "header",
"description": "API key for authentication"
}
}
},
"security": [
{
"apiKeyHeader": []
}
],
"paths": {
"/api/analyze-query": {
"post": {
"operationId": "analyze_query",
"tags": ["Azure Agent"],
"summary": "Analyze a user's natural language query and return risk analysis",
"description": "This endpoint requires a valid API key in the x-api-key header. The API key must be included in all requests.",
"security": [
{
"apiKeyHeader": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The natural language query about company risks",
"example": "do a risk analysis for ClimatePartner"
}
},
"required": ["query"]
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": ["success"]
},
"data": {
"type": "object",
"properties": {
"company_name": {
"type": "string"
},
"basic_info": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"summary": {
"type": "string"
}
}
},
"risk_analysis": {
"type": "object",
"properties": {
"auquan_risks": {
"type": "array",
"items": {
"type": "object"
}
},
"sasb_risks": {
"type": "array",
"items": {
"type": "object"
}
},
"ungc_risks": {
"type": "array",
"items": {
"type": "object"
}
},
"sdg_risks": {
"type": "array",
"items": {
"type": "object"
}
},
"recent_themes": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
}
}
}
}
}
}
},
"401": {
"description": "Unauthorized - Invalid or missing API key",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"detail": {
"type": "string",
"example": "Invalid API key"
}
}
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# pylint: disable=line-too-long,useless-suppression
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

"""
DESCRIPTION:
This sample demonstrates how to use agent operations with the
OpenAPI tool from the Azure Agents service using a synchronous client.
To learn more about OpenAPI specs, visit https://learn.microsoft.com/openapi

USAGE:
python openapi.py

Before running the sample:

pip install azure-ai-agents azure-identity jsonref

Set these environment variables with your own values:
1) PROJECT_ENDPOINT - the Azure AI Agents endpoint.
2) MODEL - The deployment name of the AI model, as found under the "Name" column in
the "Models + endpoints" tab in your Azure AI Foundry project.
"""
# <initialization>
# Import necessary libraries
import os
import jsonref
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
from azure.ai.agents.models import OpenApiTool, OpenApiConnectionAuthDetails, OpenApiConnectionSecurityScheme

# endpoint should be in the format "https://<your-ai-services-resource-name>.services.ai.azure.com/api/projects/<your-project-name>"
endpoint = os.environ["PROJECT_ENDPOINT"]
model = os.environ["MODEL"]
# connection id should be in the format "/subscriptions/<sub-id>/resourceGroups/<your-rg-name>/providers/Microsoft.CognitiveServices/accounts/<your-ai-services-name>/projects/<your-project-name>/connections/<your-connection-name>"
conn_id = os.environ["CONNECTION_ID"]

# Initialize the project client using the endpoint and default credentials
with AIProjectClient(
endpoint=endpoint,
credential=DefaultAzureCredential(exclude_interactive_browser_credential=False),
) as project_client:
# </initialization>

# Load the OpenAPI specification for the service from a local JSON file using jsonref to handle references
with open("./auquan.json", "r") as f:
openapi_spec = jsonref.loads(f.read())

# Create Auth object for the OpenApiTool (note that connection or managed identity auth setup requires additional setup in Azure)
auth = OpenApiConnectionAuthDetails(security_scheme=OpenApiConnectionSecurityScheme(connection_id=conn_id))

# Initialize the main OpenAPI tool definition for Auquan Risk Analyzer
openapi_tool = OpenApiTool(
name="auquan risk analyser tool",
spec=openapi_spec,
description="retrieve risk analysis for a given company",
auth=auth
)

# <agent_creation>
# --- Agent Creation ---
# Create an agent configured with the combined OpenAPI tool definitions
agent = project_client.agents.create_agent(
model=model, # Specify the model deployment
name="auquan-risk-analyser-agent", # Give the agent a name
instructions="You are a helpful research agent that conducts risk analysis on companies using data from Auquan.", # Define agent's role
tools=openapi_tool.definitions, # Provide the list of tool definitions
)
print(f"Created agent, ID: {agent.id}")
# </agent_creation>

# <thread_management>
# --- Thread Management ---
# Create a new conversation thread for the interaction
thread = project_client.agents.threads.create()
print(f"Created thread, ID: {thread.id}")

# Create the initial user message in the thread
message = project_client.agents.messages.create(
thread_id=thread.id,
role="user",
# give an example of a user message that the agent can respond to
content="Send me the risk analysis on Darktrace",
)
print(f"Created message, ID: {message.id}")
# </thread_management>

# <message_processing>
# --- Message Processing (Run Creation and Auto-processing) ---
# Create and automatically process the run, handling tool calls internally
# Note: This differs from the function_tool example where tool calls are handled manually
run = project_client.agents.runs.create_and_process(thread_id=thread.id, agent_id=agent.id)
print(f"Run finished with status: {run.status}")
# </message_processing>

# <tool_execution_loop> # Note: This section now processes completed steps, as create_and_process_run handles execution
# --- Post-Run Step Analysis ---
if run.status == "failed":
print(f"Run failed: {run.last_error}")

# Retrieve the steps taken during the run for analysis
run_steps = project_client.agents.run_steps.list(thread_id=thread.id, run_id=run.id)

# Loop through each step to display information
for step in run_steps:
print(f"Step {step['id']} status: {step['status']}")

# Check if there are tool calls recorded in the step details
step_details = step.get("step_details", {})
tool_calls = step_details.get("tool_calls", [])

if tool_calls:
print(" Tool calls:")
for call in tool_calls:
print(f" Tool Call ID: {call.get('id')}")
print(f" Type: {call.get('type')}")

function_details = call.get("function", {})
if function_details:
print(f" Function name: {function_details.get('name')}")
print() # Add an extra newline between steps for readability
# </tool_execution_loop>

# <cleanup>
# --- Cleanup ---
# Delete the agent resource to clean up
project_client.agents.delete_agent(agent.id)
print("Deleted agent")

# Fetch and log all messages exchanged during the conversation thread
messages = project_client.agents.messages.list(thread_id=thread.id)
for message in messages:
print(f"Message ID: {message.id}, Role: {message.role}, Content: {message.content}")
# </cleanup>
Loading