Instructions per chat (system prompt addition; UI dialog and Telegram /prompt)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
434aa84d40
commit
ff8ff585a2
14 files changed
+156
-4
No files matched your search
+10
-1
@@ -574,6 +574,7 @@ async fn create_session(Extension(user): Extension<User>, State(app): State<AppS
|
||||
pinned: false,
|
||||
archived: false,
|
||||
folder: None,
|
||||
instructions: String::new(),
|
||||
};
|
||||
let s = app.save_session(s)?;
|
||||
Ok(Json(json!(s)))
|
||||
@@ -782,12 +783,17 @@ struct UpdateSession {
|
||||
archived: Option<bool>,
|
||||
/// "" removes the folder.
|
||||
folder: Option<String>,
|
||||
/// Instructions for this chat ("" clears them).
|
||||
instructions: Option<String>,
|
||||
}
|
||||
|
||||
async fn update_session(Extension(user): Extension<User>, State(app): State<AppState>, Path(id): Path<String>, Json(body): Json<UpdateSession>) -> ApiResult {
|
||||
writable(&app, &user, &id)?;
|
||||
// Organising the list must not move the session to "today".
|
||||
let organise_only = body.title.is_none() && body.model.is_none() && body.agent.is_none() && body.clean_room.is_none() && body.permission_mode.is_none();
|
||||
let organise_only = body.title.is_none() && body.model.is_none() && body.agent.is_none() && body.clean_room.is_none() && body.permission_mode.is_none() && body.instructions.is_none();
|
||||
if body.instructions.as_ref().is_some_and(|i| i.len() > 20_000) {
|
||||
return Err(ApiError(StatusCode::BAD_REQUEST, "instructions too long (max 20,000 characters)".into()));
|
||||
}
|
||||
if let Some(m) = &body.model {
|
||||
app.registry().resolve(m)?;
|
||||
}
|
||||
@@ -824,6 +830,9 @@ async fn update_session(Extension(user): Extension<User>, State(app): State<AppS
|
||||
if let Some(p) = body.permission_mode {
|
||||
s.permission_mode = p;
|
||||
}
|
||||
if let Some(i) = body.instructions {
|
||||
s.instructions = i.trim().to_string();
|
||||
}
|
||||
})?;
|
||||
Ok(Json(json!(s)))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user