quick reply submit.
This commit is contained in:
parent
fc6e1807ad
commit
fe197fd3ea
BIN
docs/static/screenshots/web-live-chat.png
vendored
BIN
docs/static/screenshots/web-live-chat.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 27 KiB |
|
|
@ -2,7 +2,6 @@ using BotSharp.Abstraction.Messaging;
|
||||||
using BotSharp.Abstraction.Messaging.JsonConverters;
|
using BotSharp.Abstraction.Messaging.JsonConverters;
|
||||||
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
using BotSharp.Abstraction.Messaging.Models.RichContent;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using System.Text.Json.Serialization.Metadata;
|
|
||||||
|
|
||||||
namespace BotSharp.Plugin.ChatHub.Hooks;
|
namespace BotSharp.Plugin.ChatHub.Hooks;
|
||||||
|
|
||||||
|
|
@ -102,7 +101,7 @@ public class ChatHubConversationHook : ConversationHookBase
|
||||||
{
|
{
|
||||||
var conv = _services.GetRequiredService<IConversationService>();
|
var conv = _services.GetRequiredService<IConversationService>();
|
||||||
|
|
||||||
await _chatHub.Clients.User(_user.Id).SendAsync("OnMessageReceivedFromAssistant", new ChatResponseModel()
|
var json = JsonSerializer.Serialize(new ChatResponseModel()
|
||||||
{
|
{
|
||||||
ConversationId = conv.ConversationId,
|
ConversationId = conv.ConversationId,
|
||||||
MessageId = message.MessageId,
|
MessageId = message.MessageId,
|
||||||
|
|
@ -114,7 +113,8 @@ public class ChatHubConversationHook : ConversationHookBase
|
||||||
LastName = "Assistant",
|
LastName = "Assistant",
|
||||||
Role = AgentRole.Assistant
|
Role = AgentRole.Assistant
|
||||||
}
|
}
|
||||||
});
|
}, _serializerOptions);
|
||||||
|
await _chatHub.Clients.User(_user.Id).SendAsync("OnMessageReceivedFromAssistant", json);
|
||||||
|
|
||||||
await base.OnResponseGenerated(message);
|
await base.OnResponseGenerated(message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
"MaxRecursiveDepth": 3,
|
"MaxRecursiveDepth": 3,
|
||||||
"LlmConfig": {
|
"LlmConfig": {
|
||||||
"Provider": "azure-openai",
|
"Provider": "azure-openai",
|
||||||
"Model": "one"
|
"Model": "gpt-35-turbo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,5 @@
|
||||||
"createdDateTime": "2023-08-18T14:39:32.2349685Z",
|
"createdDateTime": "2023-08-18T14:39:32.2349685Z",
|
||||||
"updatedDateTime": "2023-08-18T14:39:32.2349686Z",
|
"updatedDateTime": "2023-08-18T14:39:32.2349686Z",
|
||||||
"id": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a",
|
"id": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a",
|
||||||
"isPublic": true,
|
"isPublic": true
|
||||||
"llmConfig": {
|
|
||||||
"provider": "azure-openai",
|
|
||||||
"model": "one"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -66,8 +66,7 @@ IRichContent.prototype.rich_type;
|
||||||
IRichContent.prototype.text;
|
IRichContent.prototype.text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {IRichContent} TextMessage
|
* @typedef {Object} TextMessage
|
||||||
* @implements {IRichContent}
|
|
||||||
* @property {string} text
|
* @property {string} text
|
||||||
* @property {string} rich_type
|
* @property {string} rich_type
|
||||||
*/
|
*/
|
||||||
|
|
@ -81,7 +80,7 @@ IRichContent.prototype.text;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {IRichContent} QuickReplyMessage
|
* @typedef {Object} QuickReplyMessage
|
||||||
* @property {string} text
|
* @property {string} text
|
||||||
* @property {string} rich_type
|
* @property {string} rich_type
|
||||||
* @property {QuickReplyElement[]} quick_replies
|
* @property {QuickReplyElement[]} quick_replies
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,11 @@
|
||||||
{#if message.rich_content.message.rich_type == 'text'}
|
{#if message.rich_content.message.rich_type == 'text'}
|
||||||
<RcText message={message.rich_content.message} />
|
<RcText message={message.rich_content.message} />
|
||||||
{:else if message.rich_content.message.rich_type == 'quick_reply'}
|
{:else if message.rich_content.message.rich_type == 'quick_reply'}
|
||||||
<RcQuickReply message={message.rich_content.message} />
|
<RcQuickReply
|
||||||
|
agentId={params.agentId}
|
||||||
|
conversationId={params.conversationId}
|
||||||
|
message={message.rich_content.message}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,32 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { sendMessageToHub, GetDialogs } from '$lib/services/conversation-service.js';
|
||||||
|
|
||||||
/** @type {import('$typedefs').QuickReplyMessage} */
|
/** @type {import('$typedefs').QuickReplyMessage} */
|
||||||
export let message;
|
export let message;
|
||||||
|
/** @type {string} */
|
||||||
|
export let agentId;
|
||||||
|
/** @type {string} */
|
||||||
|
export let conversationId;
|
||||||
|
|
||||||
|
export const fn = {
|
||||||
|
/**
|
||||||
|
* @param {string} payload
|
||||||
|
*/
|
||||||
|
onTextSubmitted: (payload) => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} payload
|
||||||
|
*/
|
||||||
|
async function onQuickReplyClick(payload) {
|
||||||
|
await sendMessageToHub(agentId, conversationId, payload);
|
||||||
|
message.quick_replies = [];
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<span>{message.text}</span>
|
<span>{message.text}</span>
|
||||||
<div class="fixed-bottom p-2 text-center" style="margin-bottom: 10vh;">
|
<div class="fixed-bottom p-2 text-center" style="margin-bottom: 10vh;">
|
||||||
{#each message.quick_replies as reply}
|
{#each message.quick_replies as reply}
|
||||||
<button class="btn btn-secondary btn-rounded btn-sm m-1">{reply.title}</button>
|
<button class="btn btn-secondary btn-rounded btn-sm m-1" on:click={() => onQuickReplyClick(reply.payload)}>{reply.title}</button>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
Loading…
Reference in a new issue