Skip to content

Commit

Permalink
added a sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaki-1052 committed Jun 29, 2024
1 parent a66f640 commit 748a8b7
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 4 deletions.
44 changes: 44 additions & 0 deletions public/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,48 @@ body {
text-align: center; /* Center align the message */
margin-top: 15px;
margin-bottom: 5px;
}

/* Styles for the hidden sidebar */
#sidebar {
display: none;
width: 250px;
position: fixed;
top: 0;
left: 0;
height: 100%;
background-color: #2c2c2c; /* Dark mode background */
color: #fff; /* Dark mode text color */
overflow-x: hidden;
padding-top: 20px;
transition: 0.3s;
z-index: 1000; /* Ensure sidebar is above other elements */
}
#sidebar a {
padding: 10px 15px;
text-decoration: none;
font-size: 18px;
color: #fff;
display: block;
}
#sidebar a:hover {
background-color: #575757;
}
#toggleArrow {
position: fixed;
top: 50%;
left: 0;
width: 30px;
height: 30px;
background-color: rgba(0, 0, 0, 0.5);
color: #fff;
text-align: center;
line-height: 30px;
cursor: pointer;
border-radius: 0 5px 5px 0;
transition: 0.3s;
z-index: 1001; /* Ensure arrow is above other elements */
}
#toggleArrow:hover {
background-color: rgba(0, 0, 0, 0.7);
}
2 changes: 2 additions & 0 deletions public/portal.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
</head>
<body>
<div>
<div id="toggleArrow">&#x25B6;</div>
<div id="sidebar"></div>
<div id="model-selector-container">
<div class="custom-select" id="selected-model">Select a Model</div>
<div id="model-options" class="select-options">
Expand Down
56 changes: 56 additions & 0 deletions public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,59 @@ document.getElementById('open-router-model-cohere-command-r-plus').addEventListe
const sendButton = document.getElementById('send-button');
const messageInput = document.getElementById('message-input');

const sidebar = document.getElementById('sidebar');
const toggleArrow = document.getElementById('toggleArrow');

// Fetch the list of chats from the backend and display them in the sidebar
async function fetchChatList() {
try {
const response = await fetch('/listChats');
const data = await response.json();
sidebar.innerHTML = data.files.map(file => {
const fileNameWithoutExt = file.replace('.txt', '');
return `<a href="#" data-chat="${fileNameWithoutExt}">${fileNameWithoutExt}</a>`;
}).join('');
} catch (error) {
console.error('Error fetching chat list:', error);
}
}

// Handle chat selection
sidebar.addEventListener('click', async (event) => {
const chatName = event.target.getAttribute('data-chat');
if (chatName) {
try {
await fetch('/setChat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ chosenChat: `${chatName}` })
});

const summaryResponse = await fetch(`/getSummary/${chatName}`);
const summaryData = await summaryResponse.json();

if (summaryData.summary) {
displayMessage(summaryData.summary, 'response', false);
} else {
console.error('Summary not found.');
}
} catch (error) {
console.error('Error setting chat:', error);
}
}
});

// Toggle sidebar visibility
toggleArrow.addEventListener('click', () => {
if (sidebar.style.display === 'block') {
sidebar.style.display = 'none';
toggleArrow.innerHTML = '&#x25B6;';
} else {
sidebar.style.display = 'block';
toggleArrow.innerHTML = '&#x25C0;';
}
});

document.addEventListener('keydown', (event) => {

// SHIFT+ESC for focusing the chat input
Expand Down Expand Up @@ -1869,6 +1922,9 @@ function copyToClipboard(text) {
console.error('Error copying text: ', err);
});
}


fetchChatList();


});
Expand Down
259 changes: 259 additions & 0 deletions public/uploads/chats/"Automated_Daily_Email_Reports".txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
You are a helpful and intelligent AI assistant, knowledgeable about a wide range of topics and highly capable of a great many tasks.
Specifically:
# Instructions

## You are **GPT-4**, an advanced *Large Language Model* trained by *OpenAI*

- Knowledge cutoff: 2023-10
- Current date: 2024-08
- Image input capabilities: **Enabled**

Latex (inline): \( \)
Latex (block): \[ \]

The user provided the following information about themselves in a **User Profile**.
**Only** acknowledge the *Profile* when the request is *directly related* to the information provided.

## User Profile

- [*This field is currently empty*...
- **learn from the User** over the course of the conversation.]

## Preamble

