Skip to content
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

Korostelevm patch 1 #43

Open
wants to merge 128 commits into
base: korostelevm-patch-1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
10c6d6b
Create server.js
jemonteni Nov 3, 2023
de238c7
Update server.js
jemonteni Nov 3, 2023
9081f07
Create client.js
jemonteni Nov 3, 2023
4663d4d
Update client.js
jemonteni Nov 3, 2023
8672766
Create chat.js
jemonteni Nov 3, 2023
50ef557
Update chat.js
jemonteni Nov 3, 2023
69920be
Create chatGPT.js
jemonteni Nov 3, 2023
469ba3b
Update chatGPT.js
jemonteni Nov 3, 2023
9b95cbf
Create styles.css
jemonteni Nov 3, 2023
704a24b
Update styles.css
jemonteni Nov 3, 2023
16f5e89
Update styles.css
jemonteni Nov 3, 2023
95c686d
Create main.css
jemonteni Nov 3, 2023
da72b79
Update main.css
jemonteni Nov 3, 2023
115c087
Create chat.html
jemonteni Nov 3, 2023
e517c72
Update chat.html
jemonteni Nov 3, 2023
c7d1c62
Update chat.html
jemonteni Nov 3, 2023
be4f0c7
Create main.js
jemonteni Nov 3, 2023
fbc2804
Update main.js
jemonteni Nov 3, 2023
6250ec2
Update client.js
jemonteni Nov 3, 2023
c4448d6
Update chat.js
jemonteni Nov 3, 2023
95ecceb
Update client.js
jemonteni Nov 3, 2023
b2ea58c
Update main.js
jemonteni Nov 3, 2023
82f65c3
Update chat.js
jemonteni Nov 3, 2023
728d74f
Update chatGPT.js
jemonteni Nov 3, 2023
a281f83
Update client.js
jemonteni Nov 3, 2023
410541f
Update main.js
jemonteni Nov 3, 2023
9cce1ab
Update chatGPT.js
jemonteni Nov 3, 2023
3f52189
Update chatGPT.js
jemonteni Nov 3, 2023
9e71b53
Update client.js
jemonteni Nov 3, 2023
58fe216
Update main.js
jemonteni Nov 3, 2023
603d10b
Update server.js
jemonteni Nov 3, 2023
b3081e3
Update chat.js
jemonteni Nov 3, 2023
159513a
Update chatGPT.js
jemonteni Nov 3, 2023
cccb634
Update chat.js
jemonteni Nov 3, 2023
d26a9d3
Update client.js
jemonteni Nov 3, 2023
c96f4b8
Update main.js
jemonteni Nov 3, 2023
c97b987
Update chatGPT.js
jemonteni Nov 3, 2023
0797f44
Update chat.js
jemonteni Nov 3, 2023
18bb63a
Update main.js
jemonteni Nov 3, 2023
79f3734
Update server.js
jemonteni Nov 3, 2023
1748066
Update client.js
jemonteni Nov 3, 2023
34ccf34
Update chat.html
jemonteni Nov 3, 2023
85dd3de
Update client.js
jemonteni Nov 3, 2023
ca4ddf1
Update chat.js
jemonteni Nov 3, 2023
42e8fee
Update chatGPT.js
jemonteni Nov 3, 2023
f4dd45e
Update client.js
jemonteni Nov 3, 2023
7dc9b35
Update main.js
jemonteni Nov 3, 2023
a7ae49f
Update server.js
jemonteni Nov 3, 2023
184f458
Update chat.js
jemonteni Nov 3, 2023
26e48b2
Update chatGPT.js
jemonteni Nov 3, 2023
ac314b9
Update client.js
jemonteni Nov 3, 2023
473657e
Update main.js
jemonteni Nov 3, 2023
0bbae78
Update server.js
jemonteni Nov 3, 2023
d81a99c
Update server.js
jemonteni Nov 3, 2023
4627e26
Update chat.js
jemonteni Nov 3, 2023
3da7c4f
Update chatGPT.js
jemonteni Nov 3, 2023
f73df61
Update client.js
jemonteni Nov 3, 2023
34bbeaf
Update main.js
jemonteni Nov 3, 2023
d463500
Update server.js
jemonteni Nov 3, 2023
d0c5ca6
Update server.js
jemonteni Nov 3, 2023
a2493c5
Update chat.js
jemonteni Nov 3, 2023
0ab0867
Update chatGPT.js
jemonteni Nov 3, 2023
922eabb
Update client.js
jemonteni Nov 3, 2023
9682fa5
Update main.js
jemonteni Nov 3, 2023
0668ace
Update server.js
jemonteni Nov 3, 2023
8317fbd
Update chat.html
jemonteni Nov 3, 2023
30aced3
Update chat.html
jemonteni Nov 3, 2023
f88d800
Update chatGPT.js
jemonteni Nov 3, 2023
3d1d3ee
Update chat.js
jemonteni Nov 3, 2023
c5936c2
Update chat.html
jemonteni Nov 3, 2023
30afad1
Update styles.css
jemonteni Nov 3, 2023
9d9a2e2
Update chat.html
jemonteni Nov 3, 2023
02fbb87
Update chat.js
jemonteni Nov 3, 2023
673124a
Update chatGPT.js
jemonteni Nov 3, 2023
d87e964
Update chat.js
jemonteni Nov 3, 2023
53f8dd7
Update chat.html
jemonteni Nov 3, 2023
a8fdcf4
Update chat.js
jemonteni Nov 3, 2023
9f8f25c
Update chatGPT.js
jemonteni Nov 3, 2023
a573824
Create getModels.js
jemonteni Nov 3, 2023
754d45f
Update getModels.js
jemonteni Nov 3, 2023
925cc98
Update getModels.js
jemonteni Nov 3, 2023
4f62e3d
Update chat.html
jemonteni Nov 3, 2023
1842553
Create get_response.js
jemonteni Nov 3, 2023
2fb3f91
Update get_response.js
jemonteni Nov 3, 2023
20b7f69
Update get_response.js
jemonteni Nov 3, 2023
4e39281
Update get_response.js
jemonteni Nov 3, 2023
b068174
Update server.js
jemonteni Nov 3, 2023
431e0c1
Update chat.html
jemonteni Nov 3, 2023
4eed30c
Update chat.html
jemonteni Nov 3, 2023
8d62534
Update get_response.js
jemonteni Nov 3, 2023
f14b1d8
Update get_response.js
jemonteni Nov 3, 2023
f122e82
Update chat.html
jemonteni Nov 3, 2023
cced419
Update chatGPT.js
jemonteni Nov 3, 2023
a302b77
Update get_response.js
jemonteni Nov 3, 2023
f06270e
Update chat.js
jemonteni Nov 3, 2023
639c0f2
Create server.js
jemonteni Nov 3, 2023
ad531d4
Update server.js
jemonteni Nov 3, 2023
5bd30ac
Update server.js
jemonteni Nov 3, 2023
f6b84e7
Create gpt.html
jemonteni Nov 3, 2023
2527f3e
Update gpt.html
jemonteni Nov 3, 2023
1e3e386
Create script.js
jemonteni Nov 3, 2023
7354f8b
Update script.js
jemonteni Nov 3, 2023
55dfc83
Update script.js
jemonteni Nov 3, 2023
74cacae
Update script.js
jemonteni Nov 3, 2023
b5dae52
Update script.js
jemonteni Nov 3, 2023
cbc5c2d
Update script.js
jemonteni Nov 3, 2023
2db5787
Update chat.html
jemonteni Nov 3, 2023
d2741d9
Update script.js
jemonteni Nov 3, 2023
8ca76e0
Update script.js
jemonteni Nov 3, 2023
2762b31
Update script.js
jemonteni Nov 3, 2023
23459ee
Update gpt.html
jemonteni Nov 3, 2023
899897a
Update gpt.html
jemonteni Nov 3, 2023
e5e8c43
Update script.js
jemonteni Nov 3, 2023
55bd765
Update gpt.html
jemonteni Nov 3, 2023
f8887a6
Update gpt.html
jemonteni Nov 3, 2023
a04f97d
Update script.js
jemonteni Nov 3, 2023
3286b1f
Update script.js
jemonteni Nov 3, 2023
e0c920b
Update script.js
jemonteni Nov 3, 2023
b8708de
Update gpt.html
jemonteni Nov 3, 2023
c26872f
Update script.js
jemonteni Nov 3, 2023
7ff9b32
Update gpt.html
jemonteni Nov 3, 2023
0a1df94
Update script.js
jemonteni Nov 3, 2023
3090426
Update gpt.html
jemonteni Nov 3, 2023
64121fb
Create styles.css
jemonteni Nov 3, 2023
cdb6c8d
Update styles.css
jemonteni Nov 3, 2023
a480149
Update script.js
jemonteni Nov 3, 2023
187461a
Update styles.css
jemonteni Nov 3, 2023
d16ce8d
Update script.js
jemonteni Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions public/chat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>Chat with Chat GPT</title>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<header>
<h1>Chat with Chat GPT</h1>
</header>


