SermonSearch.razorVersion:
1.0.0
Dependencies
Services:AdminSettingsService, UserService, SermonCollectionService, ConversationService, MessageService, ChatService, MarkdownService, CitationService, AuthenticationStateProvider, JS, Snackbar
Variables
| Variable Name | Type | Description |
|---|---|---|
_conversations | List<Conversation> | List of conversations available to the current user |
_messages | List<Message> | List of messages to display in chat |
_sermonCollections | IEnumerable<SermonCollection> | Sermon collections available to the current user |
_messageCollectionImageSrc | Dictionary<string, string> | Dictionary of image metadata for _sermonCollections |
_messageCollectionNames | Dictionary<string, string> | Dictionary of name metadata for _sermonCollections |
_citations | Dictionary<string, List<citation>> | Dictionary of current conversation’s citations, organized by message |
_userInputRef | MudTextField<string> | Represents the user input text field element |
_chatContainer | MudItem | Represents the container element that wraps chat area |
_chatClient | ChatClient? | An Azure Open AI ChatClient from ChatService |
_deploymentName | string | Name of the Azure Open AI model deployment |
_activeSermonCollectionId | string | State of currently selected sermon collection’s Id |
_activeConversationId | string | State of currently selected conversation’s Id |
_activeCitationId | string | State of currently selected citation’s Id |
_activeCitationTitle | string | State of currently selected citation’s title |
_activeCitationContent | string | State of currently selected citation’s content |
_activeCitationUrl | string | State of the currently selected citation’s source URL |
_userInputValue | string | State of the user input text field |
_appLogoSrc | string | Relative link to app logo |
_activeTabPanelIndex | int | Index indicating which MudTabPanel is active (Citation or Chat History) |
_loading | bool | Indicates when component is in a loading state |
_drawerOpen | bool | Indicates whether the right side drawer is open or closed |
_anchor | Anchor | Positioning anchor for right side drawer |
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 newMessage 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 HistoryMudTabPanel.
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.
