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
67ac952e
Commit
67ac952e
authored
Jan 15, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:StackOverFlower
parent
21759cac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
AgentApplicationInfoServiceImpl.java
...ation/aggregate/impl/AgentApplicationInfoServiceImpl.java
+13
-11
No files found.
src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
View file @
67ac952e
...
@@ -212,7 +212,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -212,7 +212,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
largeModelResponse
.
setUser
(
"POC-CREATE-AGENT-SYSTEM"
);
largeModelResponse
.
setUser
(
"POC-CREATE-AGENT-SYSTEM"
);
BufferedReader
bufferedReader
=
llmService
.
chatChunk
(
largeModelResponse
);
BufferedReader
bufferedReader
=
llmService
.
chatChunk
(
largeModelResponse
);
textOutputStream
(
httpServletResponse
,
bufferedReader
,
null
);
textOutputStream
(
httpServletResponse
,
bufferedReader
);
}
}
@Override
@Override
...
@@ -512,8 +512,18 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -512,8 +512,18 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
*/
*/
private
String
llmExecutorAndOutput
(
Float
topP
,
boolean
stream
,
String
model
,
Message
[]
messageArray
,
FunctionResult
functionResult
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
private
String
llmExecutorAndOutput
(
Float
topP
,
boolean
stream
,
String
model
,
Message
[]
messageArray
,
FunctionResult
functionResult
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
if
(
stream
)
{
if
(
stream
)
{
if
(
ObjectUtil
.
isNotNull
(
functionResult
)
&&
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionName
()))
{
httpServletResponse
.
setContentType
(
TEXT_EVENT_STREAM_CHARSET_UTF_8
);
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
LargeModelDemandResult
result
=
new
LargeModelDemandResult
();
result
.
setCode
(
"0"
);
ToolFunction
toolFunction
=
functionResultConvertToolFunction
(
functionResult
);
result
.
setFunction
(
toolFunction
);
writer
.
write
(
EVENT_STREAM_PREFIX
+
JsonUtils
.
serialize
(
result
)
+
"\n\n"
);
writer
.
flush
();
}
BufferedReader
bufferedReader
=
invokeLLMStream
(
model
,
messageArray
,
topP
);
BufferedReader
bufferedReader
=
invokeLLMStream
(
model
,
messageArray
,
topP
);
return
textOutputStream
(
httpServletResponse
,
bufferedReader
,
functionResult
);
return
textOutputStream
(
httpServletResponse
,
bufferedReader
);
}
else
{
}
else
{
LargeModelDemandResult
largeModelDemandResult
=
invokeLLM
(
model
,
messageArray
,
topP
);
LargeModelDemandResult
largeModelDemandResult
=
invokeLLM
(
model
,
messageArray
,
topP
);
if
(
ObjectUtil
.
isNotNull
(
functionResult
)
&&
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionName
()))
{
if
(
ObjectUtil
.
isNotNull
(
functionResult
)
&&
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionName
()))
{
...
@@ -745,20 +755,12 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
...
@@ -745,20 +755,12 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
* @param bufferedReader
* @param bufferedReader
* @throws IOException
* @throws IOException
*/
*/
private
String
textOutputStream
(
HttpServletResponse
httpServletResponse
,
BufferedReader
bufferedReader
,
FunctionResult
functionResult
)
throws
private
String
textOutputStream
(
HttpServletResponse
httpServletResponse
,
BufferedReader
bufferedReader
)
throws
IOException
{
IOException
{
String
res
=
""
;
String
res
=
""
;
httpServletResponse
.
setContentType
(
TEXT_EVENT_STREAM_CHARSET_UTF_8
);
httpServletResponse
.
setContentType
(
TEXT_EVENT_STREAM_CHARSET_UTF_8
);
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
PrintWriter
writer
=
httpServletResponse
.
getWriter
();
StringBuilder
output
=
new
StringBuilder
();
StringBuilder
output
=
new
StringBuilder
();
if
(
ObjectUtil
.
isNotNull
(
functionResult
)
&&
StringUtils
.
isNotBlank
(
functionResult
.
getFunctionName
()))
{
LargeModelDemandResult
result
=
new
LargeModelDemandResult
();
result
.
setCode
(
"0"
);
ToolFunction
toolFunction
=
functionResultConvertToolFunction
(
functionResult
);
result
.
setFunction
(
toolFunction
);
writer
.
write
(
EVENT_STREAM_PREFIX
+
JsonUtils
.
serialize
(
result
)
+
"\n\n"
);
writer
.
flush
();
}
while
((
res
=
bufferedReader
.
readLine
())
!=
null
)
{
while
((
res
=
bufferedReader
.
readLine
())
!=
null
)
{
if
(
StringUtils
.
isBlank
(
res
))
{
if
(
StringUtils
.
isBlank
(
res
))
{
continue
;
continue
;
...
...
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