Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
poc
poc-api
Commits
d3bc71cc
Commit
d3bc71cc
authored
Mar 03, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:修复大模型调用失败提示文案
parent
4e805c45
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
14 deletions
+19
-14
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+2
-1
AIDialogueServiceImpl.java
...ource/demand/ai/aggregate/impl/AIDialogueServiceImpl.java
+17
-13
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
d3bc71cc
...
...
@@ -816,7 +816,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
if
(!
"0"
.
equals
(
result
.
getCode
()))
{
logger
.
error
(
"LLM Error,code:{}"
,
result
.
getCode
());
I18nMessageException
ex
=
new
I18nMessageException
(
"exception/call.failure"
);
writer
.
write
(
EVENT_STREAM_PREFIX
+
JsonUtils
.
serialize
(
ex
.
getMessage
())
+
"\n\n"
);
result
.
setMessage
(
ex
.
getMessage
());
writer
.
write
(
EVENT_STREAM_PREFIX
+
JsonUtils
.
serialize
(
result
)
+
"\n\n"
);
writer
.
write
(
EVENT_STREAM_PREFIX
+
"[DONE]\n\n"
);
writer
.
flush
();
writer
.
close
();
...
...
src/main/java/cn/com/poc/thirdparty/resource/demand/ai/aggregate/impl/AIDialogueServiceImpl.java
View file @
d3bc71cc
...
...
@@ -19,6 +19,8 @@ import org.apache.http.entity.StringEntity;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicHeader
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
...
...
@@ -40,6 +42,8 @@ import java.util.List;
public
class
AIDialogueServiceImpl
implements
AIDialogueService
{
private
final
String
POST
=
"POST"
;
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AIDialogueService
.
class
);
@Value
(
"${dgtools.domain.url}"
)
private
String
DOMAIN_URL
;
...
...
@@ -95,20 +99,20 @@ public class AIDialogueServiceImpl implements AIDialogueService {
.
build
()
);
InputStream
inputStream
=
httpResponse
.
getEntity
().
getContent
();
Header
contentType
=
httpResponse
.
getFirstHeader
(
"Content-type"
);
//
Header contentType = httpResponse.getFirstHeader("Content-type");
BufferedReader
bufferedReader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
));
if
(
"application/json"
.
equals
(
contentType
.
getValue
())
||
"text/plain;charset=UTF-8"
.
equals
(
contentType
.
getValue
())
||
"application/json; charset=utf-8"
.
equals
(
contentType
.
getValue
()))
{
String
res
;
StringBuilder
stringBuilder
=
new
StringBuilder
();
while
((
res
=
bufferedReader
.
readLine
())
!=
null
)
{
if
(
StringUtils
.
isBlank
(
res
))
{
continue
;
}
stringBuilder
.
append
(
res
);
}
LargeModelDemandResult
result
=
JsonUtils
.
deSerialize
(
stringBuilder
.
toString
(),
LargeModelDemandResult
.
class
);
throw
new
BusinessException
(
result
.
getMessage
());
}
//
if ("application/json".equals(contentType.getValue()) || "text/plain;charset=UTF-8".equals(contentType.getValue()) || "application/json; charset=utf-8".equals(contentType.getValue())) {
//
String res;
//
StringBuilder stringBuilder = new StringBuilder();
//
while ((res = bufferedReader.readLine()) != null) {
//
if (StringUtils.isBlank(res)) {
//
continue;
//
}
//
stringBuilder.append(res);
//
}
//
LargeModelDemandResult result = JsonUtils.deSerialize(stringBuilder.toString(), LargeModelDemandResult.class);
// logger.error("调用大模型接口失败:{}",
result.getMessage());
//
}
return
bufferedReader
;
}
...
...
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