|
|
|
|
|
"""
|
|
|
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 = EndustriChatbotClient()
|
|
|
|
|
|
|
|
|
print("Sistem durumu:", client.get_health())
|
|
|
|
|
|
|
|
|
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}")
|
|
|
|
|
|
|
|
|
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()
|
|
|
|