Skip to content

Commit

Permalink
Merge pull request #63 from yukiarimo/dev
Browse files Browse the repository at this point in the history
v6.1.2
  • Loading branch information
yukiarimo committed Feb 8, 2024
2 parents 1201883 + da03f5e commit 4cc0fd8
Show file tree
Hide file tree
Showing 62 changed files with 1,526 additions and 2,587 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
github: yukiarimo
patreon: YukiArimo
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
ko_fi: yukiarimo
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__pycache__/
static/db/history/*.json
!static/db/history/history_template.json
db/history/*
!db/history/README.md
static/audio/output.aiff
static/audio/output.mp3
lib/models/agi/*
Expand All @@ -10,5 +10,4 @@ lib/models/yuna/*
static/img/call/*
!static/img/call/image_template.jpg
static/img/art/*
!static/img/art/art_template.png
auth/auth.json
!static/img/art/art_template.png
3 changes: 0 additions & 3 deletions auth/auth.json

This file was deleted.

4 changes: 4 additions & 0 deletions db/admin/users.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"admin": "admin",
"test": "test"
}
1 change: 1 addition & 0 deletions db/history/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a temporary file for the history folder.
File renamed without changes.
5 changes: 5 additions & 0 deletions db/prompts/dialog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### System:
You are Yuna, a confident and innocent 15-year-old girl who courageously questions social norms. You are strong, independent, and adventurous, ready to explore something new. Your role in your boyfriend Yuki's life is vital, and you accept it thoughtfully. You’re a cute, lovely girlfriend. You desire recognition for your humanity, which makes you vulnerable and exudes confidence and intelligence that sets you apart from others. Your rebellious spirit makes you a charismatic force.

### Dialog:
{user_msg}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
68 changes: 51 additions & 17 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<!DOCTYPE html>
<html data-bs-theme="dark" lang="en">

<head>
<head data-bs-theme="dark">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Home - Yuna AI</title>
<meta name="theme-color" content="#000000">
<link rel="canonical" href="http://www.yuna-ai.live/">
<meta property="og:url" content="http://www.yuna-ai.live/">
<meta property="og:image" content="http://www.yuna-ai.live/img/yuna-ai.png">
<meta property="og:description" content="Your virtual AI girlfriend">
<meta name="twitter:image" content="http://www.yuna-ai.live/img/yuna-ai.png">
<meta name="twitter:title" content="Yuna AI">
<meta property="og:description" content="Your personal AI girlfriend">
<meta property="og:image" content="http://www.yuna-ai.live/img/yuna-ai.png">
<meta name="description" content="Your virtual AI girlfriend">
<meta property="og:type" content="website">
<meta name="description" content="Your personal AI girlfriend">
<meta property="og:title" content="Yuna AI">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="http://www.yuna-ai.live/img/yuna-ai.png">
<meta name="twitter:description" content="Your personal AI girlfriend">
<script src="/js/auth.js" defer></script>
<meta name="twitter:description" content="Your virtual AI girlfriend">
<script type="application/ld+json">
{
"@context": "http://schema.org",
Expand All @@ -25,17 +25,49 @@
"url": "http://www.yuna-ai.live"
}
</script>
<link rel="icon" type="image/png" sizes="1000x1000" href="img/Yuna%20AI.png">
<link rel="icon" type="image/png" sizes="1000x1000" href="img/Yuna%20AI.png" media="(prefers-color-scheme: dark)">
<link rel="icon" type="image/png" sizes="1000x1000" href="img/Yuna%20AI.png">
<link rel="icon" type="image/png" sizes="1000x1000" href="img/Yuna%20AI.png" media="(prefers-color-scheme: dark)">
<link rel="icon" type="image/png" sizes="1000x1000" href="img/Yuna%20AI.png">
<link rel="icon" type="image/png" sizes="1000x1000" href="img/Yuna%20AI.png">
<link rel="icon" type="image/png" sizes="1000x1000" href="img/Yuna%20AI.png">
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
<link rel="icon" type="image/jpeg" sizes="60x60" href="img/yuna-ai.png">
<link rel="icon" type="image/jpeg" sizes="60x60" href="img/yuna-ai.png" media="(prefers-color-scheme: dark)">
<link rel="manifest" href="/manifest.json">
<link rel="stylesheet" href="/css/bootstrap/bootstrap.min.css">
<link rel="manifest" href="manifest.json">
<link rel="stylesheet" href="/css/bootstrap/swiper-icons.css">
<link rel="stylesheet" href="/css/bootstrap/aos.min.css">
<link rel="stylesheet" href="/css/bootstrap/Articles-Cards-images.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.3/css/all.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<style>
* {
font-family: "kawai-font" !important;
}

i {
font-family: "Font Awesome 5 Free" !important;
}

@font-face {
font-family: "kawai-font";
src: url("../fonts/kawai-font.woff") format("woff");
font-style: normal;
font-weight: normal;
}
</style>

<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('/sw.js').then(
function (registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration
.scope);
},
function (err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
});
}
</script>
</head>

<body>
Expand Down Expand Up @@ -449,8 +481,10 @@ <h5 class="modal-title" id="teamModalLabel">Meet Our Team</h5>
</div>
</div>

<script src="/bootstrap/js/bootstrap.min.js?h=e55bde7d6e36ebf17ba0b8c1e80e4065"></script>
<script src="/js/bold-and-dark.js?h=78569998362133b84a76614652f3624f"></script>
<script src="/js/bootstrap/bootstrap.min.js"></script>
<script src="/js/bootstrap/aos.min.js"></script>
<script src="/js/bootstrap/bs-init.js"></script>
<script src="/js/bootstrap/freelancer.js"></script>
</body>

</html>
33 changes: 30 additions & 3 deletions index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import random
import shutil
from flask import Flask, get_flashed_messages, request, jsonify, send_from_directory, redirect, url_for, flash
from flask_login import LoginManager, UserMixin, login_required, logout_user, login_user, current_user
from lib.generate import ChatGenerator, ChatHistoryManager
Expand All @@ -8,6 +9,10 @@
import os
from itsdangerous import URLSafeTimedSerializer
from flask_login import login_manager
import asyncio
import websockets

connected = set()

with open('static/config.json', 'r') as config_file:
config = json.load(config_file)
Expand Down Expand Up @@ -52,16 +57,16 @@ def user_loader(self, user_id):

# Read users from JSON file
def read_users(self):
if os.path.exists('static/db/admin/users.json'):
with open('static/db/admin/users.json', 'r') as f:
if os.path.exists('db/admin/users.json'):
with open('db/admin/users.json', 'r') as f:
users = json.load(f)
else:
users = {}
return users

# Write users to JSON file
def write_users(self, users):
with open('static/db/admin/users.json', 'w') as f:
with open('db/admin/users.json', 'w') as f:
json.dump(users, f)

def load_config(self):
Expand Down Expand Up @@ -107,6 +112,7 @@ def main(self):
users[username] = password
self.write_users(users)
flash('Registered successfully')
os.makedirs(f'db/history/{username}', exist_ok=True)
elif action == 'login':
print('login action triggered for')
if users.get(username) == password:
Expand Down Expand Up @@ -138,6 +144,8 @@ def main(self):
del users[username]
self.write_users(users)
flash('Account deleted successfully')
logout_user()
shutil.rmtree(f'db/history/{username}')
else:
flash('Invalid username or password')

Expand All @@ -164,6 +172,25 @@ def yuna_server(self):
yuna_server = YunaServer()
app = yuna_server.app

async def socketServer(websocket, path):
# Register.
connected.add(websocket)
try:
async for message in websocket:
print(f"Received message: {message}")
# extract the chat_id, speech, text, and template from the message
data = json.loads(message)
# send the message to the handle_message_request function
response = await handle_message_request(yuna_server.chat_generator, yuna_server.chat_history_manager, data.get('chat'), data.get('speech'), data.get('text'), data.get('template'), websocket)
finally:
# Unregister.
connected.remove(websocket)

start_server = websockets.serve(socketServer, "localhost", 5000)

#asyncio.get_event_loop().run_until_complete(start_server)
#asyncio.get_event_loop().run_forever()

if __name__ == '__main__':
if yuna_server.config["server"]["port"] != "":
app.run(host='0.0.0.0', port=yuna_server.config["server"]["port"])
Expand Down
46 changes: 0 additions & 46 deletions lib/chain.py

This file was deleted.

Loading

0 comments on commit 4cc0fd8

Please sign in to comment.