Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,8 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
import numpy as np
|
|
|
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
@@ -45,6 +46,38 @@ def compute_vacuum_energy(L: float, N_max: int, hbar: float=1.0545718e-34, c: fl
|
|
| 45 |
|
| 46 |
return energy
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
def convert_energy(value: float, current_unit: str, target_unit: str) -> float:
|
| 49 |
"""
|
| 50 |
Convert an energy value from one unit to another.
|
|
@@ -131,7 +164,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 131 |
|
| 132 |
agent = CodeAgent(
|
| 133 |
model=model,
|
| 134 |
-
tools=[final_answer, get_age_univers, get_current_time_in_timezone, convert_energy, compute_vacuum_energy], ## add your tools here (don't remove final answer)
|
| 135 |
max_steps=6,
|
| 136 |
verbosity_level=1,
|
| 137 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
import numpy as np$
|
| 8 |
+
from typing import Tuple
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
|
|
|
| 46 |
|
| 47 |
return energy
|
| 48 |
|
| 49 |
+
@tool
|
| 50 |
+
def compute_universe_color(age_in_gyr: float) -> Tuple[int, int, int]:
|
| 51 |
+
"""
|
| 52 |
+
Estimate the average color of the universe based on its age.
|
| 53 |
+
|
| 54 |
+
Parameters:
|
| 55 |
+
age_in_gyr (float): Age of the universe in billions of years (Gyr).
|
| 56 |
+
|
| 57 |
+
Returns:
|
| 58 |
+
Tuple[int, int, int]: RGB color representing the average color of the universe.
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
# Clamp age to a plausible range (0 - 20 Gyr)
|
| 62 |
+
age = max(0.0, min(age_in_gyr, 20.0))
|
| 63 |
+
|
| 64 |
+
# Approximate color evolution over time in RGB
|
| 65 |
+
# 0 Gyr → blue-white (hot stars), 13.8 Gyr → cosmic latte (pale beige), 20 Gyr → reddish
|
| 66 |
+
if age < 1.0:
|
| 67 |
+
color = (180, 210, 255) # bright blue-white
|
| 68 |
+
elif age < 5.0:
|
| 69 |
+
color = (240, 230, 255) # softer white
|
| 70 |
+
elif age < 9.0:
|
| 71 |
+
color = (255, 240, 220) # yellowish
|
| 72 |
+
elif age < 13.0:
|
| 73 |
+
color = (255, 230, 210) # pale beige
|
| 74 |
+
elif age <= 14.0:
|
| 75 |
+
color = (255, 223, 196) # "cosmic latte"
|
| 76 |
+
else:
|
| 77 |
+
color = (240, 200, 180) # redder with star aging
|
| 78 |
+
|
| 79 |
+
return color
|
| 80 |
+
|
| 81 |
def convert_energy(value: float, current_unit: str, target_unit: str) -> float:
|
| 82 |
"""
|
| 83 |
Convert an energy value from one unit to another.
|
|
|
|
| 164 |
|
| 165 |
agent = CodeAgent(
|
| 166 |
model=model,
|
| 167 |
+
tools=[final_answer, get_age_univers, get_current_time_in_timezone, convert_energy, compute_vacuum_energy, compute_universe_color, DuckDuckGoSearchTool], ## add your tools here (don't remove final answer)
|
| 168 |
max_steps=6,
|
| 169 |
verbosity_level=1,
|
| 170 |
grammar=None,
|