Skip to content

Commit e242d99

Browse files
author
Milder Hernandez Cagua
committed
Updates
1 parent ed651d6 commit e242d99

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

agents/semantickernel-agents-core/src/main/java/com/microsoft/semantickernel/agents/chatcompletion/ChatCompletionAgent.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private Mono<List<ChatMessageContent<?>>> internalInvokeAsync(
110110
? invocationContext.getPromptExecutionSettings()
111111
: kernelArguments.getExecutionSettings().get(chatCompletionService.getServiceId());
112112

113-
final InvocationContext newMessagesContext = InvocationContext.builder()
113+
final InvocationContext updatedInvocationContext = InvocationContext.builder()
114114
.withPromptExecutionSettings(executionSettings)
115115
.withToolCallBehavior(invocationContext.getToolCallBehavior())
116116
.withTelemetry(invocationContext.getTelemetry())
@@ -119,7 +119,7 @@ private Mono<List<ChatMessageContent<?>>> internalInvokeAsync(
119119
.withReturnMode(InvocationReturnMode.FULL_HISTORY)
120120
.build();
121121

122-
return formatInstructionsAsync(kernel, arguments, newMessagesContext).flatMap(
122+
return formatInstructionsAsync(kernel, arguments, updatedInvocationContext).flatMap(
123123
instructions -> {
124124
// Create a new chat history with the instructions
125125
ChatHistory chat = new ChatHistory(
@@ -137,7 +137,7 @@ private Mono<List<ChatMessageContent<?>>> internalInvokeAsync(
137137
chat.addAll(history);
138138
int previousHistorySize = chat.getMessages().size();
139139

140-
return chatCompletionService.getChatMessageContentsAsync(chat, kernel, newMessagesContext)
140+
return chatCompletionService.getChatMessageContentsAsync(chat, kernel, updatedInvocationContext)
141141
.map(chatMessageContents -> {
142142
return chatMessageContents.subList(
143143
previousHistorySize,

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/plugins/github/GitHubPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public Mono<List<GitHubModel.Issue>> getIssuesAsync(
103103
});
104104
}
105105

106-
@DefineKernelFunction(name = "get_issue_detail_info", description = "Get issue detail information from GitHub",
106+
@DefineKernelFunction(name = "get_issue_detail_info", description = "Get detail information of a single issue from GitHub",
107107
returnType = "com.microsoft.semantickernel.samples.plugins.github.GitHubModel$IssueDetail")
108108
public GitHubModel.IssueDetail getIssueDetailAsync(
109109
@KernelFunctionParameter(

samples/semantickernel-concepts/semantickernel-syntax-examples/src/main/java/com/microsoft/semantickernel/samples/syntaxexamples/agents/CompletionsAgent.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class CompletionsAgent {
3434
// Only required if AZURE_CLIENT_KEY is set
3535
private static final String CLIENT_ENDPOINT = System.getenv("CLIENT_ENDPOINT");
3636
private static final String MODEL_ID = System.getenv()
37-
.getOrDefault("MODEL_ID", "gpt-35-turbo");
37+
.getOrDefault("MODEL_ID", "gpt-4o");
3838

3939
private static final String GITHUB_PAT = System.getenv("GITHUB_PAT");
4040
public static void main(String[] args) {
@@ -77,7 +77,7 @@ public static void main(String[] args) {
7777
.build();
7878

7979
InvocationContext invocationContext = InvocationContext.builder()
80-
.withToolCallBehavior(ToolCallBehavior.allowAllKernelFunctions(true))
80+
.withToolCallBehavior(ToolCallBehavior.allowAllKernelFunctions(false))
8181
.build();
8282

8383
ChatCompletionAgent agent = ChatCompletionAgent.builder()
@@ -127,7 +127,7 @@ public static void main(String[] args) {
127127
.withVariable("now", System.currentTimeMillis())
128128
.build();
129129

130-
var responses = agent.invokeAsync(
130+
var response = agent.invokeAsync(
131131
List.of(message),
132132
agentThread,
133133
AgentInvokeOptions.builder()
@@ -136,10 +136,7 @@ public static void main(String[] args) {
136136
.build()
137137
).block();
138138

139-
for (var response : responses) {
140-
System.out.println("> " + response.getMessage());
141-
}
139+
System.out.println("> " + response.get(response.size() - 1).getMessage());
142140
}
143141
}
144-
145142
}

semantickernel-api/src/main/java/com/microsoft/semantickernel/agents/Agent.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ public interface Agent {
5353
*/
5454
Mono<List<AgentResponseItem<ChatMessageContent<?>>>> invokeAsync(List<ChatMessageContent<?>> messages, AgentThread thread, AgentInvokeOptions options);
5555

56-
57-
58-
56+
/**
57+
* Notifies the agent of a new message.
58+
*
59+
* @param thread The agent thread to use
60+
*/
5961
Mono<Void> notifyThreadOfNewMessageAsync(AgentThread thread, ChatMessageContent<?> newMessage);
6062
}

semantickernel-api/src/main/java/com/microsoft/semantickernel/agents/KernelAgent.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.microsoft.semantickernel.Kernel;
44
import com.microsoft.semantickernel.orchestration.InvocationContext;
5+
import com.microsoft.semantickernel.orchestration.InvocationReturnMode;
56
import com.microsoft.semantickernel.orchestration.PromptExecutionSettings;
67
import com.microsoft.semantickernel.semanticfunctions.KernelArguments;
78
import com.microsoft.semantickernel.semanticfunctions.PromptTemplate;
@@ -18,16 +19,12 @@
1819
public abstract class KernelAgent implements Agent {
1920

2021
protected final String id;
21-
2222
protected final String name;
23-
2423
protected final String description;
25-
2624
protected final Kernel kernel;
2725
protected final KernelArguments kernelArguments;
2826
protected final InvocationContext invocationContext;
2927
protected final String instructions;
30-
3128
protected final PromptTemplate template;
3229

3330
protected KernelAgent(
@@ -45,7 +42,8 @@ protected KernelAgent(
4542
this.description = description;
4643
this.kernel = kernel;
4744
this.kernelArguments = kernelArguments;
48-
this.invocationContext = invocationContext;
45+
this.invocationContext = invocationContext != null
46+
? invocationContext : InvocationContext.builder().withReturnMode(InvocationReturnMode.FULL_HISTORY).build();
4947
this.instructions = instructions;
5048
this.template = template;
5149
}

0 commit comments

Comments
 (0)