Commit 226656da authored by wuzekai's avatar wuzekai

对话智能体更改为dify

parent bc5a96cd
......@@ -48,17 +48,19 @@ output$chat_history_area <- renderUI({
if (is.null(field_info_encoded)) {
return(create_no_data_ui())
}
iframe_src <- paste0(
"http://180.169.131.147:8106/chat/9f51e1707c61027e?field_info=",
field_info_encoded
dify_url <- paste0(
"http://180.169.131.147:8078/chatbot/tfjTZpJDgjQpBeTl",
"?field_info=", field_info_encoded
)
tagList(
div(
id = "chat_box",
style = "height:700px; overflow-y:auto; border:1px solid #ddd;
border-radius:4px; padding:0; background:#fff; margin-bottom:10px;",
tags$iframe(
src = iframe_src,
src = dify_url,
style = "width: 100%; height: 100%; border: 0;",
frameborder = 0,
allow = "microphone"
......@@ -100,29 +102,34 @@ output$field_info_display <- renderUI({
# 获取并编码字段信息
get_field_info <- function() {
# 1. 校验数据集是否存在
if (is.null(input$dataset) || !exists("r_data")) {
return(NULL)
}
# 2. 尝试获取数据集
df <- tryCatch({
get(input$dataset, envir = r_data)
}, error = function(e) NULL)
# 3. 数据集为空则返回NULL
if (is.null(df) || !is.data.frame(df) || nrow(df) == 0) {
return(NULL)
}
# 构建带数据集名称的JSON结构
# 4. 构建字段名-类型映射
fields_list <- list()
for (col_name in names(df)) {
fields_list[[col_name]] <- class(df[[col_name]])[1]
}
# 5. 构建JSON结构
json_struct <- list(
dataset_name = input$dataset,
fields = fields_list
)
# 6. JSON序列化+URL编码
URLencode(
jsonlite::toJSON(json_struct, auto_unbox = TRUE),
reserved = TRUE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment