-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.py
More file actions
46 lines (38 loc) · 1.45 KB
/
Copy pathclient.py
File metadata and controls
46 lines (38 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""provisioned_credentials client — reads credentials from job.accepted."""
from __future__ import annotations
import asyncio
import contextlib
import os
import sys
from arcp import ClientInfo, WebSocketTransport
from arcp.client import ARCPClient
PORT = int(os.environ.get("ARCP_DEMO_PORT", "7892"))
URL = os.environ.get("ARCP_DEMO_URL", f"ws://127.0.0.1:{PORT}/arcp")
TOKEN = os.environ.get("ARCP_DEMO_TOKEN", "demo-token")
async def main() -> int:
client = ARCPClient(
client=ClientInfo(name="provisioned-credentials-client", version="1.1.0"),
token=TOKEN,
features=("model.use", "provisioned_credentials", "cost.budget"),
)
async with contextlib.aclosing(client):
transport = await WebSocketTransport.connect(URL)
await client.connect(transport)
handle = await client.submit(
agent="model-user",
input={"model": "tier-fast/demo"},
lease_request={
"model.use": ["tier-fast/*"],
"cost.budget": ["USD:1.00"],
},
)
credential = handle.credentials[0]
print(
f"credential id={credential.id} scheme={credential.scheme} endpoint={credential.endpoint}"
)
result = await handle.done
assert result.final_status == "success"
assert result.result == {"model": "tier-fast/demo", "credential_count": 1}
return 0
if __name__ == "__main__":
sys.exit(asyncio.run(main()))