SergeyO7 commited on
Commit
8e35c72
·
verified ·
1 Parent(s): 6ac4d9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -14
app.py CHANGED
@@ -4,19 +4,53 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
 
8
  from Gradio_UI import GradioUI
9
 
10
- # Below is an example of a tool that does nothing. Amaze us with your creativity!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: # it's important to specify the return type
13
- # Keep this format for the tool description / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
- Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -36,10 +70,10 @@ def get_current_time_in_timezone(timezone: str) -> str:
36
 
37
  final_answer = FinalAnswerTool()
38
  model = HfApiModel(
39
- max_tokens=2096,
40
- temperature=0.5,
41
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
42
- custom_role_conversions=None,
43
  )
44
 
45
 
@@ -51,7 +85,7 @@ with open("prompts.yaml", 'r') as stream:
51
 
52
  agent = CodeAgent(
53
  model=model,
54
- tools=[final_answer], # add your tools here (don't remove final_answer)
55
  max_steps=6,
56
  verbosity_level=1,
57
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from skyfield.api import load, Topos
8
+ from skyfield.almanac import find_discrete, moon_phase_fraction
9
  from Gradio_UI import GradioUI
10
 
11
+ # Define Zodiac signs and their boundaries
12
+ ZODIAC_SIGNS = [
13
+ ("Aries", 0, 30),
14
+ ("Taurus", 30, 60),
15
+ ("Gemini", 60, 90),
16
+ ("Cancer", 90, 120),
17
+ ("Leo", 120, 150),
18
+ ("Virgo", 150, 180),
19
+ ("Libra", 180, 210),
20
+ ("Scorpio", 210, 240),
21
+ ("Sagittarius", 240, 270),
22
+ ("Capricorn", 270, 300),
23
+ ("Aquarius", 300, 330),
24
+ ("Pisces", 330, 360),
25
+ ]
26
+
27
  @tool
28
+ def get_moon_position_in_zodiac() -> str:
29
+ """A tool that calculates the current position of the Moon in the Zodiac.
 
 
 
 
30
  """
31
+ # Load astronomical data
32
+ planets = load('de421.bsp') # Downloaded from JPL Horizons
33
+ ts = load.timescale()
34
+
35
+ # Get the current time in UTC
36
+ now = datetime.datetime.now(pytz.utc)
37
+ t = ts.from_datetime(now)
38
+
39
+ # Get the geocentric position of the Moon
40
+ earth = planets['earth']
41
+ moon = planets['moon']
42
+ astrometric = earth.at(t).observe(moon)
43
+ ra, dec, distance = astrometric.radec()
44
+
45
+ # Convert RA to degrees
46
+ ra_in_degrees = ra._degrees
47
+
48
+ # Determine the Zodiac sign based on RA
49
+ for sign, start, end in ZODIAC_SIGNS:
50
+ if start <= ra_in_degrees < end:
51
+ return f"The Moon is currently in {sign} ({start}° - {end}°)"
52
+
53
+ return "Unknown"
54
 
55
  @tool
56
  def get_current_time_in_timezone(timezone: str) -> str:
 
70
 
71
  final_answer = FinalAnswerTool()
72
  model = HfApiModel(
73
+ max_tokens=2096,
74
+ temperature=0.5,
75
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
76
+ custom_role_conversions=None,
77
  )
78
 
79
 
 
85
 
86
  agent = CodeAgent(
87
  model=model,
88
+ tools=[final_answer, get_moon_position_in_zodiac], # Add the new tool here
89
  max_steps=6,
90
  verbosity_level=1,
91
  grammar=None,