push clean

This commit is contained in:
greg 2023-09-29 09:02:53 +02:00
parent 766c0d1ac2
commit 944ce3eae8
13 changed files with 62 additions and 43 deletions

9
.dockerignore Normal file
View File

@ -0,0 +1,9 @@
docker-compose.yml
models/
images/
app/bin
app/lib
app/lib64
app/__pycache__
app/pyvenv.cfg
app/include

19
.env Normal file
View File

@ -0,0 +1,19 @@
#########################LOCALAI#########################
# local-ai quand flask dockerisé
LOCALAI_HOST=local-ai
MODELS_PATH=/models
DEBUG=true
REBUILD=false
#THREADS=4
DEFAULT_MODEL=gpt-3.5-turbo
PRELOAD_MODELS=[{"url":"github:go-skynet/model-gallery/gpt4all-j.yaml","name":"gpt-3.5-turbo"},{"url":"github:go-skynet/model-gallery/stablediffusion.yaml","name":"stablediffusion"}]
#DEFAULT_MODEL=wizard-lm
#PRELOAD_MODELS=[{"url":"github:go-skynet/model-gallery/openllama_7b.yaml","name":"open_llama"}]
#GALLERIES=[{"name":"model-gallery","url":"github:go-skynet/model-gallery/index.yaml"}]

29
.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
models/ggml-gpt4all-j.bin
models/gpt4all-chat.tmpl
models/open-llama-7b-q4_0.bin
models/whisper.yaml
models/ggml-whisper-base.bin
models/gpt4all-completion.tmpl
models/openllama-chat.tmpl
models/gpt-3.5-turbo.yaml
models/gpt4all-j.yaml
models/openllama-completion.tmpl
models/wizardlm-13b-v1.1-superhot-8k.ggmlv3.q4_0.bin
models/wizard-lm.yaml
models/wizard-lm-chat.tmpl
models/wizard-lm-completion.tmpl
models/wizard_lm.yaml
models/open_llama.yaml
models/openllama.yaml
models/open_llama
models/*
app/bin
app/include
app/lib
app/lib64
app/__pycache__
app/pyvenv.cfg
app/client_secrets_prod.json
images/*

View File

@ -5,4 +5,4 @@ WORKDIR /
COPY . . COPY . .
RUN pip3 install -r requirements.txt RUN pip3 install -r requirements.txt
WORKDIR /app WORKDIR /app
CMD ["gunicorn", "-w", "4", "wsgi:app", "--bind", "0.0.0.0:8000"] CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]

View File

@ -10,32 +10,8 @@ model = "ggml-gpt4all-j.bin"
load_dotenv() load_dotenv()
host = os.getenv("LOCALAI_HOST") host = os.getenv("LOCALAI_HOST")
############################### KEYCLOAK ###############################
# app.config.update({
# # PROD ONLY
# 'SECRET_KEY': 'créer-un-secret-ici',
# 'OIDC_CLIENT_SECRETS': 'client_secrets_prod.json',
# 'OIDC_ID_TOKEN_COOKIE_SECURE': False,
# 'OIDC_REQUIRE_VERIFIED_EMAIL': False,
# 'OIDC_USER_INFO_ENABLED': True,
# 'OIDC_OPENID_REALM': 'gregan',
# 'OIDC_SCOPES': ['openid', 'email', 'profile'],
# 'OIDC_INTROSPECTION_AUTH_METHOD': 'client_secret_post'
# })
# app.config['OVERWRITE_REDIRECT_URI'] = 'https://chat-gpt.domain.tld/oidc_callback'
# oidc = OpenIDConnect(app)
# @app.context_processor
# def inject_oidc_user():
# if oidc.user_loggedin:
# return dict(oidc_user=oidc.user_getfield('email'))
# return dict(oidc_user=None)
# CHAT BOT: GPT-TURBO-3.5 # CHAT BOT: GPT-TURBO-3.5
@app.route("/", methods=("GET", "POST")) @app.route("/", methods=("GET", "POST"))
# @oidc.require_login
def index(): def index():
result = '' result = ''
@ -60,8 +36,6 @@ def index():
response = requests.post(url, json=payload) response = requests.post(url, json=payload)
if response.status_code == 200: if response.status_code == 200:
result = '<md>' + response.json()['choices'][0]['message']['content'] + '</md>' result = '<md>' + response.json()['choices'][0]['message']['content'] + '</md>'
# print(result)
# format_code(result)
else: else:
result = "Erreur de connection avec l'API" result = "Erreur de connection avec l'API"
@ -75,7 +49,6 @@ def index():
# IMAGE GENERATOR: STABLEDIFFUSION # IMAGE GENERATOR: STABLEDIFFUSION
@app.route("/image", methods=("GET", "POST")) @app.route("/image", methods=("GET", "POST"))
# @oidc.require_login
def image(): def image():
result = '' result = ''
@ -100,9 +73,6 @@ def image():
response = requests.post(url, headers=headers, json=data) response = requests.post(url, headers=headers, json=data)
if response.status_code == 200: if response.status_code == 200:
########## PROD ONLY ##########
# image_url = response.json()['data'][0]['url'].replace("local-ai", "image.domain.tld").replace("http", "https").replace(":8080", "")
image_url = response.json()['data'][0]['url'].replace("local-ai", "localhost") image_url = response.json()['data'][0]['url'].replace("local-ai", "localhost")
else: else:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

BIN
app/static/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 611 KiB

View File

@ -9,7 +9,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}" /> <link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}" />
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<title>Gregan AI</title> <title>Garage AI</title>
</head> </head>
@ -20,11 +20,10 @@
<p>Loading ...</p> <p>Loading ...</p>
</div> </div>
<h3>Gregan AI</h3> <h3>Garage AI</h3>
<div class="container"> <div class="container">
<nav class="navbar navbar-expand-lg navbar-light bg-light jumbotron"> <nav class="navbar navbar-expand-lg navbar-light bg-light jumbotron">
<!-- <a class="navbar-brand" href="#">Navbar</a> -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
@ -53,7 +52,7 @@
<div class="footer"> <div class="footer">
<div class="temps">{{ time }}</div> <div class="temps">{{ time }}</div>
<div> <div>
<img src="{{ url_for('static', filename='logo-4.png') }}" style="max-width: 50%;"> <img src="{{ url_for('static', filename='logo.png') }}" style="max-width: 50%;">
</div> </div>
</div> </div>

View File

@ -4,12 +4,6 @@
<form action="/" method="post" id="form"> <form action="/" method="post" id="form">
<div class="settings"> <div class="settings">
<!-- <label for="model">Sélectionnez un model :</label><br>
<select id="model" name="model">
{% for e in menu %}
<option value={{ e }}>{{ e }}</option>
{% endfor %}
</select> -->
<br> <br>
<label for="valeur">Sélectionnez la température :</label> <label for="valeur">Sélectionnez la température :</label>
<input type="range" id="valeur" name="temperature" min="0" max="1" step=".1"> <input type="range" id="valeur" name="temperature" min="0" max="1" step=".1">

View File

@ -27,7 +27,7 @@ services:
container_name: flask-ui container_name: flask-ui
restart: always restart: always
ports: ports:
- 8000:8000 - 5000:5000
depends_on: depends_on:
local-ai: local-ai:
condition: service_healthy condition: service_healthy

View File

@ -7,5 +7,4 @@ urllib3==1.26.7
Werkzeug==2.0.2 Werkzeug==2.0.2
gunicorn==21.2.0 gunicorn==21.2.0
itsdangerous==2.0.1 itsdangerous==2.0.1
flask_oidc==1.4.0
python-dotenv python-dotenv