This commit resolves all outstanding issues with the AI Insights feature.
- Corrects the transcript formatting logic in to properly handle the database JSON structure, ensuring the AI receives the correct context.
- Fixes the Gemini API client by using the correct model name ('gemini-2.0-flash') and the proper client initialization.
- Updates to securely pass the API key as an environment variable to the container.
- Cleans up the codebase by removing temporary debugging endpoints.
- Adds script for programmatic updates.
- Updates documentation with troubleshooting insights from the implementation process.
59 lines
2.6 KiB
Python
59 lines
2.6 KiB
Python
import requests
|
|
import json
|
|
from getpass import getpass
|
|
|
|
def inspect_database_properties(db_id: str):
|
|
"""Liest die Eigenschaften (Spalten) einer Notion-Datenbank aus."""
|
|
print(f"--- Untersuche Eigenschaften von Notion DB: {db_id} ---")
|
|
token = getpass("Bitte gib deinen Notion API Key ein (Eingabe wird nicht angezeigt): ")
|
|
|
|
if not token:
|
|
print("\nFehler: Kein Token eingegeben. Abbruch.")
|
|
return
|
|
|
|
print(f"\n... Lese Struktur von Datenbank {db_id}...")
|
|
|
|
url = f"https://api.notion.com/v1/databases/{db_id}"
|
|
headers = {
|
|
"Authorization": f"Bearer {token}",
|
|
"Notion-Version": "2022-06-28"
|
|
}
|
|
|
|
try:
|
|
response = requests.get(url, headers=headers)
|
|
response.raise_for_status()
|
|
|
|
database_info = response.json()
|
|
properties = database_info.get("properties", {})
|
|
|
|
print("\n✅ Erfolgreich! Folgende Spalten (Properties) wurden gefunden:")
|
|
print("--------------------------------------------------")
|
|
for name, details in properties.items():
|
|
prop_type = details.get("type")
|
|
print(f"Spaltenname: '{name}' (Typ: {prop_type})")
|
|
if prop_type == "relation":
|
|
relation_details = details.get("relation", {})
|
|
print(f" -> Verknüpft mit Datenbank-ID: {relation_details.get('database_id')}")
|
|
# Gib die verfügbaren Optionen für Status- und Select-Felder aus
|
|
elif prop_type in ["status", "select", "multi_select"]:
|
|
options = details.get(prop_type, {}).get("options", [])
|
|
if options:
|
|
print(f" -> Verfügbare Optionen:")
|
|
for option in options:
|
|
print(f" - '{option.get('name')}'")
|
|
print("--------------------------------------------------")
|
|
print("Bitte finde den korrekten Namen der Spalte, die zu den Projekten verknüpft ist, und den exakten Namen für den 'In Bearbeitung'-Status.")
|
|
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"\n❌ FEHLER! Konnte die Datenbankstruktur nicht lesen: {e}")
|
|
if hasattr(e, 'response') and e.response is not None:
|
|
print(f"HTTP Status Code: {e.response.status_code}")
|
|
try:
|
|
print(f"Antwort des Servers: {json.dumps(e.response.json(), indent=2)}")
|
|
except:
|
|
print(f"Antwort des Servers: {e.response.text}")
|
|
|
|
if __name__ == "__main__":
|
|
tasks_db_id = "2e888f42-8544-8153-beac-e604719029cf" # Die ID für "Tasks [UT]"
|
|
inspect_database_properties(tasks_db_id)
|