-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: excalidraw-stack Image Nightly | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
env: | ||
IMAGE_BASE_TAG: git.b0t.at/b0t-at/excalidraw-ai | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.branch }} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ vars.registry_uri }} | ||
username: ${{ secrets.registry_username }} | ||
password: ${{ secrets.registry_password }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ env.IMAGE_BASE_TAG }}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Verwenden Sie ein offizielles Python-Laufzeitbild als Elternbild | ||
FROM python:3.8-slim-buster | ||
|
||
# Setzen Sie die Arbeitsumgebung im Container auf /app | ||
WORKDIR /app | ||
|
||
# Kopieren Sie die aktuellen Verzeichnisinhalte in das Arbeitsverzeichnis /app im Container | ||
ADD . /app | ||
|
||
# Installieren Sie alle benötigten Pakete | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Machen Sie den Port 5000 des Containers verfügbar für die Welt außerhalb dieses Containers | ||
EXPOSE 5000 | ||
|
||
# Führen Sie app.py aus, wenn der Container gestartet wird | ||
CMD ["python", "app.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from flask import Flask, request, jsonify | ||
from flask_cors import CORS | ||
import os | ||
import openai | ||
|
||
app = Flask(__name__) | ||
CORS(app, resources={r"/*": {"origins": os.getenv('ALLOWED_HOST')}}) | ||
|
||
@app.route('/v1/ai/text-to-diagram/generate', methods=['POST']) | ||
def generate_diagram(): | ||
data = request.get_json() | ||
prompt = data.get('prompt', '') | ||
|
||
# Call the OpenAI API | ||
response = openai.ChatCompletion.create( | ||
model="gpt-4-1106-preview", | ||
messages=[ | ||
{"role": "system", "content": "Translate the following user prompt into a diagram."}, | ||
{"role": "user", "content": prompt}, | ||
], | ||
) | ||
|
||
messages = response['choices'][0]['message'] | ||
return jsonify({"generatedResponse": ''.join(message['content'] for message in messages)}) | ||
|
||
if __name__ == '__main__': | ||
app.run(host='0.0.0.0', port=5000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
docker build -t my-python-app . | ||
docker run -p 5000:5000 -e ALLOWED_HOST='http://mein-zugelassener-host.com' my-python-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
flask | ||
flask_cors | ||
openai |