CPT hinzugefügt
This commit is contained in:
parent
5d9a00772d
commit
36b15d74e4
2 changed files with 49 additions and 9 deletions
|
|
@ -5,6 +5,7 @@ from datetime import datetime, timezone
|
|||
from openai import OpenAI
|
||||
import os
|
||||
import sys
|
||||
import random
|
||||
|
||||
|
||||
USERNAME = "hubobel"
|
||||
|
|
@ -29,7 +30,8 @@ def conf():
|
|||
passw = {'Prompt':
|
||||
{
|
||||
"PurserPrompt": "",
|
||||
"CptPrompt": ""
|
||||
"CptPrompt": "",
|
||||
"CptName":""
|
||||
|
||||
},
|
||||
'AI':
|
||||
|
|
@ -90,9 +92,22 @@ def replacedynamic(message):
|
|||
return (message)
|
||||
def unix_to_datetime(timestamp: int) -> str:
|
||||
return datetime.fromtimestamp(timestamp, tz=timezone.utc).strftime("%d.%m.%Y %H:%M:%S")
|
||||
def ai(prompt):
|
||||
completion = client.chat.completions.create(
|
||||
model="gpt-4.1-mini",
|
||||
messages=[
|
||||
{"role": "user", "content": prompt}
|
||||
]
|
||||
)
|
||||
return completion
|
||||
def stimmung():
|
||||
tone = (passw['Prompt']['tone'])
|
||||
tone = random.choice(list(tone))
|
||||
return tone
|
||||
|
||||
|
||||
|
||||
passw = conf()
|
||||
client = OpenAI(
|
||||
api_key=passw['AI']['Token'])
|
||||
resp = requests.get(URL, params=params, timeout=15)
|
||||
resp.raise_for_status()
|
||||
data = resp.json() # dict
|
||||
|
|
@ -157,5 +172,27 @@ for datei in Path(Pfad).glob("*.txt"):
|
|||
with open(dateineu,'w', encoding="utf-8") as e:
|
||||
e.write(inhalt_neu)
|
||||
|
||||
passw = conf()
|
||||
print(passw['AI']['Token'])
|
||||
prompt_org = passw['Prompt']['PurserPrompt']
|
||||
prompt2 = prompt_org + 'Die METAR lautet ' + metar_dest
|
||||
antwort_AI = ai(prompt2)
|
||||
print(antwort_AI.choices[0].message.content)
|
||||
|
||||
prompt_org = passw['Prompt']['CptPrompt']
|
||||
|
||||
info = {"Der Zielflughafen ist: " + dest.get("icao_code"), "Die Reisedauer beträgt ungefähr: " + block,
|
||||
"Die Entfernung: " + distance + "nm",
|
||||
"Der getankte Sprit: " + fuel + "kg",
|
||||
"An Bord befinden sich " + pax + "Passagiere",
|
||||
"Das Flugzeug ist eine " + aircraft_name,
|
||||
"Du freust dich auf den Flug und bedankst dich, das man sich für " + airline + " entschieden hat.",
|
||||
"Dein Name lautet " + passw['Prompt']['CptName'],
|
||||
"Startflughafen: " + origin.get("icao_code"),
|
||||
"sei dabei " + str(stimmung()),
|
||||
"Wetter am Ziel" + metar_dest,
|
||||
"Wetter am Start" + metar_origin}
|
||||
|
||||
for i in info:
|
||||
prompt_org = prompt_org + i
|
||||
antwort_AI = ai(prompt_org)
|
||||
print(antwort_AI.choices[0].message.content)
|
||||
print(str(stimmung()))
|
||||
Loading…
Add table
Add a link
Reference in a new issue