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.2 KiB
Python
59 lines
2.2 KiB
Python
import requests
|
|
from getpass import getpass
|
|
|
|
# Interaktive und sichere Abfrage des Tokens
|
|
print("--- Notion API Token Gültigkeits-Check ---")
|
|
notion_token = getpass("Bitte gib deinen Notion API Key ein (Eingabe wird nicht angezeigt): ")
|
|
|
|
if not notion_token:
|
|
print("\nFehler: Kein Token eingegeben.")
|
|
exit()
|
|
|
|
# Der einfachste API-Endpunkt, um die Authentifizierung zu testen
|
|
url = "https://api.notion.com/v1/users/me"
|
|
|
|
headers = {
|
|
"Authorization": f"Bearer {notion_token}",
|
|
"Notion-Version": "2022-06-28"
|
|
}
|
|
|
|
print("\n... Sende Test-Anfrage an Notion...")
|
|
|
|
try:
|
|
# --- TEST 1: Grundlegende Authentifizierung ---
|
|
print("\n[TEST 1/2] Prüfe grundlegende Authentifizierung (/users/me)...")
|
|
user_response = requests.get("https://api.notion.com/v1/users/me", headers=headers)
|
|
user_response.raise_for_status()
|
|
print("✅ ERFOLG! Der API Token ist gültig.")
|
|
|
|
# --- TEST 2: Suche nach der 'Projects' Datenbank ---
|
|
print("\n[TEST 2/2] Versuche, die 'Projects'-Datenbank über die Suche zu finden (/search)...")
|
|
search_url = "https://api.notion.com/v1/search"
|
|
search_payload = {
|
|
"query": "Projects",
|
|
"filter": {"value": "database", "property": "object"}
|
|
}
|
|
search_response = requests.post(search_url, headers=headers, json=search_payload)
|
|
search_response.raise_for_status()
|
|
|
|
results = search_response.json().get("results", [])
|
|
if not results:
|
|
print("🟡 WARNUNG: Die Suche war erfolgreich, hat aber keine Datenbank namens 'Projects' gefunden.")
|
|
else:
|
|
print("✅✅✅ ERFOLG! Die Suche funktioniert und hat die 'Projects'-Datenbank gefunden.")
|
|
print("Gefundene Datenbanken:")
|
|
for db in results:
|
|
print(f"- ID: {db['id']}, Titel: {db.get('title', [{}])[0].get('plain_text', 'N/A')}")
|
|
|
|
except requests.exceptions.HTTPError as e:
|
|
print(f"\n❌ FEHLER! Einer der Tests ist fehlgeschlagen.")
|
|
print(f"URL: {e.request.url}")
|
|
print(f"HTTP Status Code: {e.response.status_code}")
|
|
print("Antwort von Notion:")
|
|
try:
|
|
print(e.response.json())
|
|
except:
|
|
print(e.response.text)
|
|
except requests.exceptions.RequestException as e:
|
|
print(f"\n❌ FEHLER! Ein Netzwerk- oder Verbindungsfehler ist aufgetreten: {e}")
|