-
Notifications
You must be signed in to change notification settings - Fork 29
Add configurable default questions for Chat on Your Data feature #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace MVCWeb.Models; | ||
|
|
||
| public class ChatOnYourDataModel | ||
| { | ||
| public string Link { get; set; } = string.Empty; | ||
| public List<string> DefaultQuestions { get; set; } = new List<string>(); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| @inject IConfiguration Configuration | ||||||
| @model ChatOnYourDataModel | ||||||
| @{ | ||||||
| ViewData["Title"] = "Chat On Your Data"; | ||||||
| } | ||||||
|
|
@@ -25,9 +25,34 @@ | |||||
| <div class="col-lg-12"> | ||||||
| <div class="card"> | ||||||
| <div class="card-body"> | ||||||
| @if (Model.DefaultQuestions != null && Model.DefaultQuestions.Any()) | ||||||
| { | ||||||
| <div class="row mb-3"> | ||||||
| <div class="col-12"> | ||||||
| <h5 class="card-title">Suggested Questions</h5> | ||||||
| <p class="text-muted">Try these sample questions to get started with your document analysis:</p> | ||||||
| <div class="row"> | ||||||
| @foreach (var question in Model.DefaultQuestions) | ||||||
| { | ||||||
| <div class="col-lg-6 col-md-12 mb-2"> | ||||||
| <div class="card border-light"> | ||||||
| <div class="card-body p-3"> | ||||||
| <button type="button" class="btn btn-outline-primary btn-sm w-100 text-start question-btn" | ||||||
| data-question="@question"> | ||||||
| <i class="mdi mdi-chat-question me-1"></i> | ||||||
| @question | ||||||
| </button> | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
| } | ||||||
| </div> | ||||||
| </div> | ||||||
| </div> | ||||||
| } | ||||||
|
|
||||||
| <div id="chat-frame" class="ratio ratio-16x9"> | ||||||
| <iframe id="bigframe" src="@Configuration["ChatOnYourData:Link"]" frameborder="0"></iframe> | ||||||
| <iframe id="bigframe" src="@Model.Link" frameborder="0"></iframe> | ||||||
| </div> | ||||||
|
|
||||||
| </div> | ||||||
|
|
@@ -38,3 +63,58 @@ | |||||
|
|
||||||
| </div> | ||||||
| <!-- container --> | ||||||
|
|
||||||
| <style> | ||||||
|
||||||
| .question-btn { | ||||||
| text-align: left !important; | ||||||
| white-space: normal; | ||||||
| height: auto; | ||||||
| padding: 10px 15px; | ||||||
| transition: all 0.2s ease; | ||||||
| } | ||||||
|
|
||||||
| .question-btn:hover { | ||||||
| background-color: #0d6efd; | ||||||
| border-color: #0d6efd; | ||||||
| color: white; | ||||||
| } | ||||||
|
|
||||||
| .question-btn.active { | ||||||
| background-color: #0d6efd; | ||||||
| border-color: #0d6efd; | ||||||
| color: white; | ||||||
| } | ||||||
|
|
||||||
| .question-btn i { | ||||||
| margin-right: 8px; | ||||||
| } | ||||||
| </style> | ||||||
|
|
||||||
| <script> | ||||||
| document.addEventListener('DOMContentLoaded', function() { | ||||||
| const questionButtons = document.querySelectorAll('.question-btn'); | ||||||
| const iframe = document.getElementById('bigframe'); | ||||||
|
|
||||||
| questionButtons.forEach(button => { | ||||||
| button.addEventListener('click', function() { | ||||||
| const question = this.getAttribute('data-question'); | ||||||
|
|
||||||
| // Try to send the question to the iframe via postMessage | ||||||
| if (iframe && iframe.contentWindow) { | ||||||
| try { | ||||||
| iframe.contentWindow.postMessage({ | ||||||
| type: 'set_question', | ||||||
| question: question | ||||||
| }, '*'); | ||||||
|
||||||
| }, '*'); | |
| }, iframeOrigin); // Use the extracted origin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable
DEFAULT_QUESTIONSwon’t map to the nested config keyChatOnYourData:DefaultQuestions. UseChatOnYourData__DefaultQuestionsto match ASP.NET Core’s environment variable binding convention.