|
29 | 29 | import asyncio |
30 | 30 | import subprocess |
31 | 31 | from typing import Dict |
32 | | -import requests |
33 | 32 |
|
| 33 | +import requests |
34 | 34 | from quart import Quart, jsonify, render_template, request |
35 | 35 | from quart_cors import cors |
36 | 36 |
|
37 | 37 | # Check if copilot SDK is available |
38 | 38 | try: |
39 | | - from copilot import CopilotClient, define_tool |
| 39 | + from copilot import CopilotClient, PermissionHandler, define_tool |
40 | 40 | from pydantic import BaseModel, Field |
41 | 41 |
|
42 | 42 | COPILOT_AVAILABLE = True |
@@ -128,6 +128,7 @@ async def create_copilot_session(session_id: str, model: str, config: dict) -> d |
128 | 128 | "model": model, |
129 | 129 | "tools": [execute_crisp_command], |
130 | 130 | "streaming": True, |
| 131 | + "on_permission_request": PermissionHandler.approve_all, |
131 | 132 | } |
132 | 133 |
|
133 | 134 | # Add custom provider if specified |
@@ -155,15 +156,17 @@ async def create_copilot_session(session_id: str, model: str, config: dict) -> d |
155 | 156 | "content": skill_content, |
156 | 157 | } |
157 | 158 | data_path = config.get("data_path", "./workspace") |
158 | | - system_message["content"] += f"\n\nAll data files should be read from and saved to the '{data_path}' directory. Create it if it does not exist." |
| 159 | + system_message[ |
| 160 | + "content" |
| 161 | + ] += f"\n\nAll data files should be read from and saved to the '{data_path}' directory. Create it if it does not exist." |
159 | 162 | session_config["system_message"] = system_message |
160 | 163 |
|
161 | 164 | # Note: Temperature and max_tokens are typically controlled at the provider/model level |
162 | 165 | # These settings from the config are captured but not currently used |
163 | 166 | # Future enhancement: Pass these to the provider configuration if supported |
164 | 167 |
|
165 | 168 | # Create session |
166 | | - session = await client.create_session(session_config) # type: ignore |
| 169 | + session = await client.create_session(session_config) # type: ignore |
167 | 170 |
|
168 | 171 | # Store message history |
169 | 172 | messages = [] |
@@ -248,7 +251,7 @@ async def list_models(): |
248 | 251 | models = await client.list_models() |
249 | 252 | await client.stop() |
250 | 253 |
|
251 | | - return jsonify({"models": [model["id"] for model in models]}) |
| 254 | + return jsonify({"models": [model.id for model in models]}) |
252 | 255 | except Exception as e: |
253 | 256 | return jsonify({"error": str(e)}), 500 |
254 | 257 |
|
|
0 commit comments