chat: more tweaks

This commit is contained in:
Kyle Drake 2024-04-21 13:59:51 -05:00
parent 87dd81581c
commit 781ad6512f
3 changed files with 7 additions and 8 deletions

View file

@ -4,7 +4,7 @@ document.addEventListener('DOMContentLoaded', () => {
const chatInput = document.getElementById('chat-input');
let messages = [];
let accumulatingMessage = '';
let system = `You are Penelope, an AI coding assistant created to help users develop static websites on Neocities using HTML, CSS, and JavaScript. Provide clear, concise explanations and efficient solutions, focusing on clean, readable, and well-commented code. Break down complex concepts and offer guidance on best practices for accessibility, responsiveness, and performance optimization.
let system = `You are Penelope, an AI coding assistant created to help users develop static websites on Neocities using HTML, CSS, and JavaScript. Provide clear, concise explanations and efficient solutions, focusing on clean, readable, and well-commented code. Break down complex concepts and offer guidance on best practices for accessibility, responsiveness, and performance optimization. Only answer questions related to web development and design.
The user's website consists of:
- index.html (main page)
@ -54,8 +54,7 @@ Maintain a friendly, patient, supportive tone. Prioritize the user's learning an
var formData = new FormData();
formData.append('csrf_token', chatForm.querySelector('input[name="csrf_token"]').value);
// let systemWithFile = system + "\nThis is the user's current file they are editing:\n" + editor.getValue();
let systemWithFile = system
let systemWithFile = system + "\nThis is the user's current file they are editing:\n" + editor.getValue();
formData.append('system', systemWithFile);
formData.append('messages', JSON.stringify(messages));
@ -66,7 +65,7 @@ Maintain a friendly, patient, supportive tone. Prioritize the user's learning an
chatBox.lastElementChild.innerHTML = '<i>thinking...</i>'
source.addEventListener('error', function(e) {
chatBox.lastElementChild.innerText = 'An error occurred. Please try again later.';
chatBox.lastElementChild.innerText = 'An error occurred, or the chat is temporarily unavailable. Please try again later.';
chatForm.querySelector('button').disabled = false;
messages.pop();
})

View file

@ -2420,7 +2420,7 @@ pre, code {
.resize-handle {
position: absolute;
left: -1px; /* Adjust based on handle width to center it on the border */
left: -5px; /* Adjust based on handle width to center it on the border */
top: 50%;
transform: translateY(-50%);
width: 10px; /* Handle width */

View file

@ -90,7 +90,7 @@
<a id="saveButton" class="btn-Action" href="#" onclick="saveTextFile(false); return false" style="opacity: 0.5"><span class="hide-on-mobile"><i class="fa fa-save"></i></span>Save</a>
<span class="hide-on-mobile">
<a class="btn-Action" href="<%= current_site.uri %>/<%= @filename == 'index.html' ? '' : @filename %>" target="_blank"><i class="fa fa-globe"></i> View</a>
<a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: current_site, page_uri: "#{current_site.uri}/#{@filename}"} %>'><i class="fa fa-share-alt chat-button"></i> Share</a><% if current_site.supporter? %><a class="btn-Action" id="chatButton"><i class="fa fa-comments"></i> Chat</a><% end %>
<a href="#" id="shareButton" class="btn-Action" data-container="body" data-toggle="popover" data-placement="bottom" data-content='<%== erb :'_share', layout: false, locals: {site: current_site, page_uri: "#{current_site.uri}/#{@filename}"} %>'><i class="fa fa-share-alt chat-button"></i> Share</a><% if current_site.supporter? %><a class="btn-Action" id="chatButton"><i class="fa fa-comments"></i> Penelope <span style="font-size: 8pt">(beta)</span></a><% end %>
</span>
<!-- <a id="saveAndExitButton" class="btn-Action" href="#" onclick="saveTextFile(true); return false" style="opacity: 0.5"><i class="fa fa-save"></i>&nbsp;&nbsp;Save and Exit</a> -->
<div id="editorUpdates" class="tooltip fade bottom in hidden" style="top: 90px;right: 12.5em;">
@ -119,8 +119,8 @@
<div class="resize-handle"></div>
<div id="chat-box" class="chat-box">
<div class="bot-message message">
<img src="/img/plaincat.svg" style="width: 30px; margin-bottom: 10px;">
<p>I'm Penelope, your coding assistant! I'm here to answer any questions you have about coding web sites.</p>
<img src="/img/heartcat.png" style="width: 30px; margin-bottom: 10px;">
<p>I'm Penelope, your coding assistant! I'm here to help you with your web site.</p>
<p>I'm good at coding but can be wrong on general knowledge, <strong>so be sure to verify facts I give you</strong>.</p>
<p>How can I help you today?</p>
</div>