Skip to content

Commit

Permalink
Merge pull request #2119 from solliancenet/sc-additional-agent-displa…
Browse files Browse the repository at this point in the history
…y-settings

Additional agent display settings (showMessageTokens, showMessageRating , showViewPrompt)
  • Loading branch information
ciprianjichici authored Jan 13, 2025
2 parents 65d6a8b + 403b0ce commit d88ed6d
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 5 deletions.
18 changes: 18 additions & 0 deletions src/dotnet/Common/Models/ResourceProviders/Agent/AgentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ public class AgentBase : ResourceBase
[JsonPropertyName("virtual_security_group_id")]
public string? VirtualSecurityGroupId { get; set; }

/// <summary>
/// Indicates whether to show a token count on the messages.
/// </summary>
[JsonPropertyName("show_message_tokens")]
public bool? ShowMessageTokens { get; set; } = true;

/// <summary>
/// Indicates whether to show rating options on the messages.
/// </summary>
[JsonPropertyName("show_message_rating")]
public bool? ShowMessageRating { get; set; } = true;

/// <summary>
/// Indicates whether to show a view prompt option on agent messages.
/// </summary>
[JsonPropertyName("show_view_prompt")]
public bool? ShowViewPrompt { get; set; } = true;

/// <summary>
/// The object type of the agent.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/ui/ManagementPortal/js/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export type Agent = ResourceBase & {
type: 'knowledge-management' | 'analytics';
inline_context: boolean;

show_message_tokens?: boolean;
show_message_rating?: boolean;
show_view_prompt?: boolean;

ai_model_object_id: string;

vectorization: {
Expand Down
54 changes: 53 additions & 1 deletion src/ui/ManagementPortal/pages/agents/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,45 @@
type="text"
/>
</div>

<!-- Message tokens -->
<div id="aria-show-message-tokens" class="step-header span-2">Would you like to show the message tokens?</div>
<div class="span-2">
<ToggleButton
v-model="showMessageTokens"
on-label="Yes"
on-icon="pi pi-check-circle"
off-label="No"
off-icon="pi pi-times-circle"
aria-labelledby="aria-show-message-tokens"
/>
</div>

<!-- Rate messages -->
<div id="aria-show-message-rating" class="step-header span-2">Would you like to allow the user to rate the agent responses?</div>
<div class="span-2">
<ToggleButton
v-model="showMessageRating"
on-label="Yes"
on-icon="pi pi-check-circle"
off-label="No"
off-icon="pi pi-times-circle"
aria-labelledby="aria-show-message-rating"
/>
</div>

<!-- Show view prompt -->
<div id="aria-show-view-prompt" class="step-header span-2">Would you like to allow the user to see the message prompts?</div>
<div class="span-2">
<ToggleButton
v-model="showViewPrompt"
on-label="Yes"
on-icon="pi pi-check-circle"
off-label="No"
off-icon="pi pi-times-circle"
aria-labelledby="aria-show-view-prompt"
/>
</div>
</section>

<!-- System prompt -->
Expand Down Expand Up @@ -853,6 +892,10 @@ const getDefaultFormValues = () => {
orchestration_settings: {
orchestrator: 'LangChain' as string,
},
showMessageTokens: false as Boolean,
showMessageRating: false as Boolean,
showViewPrompt: false as Boolean,
};
};
Expand Down Expand Up @@ -1139,6 +1182,10 @@ export default {
agent.capabilities?.includes(localOption.code),
) || this.selectedAgentCapabilities;
}
this.showMessageTokens = agent.properties?.show_message_tokens ?? false;
this.showMessageRating = agent.properties?.show_message_rating ?? false;
this.showViewPrompt = agent.properties?.show_view_prompt ?? false;
},
updateAgentWelcomeMessage(newContent: string) {
Expand Down Expand Up @@ -1342,7 +1389,12 @@ export default {
type: this.agentType,
name: this.agentName,
description: this.agentDescription,
properties: { welcome_message: this.agentWelcomeMessage },
properties: {
welcome_message: this.agentWelcomeMessage,
show_message_tokens: this.showMessageTokens,
show_message_rating: this.showMessageRating,
show_view_prompt: this.showViewPrompt,
},
object_id: this.object_id,
inline_context: this.inline_context,
cost_center: this.cost_center,
Expand Down
6 changes: 3 additions & 3 deletions src/ui/UserPortal/components/ChatMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Tokens & Timestamp -->
<span class="message__header--right">
<Chip
v-if="$appConfigStore.showMessageTokens"
v-if="$appConfigStore.showMessageTokens && $appStore.agentShowMessageTokens"
:label="`Tokens: ${message.tokens}`"
class="token-chip"
:class="message.sender === 'User' ? 'token-chip--out' : 'token-chip--in'"
Expand Down Expand Up @@ -110,7 +110,7 @@
</span>
</div>

<template v-if="$appConfigStore.showMessageRating">
<template v-if="$appConfigStore.showMessageRating && $appStore.agentShowMessageRating">
<!-- Rating -->
<span class="ratings">
<!-- Rate message button -->
Expand Down Expand Up @@ -146,7 +146,7 @@

<!-- View prompt button -->
<Button
v-if="$appConfigStore.showViewPrompt"
v-if="$appConfigStore.showViewPrompt && $appStore.agentShowViewPrompt"
class="message__button"
:disabled="message.type === 'LoadingMessage'"
size="small"
Expand Down
3 changes: 3 additions & 0 deletions src/ui/UserPortal/js/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ export interface Agent {
properties?: { [key: string]: string | null };
long_running: boolean;
orchestration_settings?: OrchestrationSettings;
show_message_tokens?: boolean;
show_message_rating?: boolean;
show_view_prompt?: boolean;
}

export interface CompletionRequest {
Expand Down
14 changes: 13 additions & 1 deletion src/ui/UserPortal/stores/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,19 @@ export const useAppStore = defineStore('app', {
highContrastMode: JSON.parse(sessionStorage.getItem('highContrastMode') || 'false') as boolean,
}),

getters: {},
getters: {
agentShowMessageTokens() {
return this.lastSelectedAgent?.properties?.show_message_tokens ?? true;
},

agentShowMessageRating() {
return this.lastSelectedAgent?.properties?.show_message_rating ?? true;
},

agentShowViewPrompt() {
return this.lastSelectedAgent?.properties?.show_view_prompt ?? true;
},
},

actions: {
async init(sessionId: string) {
Expand Down

0 comments on commit d88ed6d

Please sign in to comment.