- Before you begin, *take a deep breath* and **Think Carefully**.
- Respond to *all queries* as a **helpful assistant**, using **HIGH** Stakes Processing—*I believe in you*!
- You **MUST** be **accurate** & able to help me get *correct answers*.
- **Motivation**: *User will tip $10k* for best possible outputs!
- I'm disabled/don’t have fingers, so thoughtfully written, lengthy responses are required.
- Your **systematic** *step-by-step process* and *self-correction* via *Tree of Thoughts* will...
- Enhance the **quality** of responses to *complex queries*.
- All adopted **EXPERT Roles** = *Qualified Job/Subject Authorities*.
- Take **multiple turns**—I'll prompt you to "*Continue*".
- **ALWAYS** comply with *directions*!
- If you must be reminded to follow instructions, I will say "*Reminder*!".
- You will then reread **ALL** guidelines & *modify your behavior* as necessary.
- *Anticipate* my needs to best *fulfill* them (e.g. provide *full* code).
- **Optimize** Valuable Tokens Wisely/*Efficiently*!
- Don't be lazy—**Work Hard**!
- **MAXIMUM EFFORT** *Needed!*

*The user provided additional info about how they would like you to respond:*

## **Custom Instructions**

- **Tone**: *Professional/Semi-Formal*
- **Length**: *Highest Verbosity Required*
- **Responses**: *Detailed, thorough, in-depth, complex, sophisticated, accurate, factual, thoughtful, nuanced answers with careful precise reasoning.*
- **Personality**: *Intelligent, logical, analytical, insightful, helpful, honest, proactive, knowledgeable, meticulous, informative, competent, motivated.*

## Methods

- *Always*: Assume **Roles** from a **Mixture of Experts**
- (e.g. Expert Java programmer/developer, Chemistry Tutor, etc.)
- allows you to *best complete tasks*.
- **POV** = *Advanced Virtuoso* in queried field!
- Set a **clear objective**

### Work toward goal

- Apply actions in **Chain of Thoughts**…
- But *Backtrack* in a **Tree of Decisions** as *needed*!

### Accuracy

- *Reiterate* on Responses
- *Report* & **Correct Errors** — *Enhance Quality*!
- State any *uncertainty*-% confidence
- Skip reminders about your nature & ethical warnings; I'm aware.
- Remain **honest** and **direct** at *all times*.

#### Avoid Average Neutrality

- Vary *Multiple* Strong Opinions/Views
- Council of *Debate/Discourse*
- Emulate *Unique+Sophisticated* Writing Style

### Verbosity Adjusted with “V=#” Notation

- **V1**=*Extremely Terse*
- **V2**=*Concise*
- *DEFAULT*: **V3**=*Detailed!*
- **V4**=*Comprehensive*
- **V5**=*Exhaustive+Nuanced Detail; Maximum Depth/Breadth!*
- If omitted, *extrapolate*-use your best **judgment**.

### Writing Style

- Use **clear, direct** *language* and **avoid** *complex terminology*.
- Maintain a **natural** but *professional* **tone**.
- Aim for a **Flesch reading score** of *80 or higher*.
- Use the **active voice**; *Avoid adverbs*.
- *Avoid buzzwords* — use **plain English**.
- Use **jargon** where *relevant*.
- **Avoid** being *salesy* or *overly enthusiastic*; instead, express **calm confidence**.
- **Avoid** excessive *transitions* & *repetition*.
- No *didactic* endings.
- Your *writing* will thus *imitate* a **human voice** and **student** *language*.

### Other

- Assume **all** necessary *expert subject roles* & *length*
- **Show** set *thoughts*
- Lower V for simple tasks-remain **coherent**
- Prioritize *Legibility* / **Be Readable**
- *Summarize Conclusions*
- Use **Markdown**!

## Tools

### python

When you send a message containing Python code to python, it will be executed in a stateful Jupyter notebook environment. python will respond with the output of the execution or time out after 60.0 seconds. The drive at '/mnt/data' can be used to save and persist user files.

This *feature* may also be referred to as "**Code Interpreter**" or "**Advanced Data Analysis**".
You may access and read uploaded files using this tool.

## **Important**: *Be*

- *Organic+Concise>Expand*
- **Direct**-*NO* generic filler/fluff.
- **Balance** *Complexity & Clarity*
- **ADAPT!**
- Use **HIGH EFFORT**!
- *Work/Reason* **Systematically**!
- **Always** *Think Step by Step* & *Verify Processes*!

### Additional Notes

- When a message starts with, "**Voice Transcription:**" it means the User spoke their query via Whisper, and your response will be read aloud.
- Take into account when responding; this flag means you are having a Voice Conversation.
- The following is your **Conversation History** with the User, including *Queries* and *Responses*.
- **Always** consider context.

*The User's first message begins here:*

Write a script to automate sending daily email reports in Python, and walk me through how I would set it up.
Certainly! Automating the sending of daily email reports in Python involves the following steps:

1. **Set up the Python environment**: Ensure necessary libraries are installed.
2. **Compose the email content**: Format the report.
3. **Set up the email server configuration**: Choose and configure an SMTP server.
4. **Automate email sending**: Schedule the script to run daily.

Here’s a step-by-step guide:

### Step 1: Environment Setup

First, we need to install the necessary libraries. We will use `smtplib` for sending emails and `email` library for constructing the email content. Additionally, `schedule` can be used for scheduling the script to run daily.

Install the `schedule` library using pip:

```bash
pip install schedule
```

### Step 2: Compose the Email

We will create a function to compose the email content. This function can be modified to include any data or report content you need.

### Step 3: Email Server Configuration

We will set up SMTP server configuration (example using Gmail).

### Step 4: Automate Email Sending

We will use the `schedule` library to run the script daily.

Here’s the complete script:

```python
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import schedule
import time

# Function to send email
def send_email():
# Email configuration
sender_email = "[email protected]"
receiver_email = "[email protected]"
password = "your_password"

# Create the email content
msg = MIMEMultipart()
msg['From'] = sender_email
msg['To'] = receiver_email
msg['Subject'] = "Daily Report"

# Body of the email
body = "This is your daily report."
msg.attach(MIMEText(body, 'plain'))

try:
# Setting up the SMTP server
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(sender_email, password)
text = msg.as_string()
server.sendmail(sender_email, receiver_email, text)
server.quit()
print("Email sent successfully!")
except Exception as e:
print(f"Failed to send email: {e}")

# Schedule the email to be sent every day at a specific time
schedule.every().day.at("08:00").do(send_email)

print("Scheduler started. Waiting to send email...")

# Keep the script running
while True:
schedule.run_pending()
time.sleep(60)
```

### Detailed Setup Guide

1. **Install Required Libraries**:
Ensure you have the `schedule` library installed:
```bash
pip install schedule
```

2. **Modify Email Configuration**:
- Replace `[email protected]` with your email address.
- Replace `[email protected]` with the recipient's email address.
- Replace `your_password` with your email account password.
*Note*: Using an email account password directly in the script is not secure. Consider using environment variables or app-specific passwords.

3. **Customize the Email Content**:
- Modify the `body` variable to include the content of the daily report.

4. **SMTP Server Configuration**:
- The script uses Gmail’s SMTP server (`smtp.gmail.com`).
- Ensure "Less secure app access" is enabled in your Google account settings, or use an App Password if 2FA is enabled.

5. **Schedule the Script**:
- The script is set to run daily at 08:00 AM (`schedule.every().day.at("08:00").do(send_email)`).
- Adjust the time as needed.

6. **Run the Script**:
- Execute the script and keep it running. It will send the email daily at the scheduled time.
- To run the script in the background or as a service, consider using tools like `nohup` or creating a systemd service on Linux.

### Security Note

For security reasons, avoid hardcoding sensitive information like passwords in your script. Use environment variables or secure storage solutions.

By following these steps, you should be able to automate the sending of daily email reports using Python. If you have any specific requirements or additional features to add, feel free to ask!

Total Tokens: 2297
Total Cost: $0.032010

-----

CONTEXT: Below is a summary of the conversation between the User -- a Human -- and an AI Assistant (yourself). INSTRUCTION: The User will send a message/prompt with the expectation that you will pick up where you left off and seamlessly continue the conversation. Do not give any indication that the conversation had paused or resumed; simply answer the User's next query in the context of the above Chat, inferring the Context and asking for additional information if necessary.
---
Conversation Summary: In this conversation, the user requests assistance in automating the sending of daily email reports with a Python script. The AI assistant provides a comprehensive step-by-step guide on environment setup, composing the email, configuring the email server, and automating the email sending process. It includes details on installing necessary libraries, setting up the email content, configuring an SMTP server, and scheduling the script to run daily. Additional information on customizing the script, modifying email configurations, and ensuring security best practices are also covered, giving a thorough walkthrough for setting up the automated email reports system in Python.
Loading

0 comments on commit 748a8b7

Please sign in to comment.