mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-23 04:12:13 +00:00
fix(prompt): fix response_schema not persisting and displaying in edit mode
- Add missing fields in ServeDao.to_request() to prevent data loss during updates - Update IPrompt interface to include response_schema and other missing fields - Initialize response_schema in edit form to display existing prompt data properly Fixes issue where response_schema was being cleared on update and not showing in edit mode.
This commit is contained in:
parent
845432fea0
commit
9e739e5b90
@ -108,6 +108,10 @@ class ServeDao(BaseDao[ServeEntity, ServeRequest, ServerResponse]):
|
||||
prompt_name=entity.prompt_name,
|
||||
prompt_code=entity.prompt_code,
|
||||
content=entity.content,
|
||||
response_schema=entity.response_schema,
|
||||
input_variables=entity.input_variables,
|
||||
model=entity.model,
|
||||
prompt_language=entity.prompt_language,
|
||||
prompt_desc=entity.prompt_desc,
|
||||
user_code=entity.user_code,
|
||||
user_name=entity.user_name,
|
||||
|
@ -349,6 +349,13 @@ const AddOrEditPrompt: React.FC = () => {
|
||||
const editData = JSON.parse(localStorage.getItem('edit_prompt_data') || '{}');
|
||||
setVariables(JSON.parse(editData.input_variables ?? '[]'));
|
||||
setValue(editData?.content);
|
||||
// 设置响应模板
|
||||
try {
|
||||
const responseSchema = editData.response_schema ? JSON.parse(editData.response_schema) : {};
|
||||
setResponseTemplate(responseSchema);
|
||||
} catch {
|
||||
setResponseTemplate({});
|
||||
}
|
||||
topForm.setFieldsValue({
|
||||
prompt_type: editData.prompt_type,
|
||||
prompt_name: editData.prompt_name,
|
||||
|
@ -21,6 +21,12 @@ export interface IPrompt {
|
||||
sub_chat_scene: string;
|
||||
user_name?: string;
|
||||
user_id?: string;
|
||||
response_schema?: string;
|
||||
input_variables?: string;
|
||||
model?: string;
|
||||
prompt_language?: string;
|
||||
prompt_desc?: string;
|
||||
prompt_code?: string;
|
||||
}
|
||||
|
||||
export interface PromptTemplateProps {
|
||||
|
Loading…
Reference in New Issue
Block a user