mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-22 03:41:43 +00:00
fix: Fix code format error
This commit is contained in:
parent
845432fea0
commit
35af7b17f0
@ -790,8 +790,8 @@ async def stream_generator(
|
|||||||
yield f"data: {_content}\n\n"
|
yield f"data: {_content}\n\n"
|
||||||
else:
|
else:
|
||||||
msg = chunk.replace("\ufffd", "")
|
msg = chunk.replace("\ufffd", "")
|
||||||
msg = msg.replace("\n", "\\n")
|
msg_json = json.dumps({"vis": msg}, ensure_ascii=False)
|
||||||
yield f"data:{msg}\n\n"
|
yield f"data:{msg_json}\n\n"
|
||||||
await asyncio.sleep(0.02)
|
await asyncio.sleep(0.02)
|
||||||
if incremental:
|
if incremental:
|
||||||
yield "data: [DONE]\n\n"
|
yield "data: [DONE]\n\n"
|
||||||
|
@ -435,8 +435,6 @@ class BaseChat(ABC):
|
|||||||
text_msg = model_output.text if model_output.has_text else ""
|
text_msg = model_output.text if model_output.has_text else ""
|
||||||
view_msg = self.stream_plugin_call(text_msg)
|
view_msg = self.stream_plugin_call(text_msg)
|
||||||
view_msg = model_output.gen_text_with_thinking(new_text=view_msg)
|
view_msg = model_output.gen_text_with_thinking(new_text=view_msg)
|
||||||
view_msg = view_msg.replace("\n", "\\n")
|
|
||||||
|
|
||||||
if text_output:
|
if text_output:
|
||||||
full_text = view_msg
|
full_text = view_msg
|
||||||
# Return the incremental text
|
# Return the incremental text
|
||||||
@ -603,7 +601,7 @@ class BaseChat(ABC):
|
|||||||
view_message = parsed_output.gen_text_with_thinking(
|
view_message = parsed_output.gen_text_with_thinking(
|
||||||
new_text=view_message
|
new_text=view_message
|
||||||
)
|
)
|
||||||
return ai_response_text, view_message.replace("\n", "\\n")
|
return ai_response_text, view_message
|
||||||
except BaseAppException as e:
|
except BaseAppException as e:
|
||||||
raise ContextAppException(e.message, e.view, model_output) from e
|
raise ContextAppException(e.message, e.view, model_output) from e
|
||||||
|
|
||||||
|
@ -58,9 +58,7 @@ const pluginViewStatusMapper: Record<DBGPTView['status'], { bgClass: string; ico
|
|||||||
};
|
};
|
||||||
|
|
||||||
function formatMarkdownVal(val: string) {
|
function formatMarkdownVal(val: string) {
|
||||||
return val
|
return val.replace(/<table(\w*=[^>]+)>/gi, '<table $1>')
|
||||||
.replaceAll('\\n', '\n')
|
|
||||||
.replace(/<table(\w*=[^>]+)>/gi, '<table $1>')
|
|
||||||
.replace(/<tr(\w*=[^>]+)>/gi, '<tr $1>');
|
.replace(/<tr(\w*=[^>]+)>/gi, '<tr $1>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,10 +90,10 @@ const useChat = ({ queryAgentURL = '/api/v1/chat/completions', app_code }: Props
|
|||||||
if (scene === 'chat_agent') {
|
if (scene === 'chat_agent') {
|
||||||
message = JSON.parse(message).vis;
|
message = JSON.parse(message).vis;
|
||||||
} else {
|
} else {
|
||||||
message = JSON.parse(message);
|
message = JSON.parse(message).vis;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
message.replaceAll('\\n', '\n');
|
// message.replaceAll('\\n', '\n');
|
||||||
}
|
}
|
||||||
if (typeof message === 'string') {
|
if (typeof message === 'string') {
|
||||||
if (message === '[DONE]') {
|
if (message === '[DONE]') {
|
||||||
|
@ -69,9 +69,7 @@ const pluginViewStatusMapper: Record<DBGPTView['status'], { bgClass: string; ico
|
|||||||
};
|
};
|
||||||
|
|
||||||
const formatMarkdownVal = (val: string) => {
|
const formatMarkdownVal = (val: string) => {
|
||||||
return val
|
return val.replace(/<table(\w*=[^>]+)>/gi, '<table $1>')
|
||||||
.replaceAll('\\n', '\n')
|
|
||||||
.replace(/<table(\w*=[^>]+)>/gi, '<table $1>')
|
|
||||||
.replace(/<tr(\w*=[^>]+)>/gi, '<tr $1>');
|
.replace(/<tr(\w*=[^>]+)>/gi, '<tr $1>');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,9 +69,7 @@ const ChatDialog: React.FC<{
|
|||||||
}, [context]);
|
}, [context]);
|
||||||
|
|
||||||
const formatMarkdownVal = (val: string) => {
|
const formatMarkdownVal = (val: string) => {
|
||||||
return val
|
return val.replace(/<table(\w*=[^>]+)>/gi, '<table $1>')
|
||||||
.replaceAll('\\n', '\n')
|
|
||||||
.replace(/<table(\w*=[^>]+)>/gi, '<table $1>')
|
|
||||||
.replace(/<tr(\w*=[^>]+)>/gi, '<tr $1>');
|
.replace(/<tr(\w*=[^>]+)>/gi, '<tr $1>');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user