Skip to main content
Component Name: SermonSearch.razor
Version: 1.0.0
Sermon Search Conversation Screenshot

Dependencies

Services:
AdminSettingsService, UserService, SermonCollectionService, ConversationService, MessageService, ChatService, MarkdownService, CitationService, AuthenticationStateProvider, JS, Snackbar

Variables

Lifecycle Methods

Runtime Methods

StartNewConversationAsync(string, bool, int)

When there is no active conversation, this method calls several other methods to start a new conversation using the inputMessage as the first message.

BuildNewConversation(string)

Instantiates a Conversation object using inputMessage as the Conversation.LastMessage.

BuildStartingMessage(Conversation, bool, int)

Instantiates a Message object using newConversation.

GenerateConversationTitle(string)

Uses ChatService to generate an appropriate 3-5 word title, given the first message in a conversation.

SendMessage()

Checks if _activeSermonCollectionId is empty. If not, this method will either call StartNewConversationAsync or call several methods (including GenerateStreamingResponse) to add the message to the active conversation & stream a response.

BuildUserMessage()

Instantiates a new Message object from user’s input.

GenerateStreamingResponse(string, string)

Instantiates a new system Message object, prompts Azure Open AI via ChatService using userMessage & sermonCollectionId, and asynchronously fills the new system message with a streaming response.

HandleKeyDown(KeyboardEventArgs)

Monitors for user to press Enter, triggering a SendMessage call.

SaveCitationsFromChatContext(List<ChatMessageContext>, string, string)

Asynchronous method to handle retrieving citations’ information from a streamed response & uses CitationService.AddNewCitationsAsync to save them to Cosmos DB.

TrimCitationContent(string, string)

Used to trim excess metadata off of a citation when ShowCitation is called

ShowCitation(Citation)

Set the state variables for displaying the active citation, given a Citation object.

SetActiveConversation(string)

Sets _activeSermonCollectionId to the sermon collection of the last message & calls ConversationService.SetActiveConversationByIdAsync().

UpdateMessageDictionaries()

Sets _messageCollectionImageSrc and _messageCollectionNames.

GetConversationClass(string)

Determines the class applied to conversations in the Conversation History MudTabPanel.

ToggleDrawer(Anchor)

Toggles the right side drawer open & closed.

ShowStartScreen()

Clears _messages & sets the active conversation to null; returns the user to the start screen for a new conversation.

ClearAndFocusInputAsync()

Clears _userInputValue and focuses on the user input text field _userInputRef.

ToggleLoading()

Toggles _loading between true and false

StripHtmlTags(string)

Removes all HTML tags from input string.

ScrollToBottom()

JS interop function to keep chat area scrolled to the conversation’s most recent message.

copyToClipboard(string)

JS interop function to copy all HTML content from a system message onto user’s clipboard; used in the ‘Copy’ action button.