web_chat.py
- Pfad:
/var/www/scripts/pipeline/web_chat.py - Namespace: pipeline
- Zeilen: 44 | Größe: 952 Bytes
- Geändert: 2025-12-23 22:57:42 | Gescannt: 2025-12-31 10:22:15
Code Hygiene Score: 100
- Dependencies: 100 (25%)
- LOC: 100 (20%)
- Methods: 100 (20%)
- Secrets: 100 (15%)
- Classes: 100 (10%)
- Magic Numbers: 100 (10%)
Keine Issues gefunden.
Dependencies 4
- use json
- use os
- use sys
- use chat.chat
Funktionen 1
-
main()Zeile 19
Code
#!/usr/bin/env python3
"""
Web Chat Interface for KI-System
Called from PHP with question file as argument.
"""
import json
import os
import sys
# Change to pipeline directory and add to path
PIPELINE_PATH = "/var/www/scripts/pipeline"
os.chdir(PIPELINE_PATH)
sys.path.insert(0, PIPELINE_PATH)
from chat import chat
def main():
"""Process chat question from file and return JSON response."""
if len(sys.argv) < 2:
print(json.dumps({"error": "No question file provided"}))
return
question_file = sys.argv[1]
try:
with open(question_file, encoding="utf-8") as f:
question = f.read().strip()
if not question:
print(json.dumps({"error": "Empty question"}))
return
result = chat(question)
print(json.dumps(result, ensure_ascii=False))
except Exception as e:
print(json.dumps({"error": str(e)}))
if __name__ == "__main__":
main()