Init Python test
All checks were successful
Build and Push AI Image / build-and-push (push) Successful in 43s
All checks were successful
Build and Push AI Image / build-and-push (push) Successful in 43s
This commit is contained in:
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.env
|
||||||
1
.env.example
Normal file
1
.env.example
Normal file
@@ -0,0 +1 @@
|
|||||||
|
OPENAI_API_KEY=123456ABCDEF
|
||||||
32
.gitea/workflows/main.yml
Normal file
32
.gitea/workflows/main.yml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Build and Push AI Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Docker smoke test
|
||||||
|
run: docker ps -a
|
||||||
|
|
||||||
|
- name: Docker login
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_PASSWORD }}" \
|
||||||
|
| docker login git.petyi.eu \
|
||||||
|
-u "${{ secrets.REGISTRY_USER }}" \
|
||||||
|
--password-stdin
|
||||||
|
|
||||||
|
- name: Docker build
|
||||||
|
run: |
|
||||||
|
docker build -t git.petyi.eu/szakdolgozat/ai:latest .
|
||||||
|
|
||||||
|
- name: Docker push
|
||||||
|
run: |
|
||||||
|
docker push git.petyi.eu/szakdolgozat/ai:latest
|
||||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt /app/requirements.txt
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY ai.py /app/ai.py
|
||||||
|
|
||||||
|
CMD ["python", "ai.py"]
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
# AI
|
# AI
|
||||||
|
|
||||||
Az AI Engine, ami segít eldönteni, hogy hogyan változzon a K8S konfigurációja
|
Az AI Engine, ami segít eldönteni, hogy hogyan változzon a K8S konfigurációja
|
||||||
|
|
||||||
|
## .ENV
|
||||||
|
|
||||||
|
A helyes működéshez le kell másolni a `.env.example` filet `.env` névre és az api kulcsot a megfelelő helyre bemásolni.
|
||||||
34
ai.py
Normal file
34
ai.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from openai import OpenAI
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
api_key = os.getenv("OPENAI_API_KEY")
|
||||||
|
if not api_key:
|
||||||
|
print("ERROR: OPENAI_API_KEY environment variable is not set.", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Az új OpenAI kliens automatikusan az OPENAI_API_KEY env-ből dolgozik
|
||||||
|
client = OpenAI()
|
||||||
|
|
||||||
|
prompt = "Please respond with exactly the string: hello world"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = client.responses.create(
|
||||||
|
model="gpt-4.1-mini",
|
||||||
|
input=prompt,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Egyszerű, „naivan” kiszedjük a szöveget
|
||||||
|
msg = response.output[0].content[0].text
|
||||||
|
|
||||||
|
print("Model response:", msg)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"ERROR while calling OpenAI API: {e}", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
8
docker-compose.yaml
Normal file
8
docker-compose.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
ai-helper:
|
||||||
|
build: .
|
||||||
|
container_name: ai-helper
|
||||||
|
environment:
|
||||||
|
OPENAI_API_KEY: "${OPENAI_API_KEY}"
|
||||||
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
openai>=1.52.0
|
||||||
|
PyYAML>=6.0.2
|
||||||
|
requests>=2.32.3
|
||||||
Reference in New Issue
Block a user