msl 1 year ago
parent 48fca54eb8
commit 1be23e43c9

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WeChat-like Chat Interface</title> <title>Artemis GPT</title>
<!-- Bootstrap CSS --> <!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head> </head>
@ -39,11 +39,11 @@
var message = $$("#messageInput").val().trim(); var message = $$("#messageInput").val().trim();
if (message) { if (message) {
$$(".chat-content").append(`<div class="text-right mb-2"><span class="badge badge-primary">$${message}</span></div>`);
$$("#messageInput").val(''); $$("#messageInput").val('');
$$("#hidep").append("{'role': 'user', 'content':'"+message+"'},") $$("#hidep").append("{'role': 'user', 'content':'"+message+"'},")
allMessages=$$("#hidep").text() allMessages=$$("#hidep").text()
$$(".chat-content").append(`<div class="text-right mb-2"><span class="badge badge-primary" ><p style="white-space: pre-wrap; width:220px; word-wrap: break-word; word-break:break-all;">$${message}<p></span></div>`);
$$("#sendButton").prop("disabled", true); $$("#sendButton").prop("disabled", true);
// Show loading spinner // Show loading spinner
@ -52,7 +52,7 @@
if(response) { if(response) {
$$("#hidep").append("{'role': 'assistant', 'content':'"+response+"'},"); $$("#hidep").append("{'role': 'assistant', 'content':'"+response+"'},");
response=response.replace("\n","<br>") response=response.replace("\n","<br>")
$$(".chat-content").append(`<div class="text-left mb-2"><span class="badge badge-secondary">$${response}</span></div>`); $$(".chat-content").append(`<div class="text-left mb-2"><span class="badge badge-secondary"><p style="white-space: pre-wrap; width:220px; word-wrap: break-word; word-break:break-all;">$${response}</p></span></div>`);
$$("#sendButton").prop("disabled", false); $$("#sendButton").prop("disabled", false);
$$('#loadingSpinner').remove(); $$('#loadingSpinner').remove();

@ -3,7 +3,7 @@ import openai
def chatgpt(mess): def chatgpt(mess):
openai.api_key ="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" openai.api_key ="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"
response = openai.ChatCompletion.create( response = openai.ChatCompletion.create(
model="gpt-3.5-turbo", model="gpt-4",
messages=mess messages=mess
) )
re=response['choices'][0]['message']['content'] re=response['choices'][0]['message']['content']

Loading…
Cancel
Save