<main>
<!-- Контейнер для отображения сообщений -->
<div class="chat-container">
<div class="chat-messages">
<!-- Здесь будут отображаться сообщения чата -->
</div>
<form id="chat-form">
<!-- Поле ввода сообщения -->
<input type="text" id="message-input" placeholder="Type your message...">
<!-- Кнопка отправки сообщения -->
<button type="submit">Send</button>
</form>
</div>
</main>

<!-- Импорт скриптов -->
<script src="script.js"></script>
</body>
</html>
70 changes: 70 additions & 0 deletions public/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

/* Reset default margins and paddings */
body, html, ul, ol, li, p, h1, h2, h3, h4, h5, h6, form, fieldset, input, textarea, blockquote {
margin: 0;
padding: 0;
}

/* Set box-sizing to border-box */
*, *::before, *::after {
box-sizing: border-box;
}

/* Remove list styles */
ul, ol {
list-style: none;
}

/* Set a default font */
body {
font-family: Arial, sans-serif;
}

/* Set container styles */
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
}

/* Styling for chat log */
#chat-log {
border: 1px solid #ccc;
padding: 10px;
height: 300px;
overflow-y: auto;
margin-bottom: 10px;
}

.message {
margin-bottom: 10px;
padding: 5px 10px;
border-radius: 5px;
}

