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.Models.RichContent;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System.Text.Json.Serialization.Metadata;
|
||||
|
||||
namespace BotSharp.Plugin.ChatHub.Hooks;
|
||||
|
||||
|
|
@ -102,7 +101,7 @@ public class ChatHubConversationHook : ConversationHookBase
|
|||
{
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
|
||||
await _chatHub.Clients.User(_user.Id).SendAsync("OnMessageReceivedFromAssistant", new ChatResponseModel()
|
||||
var json = JsonSerializer.Serialize(new ChatResponseModel()
|
||||
{
|
||||
ConversationId = conv.ConversationId,
|
||||
MessageId = message.MessageId,
|
||||
|
|
@ -114,7 +113,8 @@ public class ChatHubConversationHook : ConversationHookBase
|
|||
LastName = "Assistant",
|
||||
Role = AgentRole.Assistant
|
||||
}
|
||||
});
|
||||
}, _serializerOptions);
|
||||
await _chatHub.Clients.User(_user.Id).SendAsync("OnMessageReceivedFromAssistant", json);
|
||||
|
||||
await base.OnResponseGenerated(message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
"MaxRecursiveDepth": 3,
|
||||
"LlmConfig": {
|
||||
"Provider": "azure-openai",
|
||||
"Model": "one"
|
||||
"Model": "gpt-35-turbo"
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,5 @@
|
|||
"createdDateTime": "2023-08-18T14:39:32.2349685Z",
|
||||
"updatedDateTime": "2023-08-18T14:39:32.2349686Z",
|
||||
"id": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a",
|
||||
"isPublic": true,
|
||||
"llmConfig": {
|
||||
"provider": "azure-openai",
|
||||
"model": "one"
|
||||
}
|
||||
"isPublic": true
|
||||
}
|
||||
|
|
@ -66,8 +66,7 @@ IRichContent.prototype.rich_type;
|
|||
IRichContent.prototype.text;
|
||||
|
||||
/**
|
||||
* @typedef {IRichContent} TextMessage
|
||||
* @implements {IRichContent}
|
||||
* @typedef {Object} TextMessage
|
||||
* @property {string} text
|
||||
* @property {string} rich_type
|
||||
*/
|
||||
|
|
@ -81,7 +80,7 @@ IRichContent.prototype.text;
|
|||
*/
|
||||
|
||||
/**
|
||||
* @typedef {IRichContent} QuickReplyMessage
|
||||
* @typedef {Object} QuickReplyMessage
|
||||
* @property {string} text
|
||||
* @property {string} rich_type
|
||||
* @property {QuickReplyElement[]} quick_replies
|
||||
|
|
|
|||
|
|
@ -176,7 +176,11 @@
|
|||
{#if message.rich_content.message.rich_type == 'text'}
|
||||
<RcText message={message.rich_content.message} />
|
||||
{: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}
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,32 @@
|
|||
<script>
|
||||
import { sendMessageToHub, GetDialogs } from '$lib/services/conversation-service.js';
|
||||
|
||||
/** @type {import('$typedefs').QuickReplyMessage} */
|
||||
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>
|
||||
|
||||
<span>{message.text}</span>
|
||||
<div class="fixed-bottom p-2 text-center" style="margin-bottom: 10vh;">
|
||||
{#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}
|
||||
</div>
|
||||
Loading…
Reference in a new issue