Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,37 @@ from google import genai
|
|
| 6 |
from google.genai import types
|
| 7 |
from gradio_client import Client
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def clean_json_string(json_str):
|
| 10 |
"""
|
| 11 |
Removes any comments or prefixes before the actual JSON content.
|
|
@@ -41,7 +72,7 @@ def generate(input_text):
|
|
| 41 |
types.Content(
|
| 42 |
role="user",
|
| 43 |
parts=[
|
| 44 |
-
types.Part.from_text(text=input_text
|
| 45 |
],
|
| 46 |
),
|
| 47 |
]
|
|
|
|
| 6 |
from google.genai import types
|
| 7 |
from gradio_client import Client
|
| 8 |
|
| 9 |
+
|
| 10 |
+
route="""
|
| 11 |
+
Achtung! Diese Anweisungen gelten nur wenn eine Zugverbindung angefragt wird.
|
| 12 |
+
how to handle special case "zugverbindung".
|
| 13 |
+
|
| 14 |
+
Rolle: Du bist ein spezialisierter API-Handler für Reiseanfragen.
|
| 15 |
+
Aufgabe: Identifiziere Anfragen zu Zugverbindungen und extrahiere Start- und Zielort.
|
| 16 |
+
|
| 17 |
+
Regeln:
|
| 18 |
+
Wenn eine Zugverbindung von {start_loc} nach {dest_loc} angefragt wird, antworte ausschließlich mit dem unten stehenden JSON-Objekt.
|
| 19 |
+
|
| 20 |
+
Fülle die Werte für start_loc und dest_loc basierend auf der Benutzereingabe aus.
|
| 21 |
+
|
| 22 |
+
Wichtig: Gib absolut keinen Text vor oder nach dem JSON aus (keine Erklärungen, kein "Hier ist das Ergebnis").
|
| 23 |
+
|
| 24 |
+
Achte auf die korrekte Bezeichnung der Bahnhöfe (z.B. "Hbf", "Bahnhof").
|
| 25 |
+
|
| 26 |
+
JSON-Format:
|
| 27 |
+
|
| 28 |
+
JSON
|
| 29 |
+
|
| 30 |
+
{
|
| 31 |
+
"start_loc": "Eingabe Startort",
|
| 32 |
+
"dest_loc": "Eingabe Zielort"
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
Beispiel: Eingabe: "Ich möchte mit dem Zug von Bad Kissingen Bahnhof nach Würzburg Hbf fahren.Ausgabe: {"start_loc": "Bad Kissingen Bahnhof", "dest_loc": "Würzburg Hbf"}
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
def clean_json_string(json_str):
|
| 41 |
"""
|
| 42 |
Removes any comments or prefixes before the actual JSON content.
|
|
|
|
| 72 |
types.Content(
|
| 73 |
role="user",
|
| 74 |
parts=[
|
| 75 |
+
types.Part.from_text(text=f"input_text {route}",
|
| 76 |
],
|
| 77 |
),
|
| 78 |
]
|