Spaces:
Runtime error
Runtime error
Upload 10 files
Browse files- app.py +47 -11
- requirements.txt +3 -1
app.py
CHANGED
|
@@ -1,4 +1,12 @@
|
|
| 1 |
-
from smolagents import CodeAgent,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -50,6 +58,10 @@ def create_birth_chart(name: str, year: int, month: int, day: int, hour: int, mi
|
|
| 50 |
str: Success message with file paths
|
| 51 |
"""
|
| 52 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# Create birth chart
|
| 54 |
person = AstrologicalSubject(
|
| 55 |
name=name,
|
|
@@ -64,16 +76,20 @@ def create_birth_chart(name: str, year: int, month: int, day: int, hour: int, mi
|
|
| 64 |
|
| 65 |
# Create SVG file
|
| 66 |
chart = KerykeionChartSVG(person)
|
| 67 |
-
|
|
|
|
| 68 |
chart.makeSVG(svg_path)
|
| 69 |
|
| 70 |
# Create astrological report
|
| 71 |
report = Report(person)
|
| 72 |
report_text = report.get_full_report()
|
| 73 |
|
|
|
|
| 74 |
return f"SUCCESS|{svg_path}|{report_text}"
|
| 75 |
|
| 76 |
except Exception as e:
|
|
|
|
|
|
|
| 77 |
return f"ERROR|{str(e)}"
|
| 78 |
|
| 79 |
@tool
|
|
@@ -105,18 +121,38 @@ def interpret_astrological_report(raw_report: str, person_name: str) -> str:
|
|
| 105 |
"""
|
| 106 |
|
| 107 |
try:
|
| 108 |
-
#
|
| 109 |
-
return f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
except Exception as e:
|
| 111 |
-
return f"Rapor
|
| 112 |
|
| 113 |
final_answer = FinalAnswerTool()
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
# Import tool from Hub
|
| 122 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, load_tool, tool
|
| 2 |
+
try:
|
| 3 |
+
from smolagents import HfApiModel
|
| 4 |
+
except ImportError:
|
| 5 |
+
try:
|
| 6 |
+
from smolagents.models import HfApiModel
|
| 7 |
+
except ImportError:
|
| 8 |
+
from smolagents import TransformersModel as HfApiModel
|
| 9 |
+
print("Using TransformersModel as fallback for HfApiModel")
|
| 10 |
import datetime
|
| 11 |
import requests
|
| 12 |
import pytz
|
|
|
|
| 58 |
str: Success message with file paths
|
| 59 |
"""
|
| 60 |
try:
|
| 61 |
+
print(f"🔮 {name} için doğum haritası oluşturuluyor...")
|
| 62 |
+
print(f"📅 Doğum: {day}/{month}/{year} {hour}:{minute:02d}")
|
| 63 |
+
print(f"🌍 Konum: {city}, {nation}")
|
| 64 |
+
|
| 65 |
# Create birth chart
|
| 66 |
person = AstrologicalSubject(
|
| 67 |
name=name,
|
|
|
|
| 76 |
|
| 77 |
# Create SVG file
|
| 78 |
chart = KerykeionChartSVG(person)
|
| 79 |
+
safe_name = name.lower().replace(' ', '_').replace('ı', 'i').replace('ğ', 'g').replace('ü', 'u').replace('ş', 's').replace('ö', 'o').replace('ç', 'c')
|
| 80 |
+
svg_path = f"charts/{safe_name}_birth_chart.svg"
|
| 81 |
chart.makeSVG(svg_path)
|
| 82 |
|
| 83 |
# Create astrological report
|
| 84 |
report = Report(person)
|
| 85 |
report_text = report.get_full_report()
|
| 86 |
|
| 87 |
+
print(f"✅ Doğum haritası başarıyla oluşturuldu: {svg_path}")
|
| 88 |
return f"SUCCESS|{svg_path}|{report_text}"
|
| 89 |
|
| 90 |
except Exception as e:
|
| 91 |
+
error_msg = f"❌ Doğum haritası oluşturulurken hata: {str(e)}"
|
| 92 |
+
print(error_msg)
|
| 93 |
return f"ERROR|{str(e)}"
|
| 94 |
|
| 95 |
@tool
|
|
|
|
| 121 |
"""
|
| 122 |
|
| 123 |
try:
|
| 124 |
+
# Ham raporu Türkçe format ile yorumlayalım
|
| 125 |
+
return f"""
|
| 126 |
+
🌟 **Kişilik Analizi**
|
| 127 |
+
{person_name} için detaylı astrolojik analiz:
|
| 128 |
+
|
| 129 |
+
📋 **Ham Astrolojik Veri:**
|
| 130 |
+
{raw_report}
|
| 131 |
+
|
| 132 |
+
💭 **Bu rapor, {person_name}'in doğum haritasından çıkarılan temel astrolojik verilerdir.
|
| 133 |
+
Detaylı yorumlar için astroloji uzmanına başvurunuz.**
|
| 134 |
+
""".strip()
|
| 135 |
except Exception as e:
|
| 136 |
+
return f"Rapor işlenirken hata oluştu: {str(e)}"
|
| 137 |
|
| 138 |
final_answer = FinalAnswerTool()
|
| 139 |
+
# Model konfigürasyonu - HfApiModel'in alternatifi olarak TransformersModel kullanıyoruz
|
| 140 |
+
try:
|
| 141 |
+
from smolagents import HfApiModel
|
| 142 |
+
model = HfApiModel(
|
| 143 |
+
max_tokens=2096,
|
| 144 |
+
temperature=0.5,
|
| 145 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 146 |
+
)
|
| 147 |
+
except ImportError:
|
| 148 |
+
# Fallback: TransformersModel kullan
|
| 149 |
+
from smolagents import TransformersModel
|
| 150 |
+
model = TransformersModel(
|
| 151 |
+
model_id="HuggingFaceTB/SmolLM-1.7B-Instruct", # Küçük model local için
|
| 152 |
+
max_new_tokens=2096,
|
| 153 |
+
temperature=0.5,
|
| 154 |
+
)
|
| 155 |
+
print("HfApiModel bulunamadı, TransformersModel kullanılıyor.")
|
| 156 |
|
| 157 |
# Import tool from Hub
|
| 158 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
requirements.txt
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
markdownify
|
| 2 |
-
smolagents
|
|
|
|
|
|
|
| 3 |
requests
|
| 4 |
duckduckgo_search
|
| 5 |
pandas
|
|
|
|
| 1 |
markdownify
|
| 2 |
+
smolagents>=1.5.0
|
| 3 |
+
transformers
|
| 4 |
+
torch
|
| 5 |
requests
|
| 6 |
duckduckgo_search
|
| 7 |
pandas
|