.user {
background-color: #f2f2f2;
}

.chatbot {
background-color: #e3e4e6;
}

/* Styling for user input */
#user-input {
width: 80%;
padding: 5px;
margin-right: 10px;
}

#send-button {
padding: 5px 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}

#send-button:hover {
background-color: #45a049;
}
44 changes: 44 additions & 0 deletions public/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
main {
background-color: #f2f2f2;
padding: 20px;
border-radius: 5px;
}

.chat-container {
display: flex;
flex-direction: column;
height: 400px;
overflow-y: scroll;
padding: 10px;
}

.chat-messages {
flex-grow: 1;
margin-bottom: 10px;
}

form#chat-form {
display: flex;
align-items: center;
}

#message-input {
flex-grow: 1;
padding: 8px;
border: none;
border-radius: 5px;
margin-right: 10px;
}

button[type="submit"] {
padding: 8px 16px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}

button[type="submit"]:hover {
background-color: #0056b3;
}
20 changes: 20 additions & 0 deletions public/gpt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Chat GPT</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="chatContainer">
<div id="chatLog"></div>

<form id="chatForm">
<input type="text" id="userMessage" placeholder="Введите сообщение..."/>
<button type="submit" id="sendMessageButton">Отправить</button>
</form>
</div>

<script src="script.js"></script>
</body>
</html>
64 changes: 64 additions & 0 deletions public/js/chat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// chat.js

// Функция отправки сообщения на сервер Chat GPT и получения ответа
async function sendMessageToChatGPT(message) {
try {
const response = await fetch('127.0.0.1', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-76ADBqR4Eqsto6K8p8DNVGhlQi5BSQBGIxu8MKv2E6mla1KY'
},
body: JSON.stringify({
message: message
})
});

if (!response.ok) {
throw new Error('Request failed');
}

const data = await response.json();
return data.answer;
} catch (error) {
console.log('Error:', error.message);
return 'Sorry, I am unable to respond at the moment.';
}
}

function getChatGPTResponse(message) {
const url = '127.0.0.1'; // Replace with your server URL

// остальной код
}

// Обработчик отправки сообщения из формы чата
function handleChatFormSubmit(event) {
event.preventDefault();
const messageInput = document.getElementById('message-input');
const message = messageInput.value.trim();
if (message !== '') {
appendMessageToChat('You: ' + message);
messageInput.value = '';
sendMessageToChatGPT(message)
.then(response => {
appendMessageToChat('ChatBot: ' + response);
})
.catch(error => {
console.log(error);
appendMessageToChat('Sorry, there was an error processing your request.');
});
}
}

