cha0smagick commited on
Commit
20b5230
β€’
1 Parent(s): c16780f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +69 -73
app.py CHANGED
@@ -1,98 +1,94 @@
1
  import streamlit as st
2
- from kerykeion import AstrologicalSubject, KerykeionChartSVG
3
  from kerykeion.report import Report
4
  import sys
5
  import os
 
 
 
6
 
7
- def get_user_input():
8
- name = st.text_input("Person's name:")
9
- year = st.number_input("Year of birth:", min_value=1900, max_value=2099)
10
- month = st.number_input("Month of birth (1-12):", min_value=1, max_value=12)
11
- day = st.number_input("Day of birth (1-31):", min_value=1, max_value=31)
12
- hour = st.number_input("Hour of birth (0-23):", min_value=0, max_value=23)
13
- minute = st.number_input("Minute of birth (0-59):", min_value=0, max_value=59)
14
- location = st.text_input("Place of birth:")
15
- zodiac_type = st.selectbox("Zodiac type", ["Tropic", "Sidereal"]).capitalize()
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  return name, year, month, day, hour, minute, location, zodiac_type
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  def main():
20
- st.title("Astrological Chart Generator")
21
- st.markdown(
22
- """
23
-
24
- **Author:** cha0smagick the Techno Wizard
25
- **Created for the blog:** [El Rincon Paranormal](https://elrinconparanormal.blogspot.com)
26
- **Project's main page:** [Technowizard Cha0smagick's Astrological charts](hhttps://elrinconparanormal.blogspot.com/2023/12/Free%20Astrological%20Chart%20Generator%20Tool%20Online.html)
27
-
28
- **Donate crypto to support the project:**
29
-
30
- - Bitcoin: 3KcF1yrY44smTJpVW68m8dw8q64kPtzvtX
31
- - Litecoin: LME9oq8BRQ6dDdqEKg3HJB9UL6byhJka1X
32
- - Gridcoin: RyAcDpYRMWfDHLTizCTLzy58qBgzcfo5eZ
33
- - Dodgecoin: DDSxowLFPyBHVdV16hGhWdhyfa8ors3VPd
34
- - Blackcoin: B62pVSG1hjvBDbCeKbEnYmKxUg5rsnZKwt
35
- - Dash: Xj1MjAgxZPRqysMHox4sUV9XYZixrsk4e6
36
- - Peercoin: PA43iLNooKU76u4yPTtL5j97W6zwWkwxV2
37
- - Syscoin: sys1qg6npncq4xe7ruz4e4xlnvuyrzj90qvv3gg0yag
38
-
39
- """
40
- )
41
-
42
  st.write("Enter information for the first person:")
43
  name1, year1, month1, day1, hour1, minute1, location1, zodiac_type1 = get_user_input()
 
44
 
45
- chart_type = st.selectbox("Chart type", ["Natal", "Synastry", "Transit"]).capitalize()
46
 
47
- if chart_type in ["Synastry", "Transit"]:
 
48
  st.write("Enter information for the second person:")
49
- name2, year2, month2, day2, hour2, minute2, location2, zodiac_type2 = get_user_input()
50
- person1 = AstrologicalSubject(name1, year1, month1, day1, hour1, minute1, location1, zodiac_type=zodiac_type1)
51
  person2 = AstrologicalSubject(name2, year2, month2, day2, hour2, minute2, location2, zodiac_type=zodiac_type2)
52
- chart = KerykeionChartSVG(person1, chart_type=chart_type, second_obj=person2)
53
- else:
54
- person1 = AstrologicalSubject(name1, year1, month1, day1, hour1, minute1, location1, zodiac_type=zodiac_type1)
55
- chart = KerykeionChartSVG(person1, chart_type=chart_type)
56
-
57
- chart.makeSVG()
58
 
59
- # Create a user report
60
- user_report = Report(person1)
61
-
62
- st.write(f"Number of aspects found: {len(chart.aspects_list)}")
63
-
64
- # Download the report as a text file
65
- st.markdown("## Download Report")
66
- st.write("Click the button below to download the report as a text file.")
67
-
68
- script_dir = os.path.dirname(os.path.abspath(__file__))
69
- report_file_path = os.path.join(script_dir, "report.txt")
70
 
71
- if st.button("Download Report"):
72
- # Create a user report
73
- user_report = Report(person1)
74
-
75
- with open(report_file_path, 'w') as file:
76
- sys.stdout = file
77
- user_report.print_report()
78
- sys.stdout = sys.__stdout__
79
- st.success(f"Report successfully downloaded as 'report.txt'")
80
 
81
- # Display the content of 'report.txt'
82
- if os.path.exists(report_file_path):
83
- with open(report_file_path, 'r') as file:
84
- report_content = file.read()
85
- st.markdown("## Report Content")
86
- st.text(report_content)
87
- else:
88
- st.warning("Report file not found. Please generate the report first.")
89
 
90
- # Search and display an SVG image in the current directory
91
  st.markdown("## Generated Astrological Chart")
 
92
  svg_files = [f for f in os.listdir(script_dir) if f.endswith(".svg")]
93
-
94
  if svg_files:
95
- svg_file = svg_files[0] # Display the first SVG file found
96
  st.image(os.path.join(script_dir, svg_file), use_container_width=True)
97
  else:
98
  st.write("No SVG files found in the current directory.")
 
1
  import streamlit as st
2
+ from kerykeion import AstrologicalSubject, KerykeionChartSVG, SynastryAspects
3
  from kerykeion.report import Report
4
  import sys
5
  import os
6
+ import re
7
+ import google.generativeai as genai
8
+ from io import StringIO
9
 
10
+ # Function to clean text for Google GEMINI
11
+ def clean_text(text):
12
+ cleaned_text = re.sub(r'[^a-zA-Z0-9\s]', '', text)
13
+ return cleaned_text
 
 
 
 
 
14
 
15
+ # Function to generate response from Google GEMINI
16
+ def generate_response(cleaned_input, model):
17
+ try:
18
+ response = model.generate_content(cleaned_input, stream=True)
19
+ full_response = ""
20
+ for chunk in response:
21
+ full_response += chunk.text
22
+ return full_response
23
+ except Exception as e:
24
+ error_message = str(e)
25
+ st.error(f"Error: {error_message}")
26
+ return None
27
+
28
+ # Function to get user input for astrological charts, with unique keys
29
+ def get_user_input(key_suffix=""):
30
+ name = st.text_input(f"Person's name {key_suffix}:", key=f"name{key_suffix}")
31
+ year = st.number_input(f"Year of birth {key_suffix}:", min_value=1900, max_value=2099, key=f"year{key_suffix}")
32
+ month = st.number_input(f"Month of birth {key_suffix} (1-12):", min_value=1, max_value=12, key=f"month{key_suffix}")
33
+ day = st.number_input(f"Day of birth {key_suffix} (1-31):", min_value=1, max_value=31, key=f"day{key_suffix}")
34
+ hour = st.number_input(f"Hour of birth {key_suffix} (0-23):", min_value=0, max_value=23, key=f"hour{key_suffix}")
35
+ minute = st.number_input(f"Minute of birth {key_suffix} (0-59):", min_value=0, max_value=59, key=f"minute{key_suffix}")
36
+ location = st.text_input(f"Place of birth {key_suffix}:", key=f"location{key_suffix}")
37
+ zodiac_type = st.selectbox(f"Zodiac type {key_suffix}", ["Tropic", "Sidereal"], key=f"zodiac_type{key_suffix}").capitalize()
38
  return name, year, month, day, hour, minute, location, zodiac_type
39
 
40
+ class SynastryAspectsWithRelevant(SynastryAspects):
41
+ @property
42
+ def relevant_aspects(self):
43
+ relevant_aspects_list = []
44
+
45
+ # Add your logic to calculate relevant aspects here
46
+ for aspect in self.all_aspects:
47
+ # Customize this condition based on your criteria
48
+ if aspect["orbit"] < 10:
49
+ relevant_aspects_list.append(aspect)
50
+
51
+ return relevant_aspects_list
52
+
53
  def main():
54
+ st.title("Astrological Chart Oracle")
55
+ st.write("Enter information for you, your lover or both, and get astrological and compatibility results!:")
56
+
57
+ # Astrological chart generation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  st.write("Enter information for the first person:")
59
  name1, year1, month1, day1, hour1, minute1, location1, zodiac_type1 = get_user_input()
60
+ person1 = AstrologicalSubject(name1, year1, month1, day1, hour1, minute1, location1, zodiac_type=zodiac_type1)
61
 
62
+ chart_type = st.selectbox("Chart type", ["Natal", "Synastry"]).capitalize()
63
 
64
+ report_content = ""
65
+ if chart_type == "Synastry":
66
  st.write("Enter information for the second person:")
67
+ name2, year2, month2, day2, hour2, minute2, location2, zodiac_type2 = get_user_input(" - Person 2")
 
68
  person2 = AstrologicalSubject(name2, year2, month2, day2, hour2, minute2, location2, zodiac_type=zodiac_type2)
 
 
 
 
 
 
69
 
70
+ synastry = SynastryAspectsWithRelevant(person1, person2)
71
+ aspect_list = synastry.relevant_aspects
72
+ report_content = "\n".join([str(aspect) for aspect in aspect_list])
 
 
 
 
 
 
 
 
73
 
74
+ # Google GEMINI integration
75
+ genai.configure(api_key='AIzaSyAkbU3CsZ-xmOhRF1XfdlVxasRtt9gdRMk') # Replace with your Gemini API key
76
+ model = genai.GenerativeModel('gemini-pro')
 
 
 
 
 
 
77
 
78
+ st.write("Ask the WiseOracle using your astrological chart information as context")
79
+ user_query = st.text_input("Your question:")
80
+ if st.button("Get Astrological Insight"):
81
+ cleaned_input = clean_text(report_content + " " + user_query)
82
+ response = generate_response(cleaned_input, model)
83
+ if response:
84
+ st.success(response)
 
85
 
86
+ # Display the astrological chart
87
  st.markdown("## Generated Astrological Chart")
88
+ script_dir = os.path.dirname(os.path.abspath(__file__))
89
  svg_files = [f for f in os.listdir(script_dir) if f.endswith(".svg")]
 
90
  if svg_files:
91
+ svg_file = svg_files[0]
92
  st.image(os.path.join(script_dir, svg_file), use_container_width=True)
93
  else:
94
  st.write("No SVG files found in the current directory.")