File size: 2,794 Bytes
8223b74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
"""

Endüstri Chatbot Kullanım Örneği



Bu dosya, Endüstri Chatbot'un nasıl kullanılacağını gösterir.

"""

import requests
import json
from typing import Dict, Any

class EndustriChatbotClient:
    def __init__(self, base_url: str = "http://localhost:8000"):
        self.base_url = base_url
    
    def chat(self, message: str) -> str:
        """Chatbot ile sohbet et"""
        response = requests.post(
            f"{self.base_url}/chat",
            json={"message": message}
        )
        return response.json()["response"]
    
    def upload_document(self, file_path: str, analyze: bool = True) -> Dict[str, Any]:
        """Doküman yükle ve analiz et"""
        with open(file_path, "rb") as f:
            response = requests.post(
                f"{self.base_url}/documents/upload",
                files={"file": f},
                data={"analyze": str(analyze).lower()}
            )
        return response.json()
    
    def generate_report(self, document_type: str, template_type: str, data: Dict[str, Any]) -> Dict[str, Any]:
        """Rapor oluştur"""
        response = requests.post(
            f"{self.base_url}/documents/generate",
            json={
                "document_type": document_type,
                "template_type": template_type,
                "data": data
            }
        )
        return response.json()
    
    def get_health(self) -> Dict[str, Any]:
        """Sistem durumunu kontrol et"""
        response = requests.get(f"{self.base_url}/health")
        return response.json()

def main():
    # Client oluştur
    client = EndustriChatbotClient()
    
    # Sistem durumunu kontrol et
    print("Sistem durumu:", client.get_health())
    
    # Basit sohbet örnekleri
    questions = [
        "5 saat kaynakçı işçiliği ne kadar tutar?",
        "10 metre bakır kablo maliyeti nedir?",
        "2500 TL'lik bir işe standart marj uygularsak fiyat ne olur?"
    ]
    
    for question in questions:
        print(f"\nSoru: {question}")
        answer = client.chat(question)
        print(f"Cevap: {answer}")
    
    # Rapor oluşturma örneği
    report_data = {
        "proje_adi": "Fabrika Kurulumu",
        "referans_no": "PRJ-2024-001",
        "iscilik_maliyeti": 15000,
        "malzeme_maliyeti": 25000,
        "toplam_maliyet": 40000,
        "kar_marji": 20,
        "toplam_teklif": 48000,
        "notlar": "Bu örnek bir maliyet hesaplamasıdır."
    }
    
    print("\nMaliyet raporu oluşturuluyor...")
    report_result = client.generate_report("word", "maliyet_raporu", report_data)
    print(f"Rapor oluşturuldu: {report_result}")

if __name__ == "__main__":
    main()