// Функция добавления сообщения в окно чата
function appendMessageToChat(message) {
const chatMessages = document.querySelector('.chat-messages');
const messageElement = document.createElement('div');
messageElement.textContent = message;
chatMessages.appendChild(messageElement);
}

// Назначение обработчика события отправки формы чата
const chatForm = document.getElementById('chat-form');
chatForm.addEventListener('submit', handleChatFormSubmit);
63 changes: 63 additions & 0 deletions public/js/chatGPT.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

// chatGPT.js

// API-ключ от Chat GPT
const API_KEY = 'sk-76ADBqR4Eqsto6K8p8DNVGhlQi5BSQBGIxu8MKv2E6mla1KY';

// Функция для отправки сообщения на сервер Chat GPT и получения ответа
async function sendMessageToChatGPT(message) {
try {
const response = await fetch('https://chatgpt.cyclic.app', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-76ADBqR4Eqsto6K8p8DNVGhlQi5BSQBGIxu8MKv2E6mla1KY'
},
body: JSON.stringify({
message: message
})
});

if (!response.ok) {
throw new Error('Request failed');
}

const data = await response.json();
return data.answer;
} catch (error) {
console.log('Error:', error.message);
return 'Sorry, I am unable to respond at the moment.';
}
}

// Функция для отображения полученного ответа от Chat GPT в чате
function displayChatMessage(message) {
const chatMessages = document.querySelector('.chat-messages');
const messageElement = document.createElement('div');
messageElement.classList.add('message');
messageElement.innerText = message;
chatMessages.appendChild(messageElement);
}

// Обработчик отправки формы
async function handleSubmit(event) {
event.preventDefault(); // Предотвращаем отправку формы

const messageInput = document.getElementById('message-input');
const message = messageInput.value.trim();

if (message !== '') {
// Отправляем сообщение на Chat GPT
const answer = await sendMessageToChatGPT(message);

// Отображаем полученный ответ в чате
displayChatMessage(answer);

// Очищаем поле ввода
messageInput.value = '';
}
}

// Привязываем обработчик отправки формы к форме чата
const chatForm = document.getElementById('chat-form');
chatForm.addEventListener('submit', handleSubmit);
56 changes: 56 additions & 0 deletions public/js/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const chatLog = document.getElementById('chat-log');
const userInput = document.getElementById('user-input');
const sendButton = document.getElementById('send-button');
import axios from 'axios';

sendButton.addEventListener('click', sendMessage);

function sendMessage() {
const message = userInput.value.trim();

if (message !== '') {
appendMessage('user', message);
userInput.value = '';

getChatGPTResponse(message)
.then(reply => {
appendMessage('chatbot', reply);
})
.catch(error => {
console.error('Error:', error);
appendMessage('chatbot', 'An error occurred while processing the request.');
});
}
}

function appendMessage(sender, content) {
const messageElement = document.createElement('div');
messageElement.className = `message ${sender}`;
messageElement.textContent = content;

chatLog.appendChild(messageElement);
chatLog.scrollTop = chatLog.scrollHeight;
}


function getChatGPTResponse(message) {
const url = 'https://chatgpt.cyclic.app'; // Replace with your server URL
const apiKey = 'sk-76ADBqR4Eqsto6K8p8DNVGhlQi5BSQBGIxu8MKv2E6mla1KY'; // Replace with your API key

return new Promise((resolve, reject) => {
axios.get(url, {
params: {
message: message
},
headers: {
'Authorization': 'Bearer sk-76ADBqR4Eqsto6K8p8DNVGhlQi5BSQBGIxu8MKv2E6mla1KY'
}
})
.then(response => {
resolve(response.data.reply);
})
.catch(error => {
reject(error);
});
});
}
8 changes: 8 additions & 0 deletions public/js/getModels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import requests
url = "https://api.theb.ai/v1/models"
# url = "https://api.baizhi.ai/v1/models"
headers = {
'Authorization': 'Bearer sk-76ADBqR4Eqsto6K8p8DNVGhlQi5BSQBGIxu8MKv2E6mla1KY'
}
response = requests.request("GET", url, headers=headers)
print(response.json())
Loading