Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
Radiant
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wuzekai
Radiant
Commits
45915ece
Commit
45915ece
authored
Jan 25, 2026
by
wuzekai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:替换为外网部署的模型
parent
75d22b2a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
33 deletions
+89
-33
quickgen_chart.R
radiant.quickgen/R/quickgen_chart.R
+43
-14
quickgen_metrics.R
radiant.quickgen/R/quickgen_metrics.R
+45
-13
quickgen_chat_ui.R
radiant.quickgen/inst/app/tools/analysis/quickgen_chat_ui.R
+1
-6
No files found.
radiant.quickgen/R/quickgen_chart.R
View file @
45915ece
# === 配置 ===
# 内网环境
OLLAMA_URL
<-
"http://172.29.2.110:8137/api/generate"
# 外网环境
#OLLAMA_URL <- "http://180.169.131.147:8137/api/generate"
API_URL
<-
"https://oam0321.cixincloud.com/v1/chat/completions"
API_KEY
<-
"1affeg87354asdgds9sgsdffgr87623"
MODEL_ID
<-
"qwen3-coder:30b"
# === 单次对话 ===
...
...
@@ -16,27 +13,59 @@ chart_completion <- function(user_prompt) {
# 构建请求体
req_body
<-
list
(
model
=
MODEL_ID
,
prompt
=
user_prompt
,
messages
=
list
(
list
(
role
=
"user"
,
content
=
user_prompt
)),
stream
=
FALSE
)
# 转换为JSON
json_body
<-
jsonlite
::
toJSON
(
req_body
,
auto_unbox
=
TRUE
,
pretty
=
TRUE
)
# 使用 curl 包发送请求
h
<-
curl
::
new_handle
()
curl
::
handle_setheaders
(
h
,
"Content-Type"
=
"application/json"
)
curl
::
handle_setopt
(
h
,
postfields
=
jsonlite
::
toJSON
(
req_body
,
auto_unbox
=
TRUE
))
curl
::
handle_setheaders
(
h
,
"Content-Type"
=
"application/json"
,
"Authorization"
=
paste
(
"Bearer"
,
API_KEY
)
)
curl
::
handle_setopt
(
h
,
postfields
=
json_body
)
curl
::
handle_setopt
(
h
,
timeout
=
60
)
con
<-
curl
::
curl
(
OLLAMA_URL
,
handle
=
h
)
# 捕获响应
con
<-
curl
::
curl
(
API_URL
,
handle
=
h
)
result
<-
readLines
(
con
,
warn
=
FALSE
)
close
(
con
)
# 解析响应
body
<-
jsonlite
::
fromJSON
(
paste
(
result
,
collapse
=
""
))
# 检查响应是否为空
if
(
length
(
result
)
==
0
||
all
(
result
==
""
))
{
stop
(
"API 返回空响应"
)
}
# 尝试解析JSON
body
<-
tryCatch
({
jsonlite
::
fromJSON
(
paste
(
result
,
collapse
=
""
),
simplifyVector
=
FALSE
)
},
error
=
function
(
e
)
{
stop
(
"JSON解析失败: "
,
e
$
message
,
"\n原始响应: "
,
paste
(
result
,
collapse
=
""
))
})
if
(
is.null
(
body
$
response
)
||
trimws
(
body
$
response
)
==
""
)
stop
(
"Ollama API 返回空内容:"
,
paste
(
result
,
collapse
=
""
))
# 检查是否有错误字段
if
(
!
is.null
(
body
$
error
))
{
stop
(
"API 返回错误: "
,
jsonlite
::
toJSON
(
body
$
error
,
auto_unbox
=
TRUE
))
}
# 提取内容
if
(
!
is.list
(
body
)
||
!
is.list
(
body
$
choices
)
||
length
(
body
$
choices
)
==
0
)
{
stop
(
"API 响应格式异常: "
,
paste
(
result
,
collapse
=
""
))
}
response_content
<-
body
$
choices
[[
1
]]
$
message
$
content
if
(
is.null
(
response_content
)
||
trimws
(
response_content
)
==
""
)
{
stop
(
"API 返回空内容: "
,
paste
(
result
,
collapse
=
""
))
}
body
$
response
response_content
}
# === 构造发给模型的 Prompt ===
...
...
radiant.quickgen/R/quickgen_metrics.R
View file @
45915ece
# === 配置 ===
# 内网环境
OLLAMA_URL
<-
"http://172.29.2.110:8137/api/generate"
# 外网环境
#OLLAMA_URL <- "http://180.169.131.147:8137/api/generate"
API_URL
<-
"https://oam0321.cixincloud.com/v1/chat/completions"
API_KEY
<-
"1affeg87354asdgds9sgsdffgr87623"
MODEL_ID
<-
"qwen3-coder:30b"
# === 单次对话 ===
...
...
@@ -16,27 +13,62 @@ metrics_completion <- function(user_prompt) {
# 构建请求体
req_body
<-
list
(
model
=
MODEL_ID
,
prompt
=
user_prompt
,
messages
=
list
(
list
(
role
=
"user"
,
content
=
user_prompt
)),
stream
=
FALSE
)
# 转换为JSON
json_body
<-
jsonlite
::
toJSON
(
req_body
,
auto_unbox
=
TRUE
,
pretty
=
TRUE
)
# 使用 curl 包发送请求
h
<-
curl
::
new_handle
()
curl
::
handle_setheaders
(
h
,
"Content-Type"
=
"application/json"
)
curl
::
handle_setopt
(
h
,
postfields
=
jsonlite
::
toJSON
(
req_body
,
auto_unbox
=
TRUE
))
curl
::
handle_setheaders
(
h
,
"Content-Type"
=
"application/json"
,
"Authorization"
=
paste
(
"Bearer"
,
API_KEY
)
)
curl
::
handle_setopt
(
h
,
postfields
=
json_body
)
curl
::
handle_setopt
(
h
,
timeout
=
60
)
con
<-
curl
::
curl
(
OLLAMA_URL
,
handle
=
h
)
# 捕获响应
con
<-
curl
::
curl
(
API_URL
,
handle
=
h
)
result
<-
readLines
(
con
,
warn
=
FALSE
)
close
(
con
)
# 检查响应是否为空
if
(
length
(
result
)
==
0
||
all
(
result
==
""
))
{
stop
(
"API 返回空响应"
)
}
# 解析响应
body
<-
jsonlite
::
fromJSON
(
paste
(
result
,
collapse
=
""
))
body
<-
jsonlite
::
fromJSON
(
paste
(
result
,
collapse
=
""
),
simplifyVector
=
FALSE
)
# 尝试解析JSON
body
<-
tryCatch
({
jsonlite
::
fromJSON
(
paste
(
result
,
collapse
=
""
),
simplifyVector
=
FALSE
)
},
error
=
function
(
e
)
{
stop
(
"JSON解析失败: "
,
e
$
message
,
"\n原始响应: "
,
paste
(
result
,
collapse
=
""
))
})
if
(
is.null
(
body
$
response
)
||
trimws
(
body
$
response
)
==
""
)
stop
(
"Ollama API 返回空内容:"
,
paste
(
result
,
collapse
=
""
))
# 检查是否有错误字段
if
(
!
is.null
(
body
$
error
))
{
stop
(
"API 返回错误: "
,
jsonlite
::
toJSON
(
body
$
error
,
auto_unbox
=
TRUE
))
}
# 提取内容
if
(
!
is.list
(
body
)
||
!
is.list
(
body
$
choices
)
||
length
(
body
$
choices
)
==
0
)
{
stop
(
"API 响应格式异常: "
,
paste
(
result
,
collapse
=
""
))
}
response_content
<-
body
$
choices
[[
1
]]
$
message
$
content
if
(
is.null
(
response_content
)
||
trimws
(
response_content
)
==
""
)
{
stop
(
"API 返回空内容: "
,
paste
(
result
,
collapse
=
""
))
}
body
$
response
response_content
}
...
...
radiant.quickgen/inst/app/tools/analysis/quickgen_chat_ui.R
View file @
45915ece
...
...
@@ -49,12 +49,7 @@ output$chat_history_area <- renderUI({
return
(
create_no_data_ui
())
}
# 内网环境
dify_base_url
<-
"http://172.31.2.2:8078/chat/tfjTZpJDgjQpBeTl"
# 外网环境
# dify_base_url <- "http://180.169.131.147:8078/chat/tfjTZpJDgjQpBeTl"
dify_base_url
<-
"http://122.112.232.121:8079/chat/pmo9kEMGQVAdv8YR"
dify_url
<-
paste0
(
dify_base_url
,
"?showSidebar=true"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment