Repository navigation
[example][java] Add single agent example - #225
Conversation
| public String toString() { | ||
| if (success) { | ||
| return result.toString(); | ||
| return getResultAsString(); |
There was a problem hiding this comment.
bug: when result is null...we got NPE
There was a problem hiding this comment.
Hi, @letaoj . Thanks for your contribution.
The reason why the agent result is not correct is the ChatMessage produced by processInput action doesn't have correspond keyword argument to fill the Prompt in ChatModel. I described the detail below.
And you can refer to the branch https://github.com/wenjin272/flink-agents/tree/single-agent-example-fix which has the patch
| String.format( | ||
| "{\n" + "\"id\": %s,\n" + "\"review\": \"%s\"\n" + "}", | ||
| inputObj.getId(), inputObj.getReview()); | ||
| ChatMessage msg = new ChatMessage(MessageRole.USER, content); |
There was a problem hiding this comment.
Because the Prompt we used should be filled with keyword arguments {"input": input}
public static final Prompt REVIEW_ANALYSIS_PROMPT =
new Prompt(
Arrays.asList(
new ChatMessage(MessageRole.SYSTEM, REVIEW_ANALYSIS_SYSTEM_PROMPT_STR),
new ChatMessage(MessageRole.USER, "\"input\":\n" + "{input}")));
Here, we should provide the keyword arguments in msg, or the Prompt won't be filled. And this is exactly the reason why your can't get correct result.
ChatMessage msg = new ChatMessage(MessageRole.USER, "", Map.of("input", content));
This behavior is indeed not clear for user, we have create a issue #220 , and will fix it in next version.
There was a problem hiding this comment.
Thanks for the detailed explanation. I was not able to figure it out and thought it might be a model issue :|
|
The ci failure is caused by java compile error. You may need rebase master and adjust some code for the |
7e21c71 to
4112213
Compare
|
Thanks again @wenjin272! I'm able to run the workflow now with correct output! |
6489ae4 to
7362e21
Compare
7362e21 to
7933dd1
Compare
|
LGTM. Please take a look at your convenience @xintongsong @Sxnan |
xintongsong
left a comment
There was a problem hiding this comment.
Thank both @letaoj and @wenjin272. Just one last comment from my side.
8cdb972 to
7086a88
Compare
xintongsong
left a comment
There was a problem hiding this comment.
LGTM. I just moved the NOTICE file to resources/META-INF/.
Linked issue: #xxx
Purpose of change
Adding an example usage of SingleAgent in java
Tests
API
Documentation