Global Chat
Global Chat
Abschnitt betitelt „Global Chat“Diese Anleitung zeigt, wie Sie eine Chat-Sitzung mit der gemeinsamen globalen Wissensbasis erstellen — ohne Datei-Uploads.
Voraussetzungen
Abschnitt betitelt „Voraussetzungen“- Zugangsdaten fuer eine gehostete SmartChat RAG API mit der Rolle
CHAT_USER - Ein vorkonfigurierter SmartChat RAG API-Server
1. Authentifizieren
Abschnitt betitelt „1. Authentifizieren“import requestsimport json
base_url = "<BASE_URL>"
payload = json.dumps({"username": "<USERNAME>", "password": "<PASSWORD>"})headers = {"Content-Type": "application/json"}
response = requests.post(f"{base_url}/api/v1/auth/user", headers=headers, data=payload)headers["Authorization"] = f"Bearer {response.json()['access_token']}"2. Standard-Chat-Konfiguration abrufen
Abschnitt betitelt „2. Standard-Chat-Konfiguration abrufen“response = requests.get(f"{base_url}/config-manager/api/v1/user/configs", headers=headers)
configs = response.json()default_config = [c for c in configs if c["userGroupId"] == "default"][0]
default_local_config_id = default_config["localKbConfigs"][0]["id"]allowed_llms = default_config["localKbConfigs"][0]["allowed_llms"]3. Globale Chat-Sitzung erstellen
Abschnitt betitelt „3. Globale Chat-Sitzung erstellen“body = { "title": "Testing the SmartChat RAG API", "config": { "localConfigId": default_local_config_id, "globalContext": True, "chatModel": allowed_llms[0]["name"], },}response = requests.post(f"{base_url}/chat-session-manager/api/v1/sessions/", headers=headers, json=body)session_id = response.json()["sessionId"]4. Chatten
Abschnitt betitelt „4. Chatten“body = { "sessionId": session_id, "userPrompt": "Can you summarize the context to me?",}response = requests.post(f"{base_url}/query-pipelines/api/v1/chat", headers=headers, json=body)print(response.json())