Spaces:
Sleeping
Sleeping
| import httpx | |
| import json | |
| import asyncio | |
| async def test(): | |
| headers = { | |
| "Content-Type": "application/json", | |
| "Authorization": "Bearer sk-rOiDSQkoe2VgPbWJVbWbLXo2PrmEYVAVoFCrcNjGAMgPmnsOxLQ5XBsSHbGhrStv" | |
| } | |
| body = {"model": "kimi-k2.5", "temperature": 0.7, "messages": [{"role": "system", "content": "You are an AI agent designed to operate in an iterative loop to automate browser tasks."}, {"role": "user", "content": "test"}], "tools": [{"type": "function", "function": {"name": "AgentOutput", "description": "You MUST call this tool every step!", "parameters": {"type": "object", "properties": {"evaluation_previous_goal": {"type": "string"}, "memory": {"type": "string"}, "next_goal": {"type": "string"}, "action": {"anyOf": [{"type": "object", "properties": {"done": {"type": "object", "properties": {"text": {"type": "string"}, "success": {"default": True, "type": "boolean"}}, "required": ["text", "success"], "additionalProperties": False}}, "required": ["done"], "additionalProperties": False}]}}}}], "tool_choice": {"type": "function", "function": {"name": "AgentOutput"}}} | |
| async with httpx.AsyncClient(timeout=60) as client: | |
| resp = await client.post( | |
| "https://opencode.ai/zen/go/v1/chat/completions", | |
| json=body, | |
| headers=headers | |
| ) | |
| print(f"Status: {resp.status_code}") | |
| print(f"Response: {resp.text[:1000]}") | |
| asyncio.run(test()) |