db620d33df
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
# /// script
|
|
# requires-python = ">=3.10"
|
|
# dependencies = [
|
|
# "openai>=1.50,<3",
|
|
# "azure-identity>=1.19,<2",
|
|
# ]
|
|
# ///
|
|
# Run with: uv run call_server.py
|
|
|
|
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
"""Call the deployed Hyperlight CodeAct Foundry hosted agent via the OpenAI client."""
|
|
|
|
import os
|
|
|
|
from azure.identity import AzureCliCredential
|
|
from openai import OpenAI
|
|
|
|
# Set FOUNDRY_AGENT_ENDPOINT to your deployed agent endpoint, e.g.
|
|
# https://<your-foundry-resource>.services.ai.azure.com/api/projects/<project>/agents/<agent-name>
|
|
ENDPOINT = os.environ.get(
|
|
"FOUNDRY_AGENT_ENDPOINT",
|
|
"https://<your-foundry-resource>.services.ai.azure.com/api/projects/<project>/agents/<agent-name>",
|
|
)
|
|
SCOPE = "https://ai.azure.com/.default"
|
|
PROMPT = (
|
|
"Fetch all users, find the admins, multiply 7 by 6, and print the users, "
|
|
"admins and multiplication result. Use execute_code with call_tool(...)."
|
|
)
|
|
|
|
|
|
def main() -> None:
|
|
token = AzureCliCredential().get_token(SCOPE).token
|
|
client = OpenAI(base_url=ENDPOINT, api_key=token, default_query={"api-version": "v1"})
|
|
response = client.responses.create(model="hosted-agent", input=PROMPT)
|
|
print(response.output_text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|