Skip to content

Commit e8d7c66

Browse files
Feature/fix copilot 1 (#102)
* Implement feature X to enhance user experience and fix bug Y in module Z * Refactor session creation and model listing for improved clarity and consistency * Add PermissionHandler to manage Copilot permissions in session creation
1 parent e1e4322 commit e8d7c66

2 files changed

Lines changed: 941 additions & 871 deletions

File tree

src/crisp_t/ui/server.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
import asyncio
3030
import subprocess
3131
from typing import Dict
32-
import requests
3332

33+
import requests
3434
from quart import Quart, jsonify, render_template, request
3535
from quart_cors import cors
3636

3737
# Check if copilot SDK is available
3838
try:
39-
from copilot import CopilotClient, define_tool
39+
from copilot import CopilotClient, PermissionHandler, define_tool
4040
from pydantic import BaseModel, Field
4141

4242
COPILOT_AVAILABLE = True
@@ -128,6 +128,7 @@ async def create_copilot_session(session_id: str, model: str, config: dict) -> d
128128
"model": model,
129129
"tools": [execute_crisp_command],
130130
"streaming": True,
131+
"on_permission_request": PermissionHandler.approve_all,
131132
}
132133

133134
# Add custom provider if specified
@@ -155,15 +156,17 @@ async def create_copilot_session(session_id: str, model: str, config: dict) -> d
155156
"content": skill_content,
156157
}
157158
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."
159162
session_config["system_message"] = system_message
160163

161164
# Note: Temperature and max_tokens are typically controlled at the provider/model level
162165
# These settings from the config are captured but not currently used
163166
# Future enhancement: Pass these to the provider configuration if supported
164167

165168
# Create session
166-
session = await client.create_session(session_config) # type: ignore
169+
session = await client.create_session(session_config) # type: ignore
167170

168171
# Store message history
169172
messages = []
@@ -248,7 +251,7 @@ async def list_models():
248251
models = await client.list_models()
249252
await client.stop()
250253

251-
return jsonify({"models": [model["id"] for model in models]})
254+
return jsonify({"models": [model.id for model in models]})
252255
except Exception as e:
253256
return jsonify({"error": str(e)}), 500
254257

0 commit comments

Comments
 (0)