rtamaki commited on
Commit
2d98f03
·
verified ·
1 Parent(s): fe0387d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -6,6 +6,9 @@ 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
@@ -33,6 +36,36 @@ def get_current_time_in_timezone(timezone: str) -> str:
33
  except Exception as e:
34
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  final_answer = FinalAnswerTool()
38
 
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
+ from transformers import AutoTokenizer
10
+
11
+
12
 
13
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
14
  @tool
 
36
  except Exception as e:
37
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
38
 
39
+ @tool
40
+ def get_demon_slayer_hashira(description: str) -> str:
41
+ """A tool that fetches the name of the Hashira, a title for top demon slayer characters in the Demon Slayer anime, based on the description of the
42
+ Args:
43
+ description: The description of the Hashira(s) that we are looking for
44
+ """
45
+ desctiptions = """
46
+ Flame Hashira: Kyōjurō Rengoku is a young adult of tall stature and athletic build. He has long bright yellow hair with red streaks with two shoulder-length bangs and two chin-length bangs on the side of his head, black forked eyebrows, and golden eyes that fade to red with white pupils.
47
+ Love Hashira: Mitsuri Kanroji is a young curvaceous woman with fair skin and round, light green eyes with long eyelashes, a small mole beneath each of them. She has long, pink hair that fades into a neon green color at the halfway point, which she wears in three thick braids with five shorter clumps hanging over her face as bangs. When she was trying to get married, her hair was dyed black in an attempt to make herself look more "normal".
48
+ Stone Hashira: Gyōmei Himejima is a hulking figure among the Demon Slayers. He is one of the tallest characters in the series, easily towering over his fellow Hashira. He is powerfully built and extremely muscular. He has spiky black hair and a prominent scar running horizontally across his forehead. Having been blind since childhood, he has white eyes with no visible irises or pupils. His eyes frequently tear-up when he gets emotional.
49
+ Mist Hashira: Muichirō Tokitō is a short, young man of light complexion with long, straight hair of a black color that fades into aquamarine/cyan as it approaches his waist. He wears his hair loose with two clumps protruding slightly from each side of his head, a set of marginally shorter hair left down to frame his face, and unruly bangs over his forehead. He also possesses large, empty-looking soft cyan eyes. His eyes and hair are traits shared with his twin brother, Yūichirō Tokitō.
50
+ Snake Hashira: Obanai Iguro is a young man of short stature and a pale complexion. He has straight-edged black hair of varying lengths, the longest reaching down to his shoulders and the shortest stopping at his cheekbones, which he wears down with two shorter strands hanging between his eyes. His eyes are almond-shaped and tilt upwards on the far sides, and are unusual due to Obanai possessing heterochromia—his right eye is yellow and his left eye is turquoise. He is partially blind as he can barely see out of his right eye.
51
+ Water Hashira: Giyū Tomioka is a fairly tall young man of a lean muscular stature and pale complexion, who is almost always seen wearing a serious and emotionless expression. He has unruly black hair of uneven lengths that sticks up in tufts around his head, which he wears tied back in a low messy ponytail at the base of his neck. His bangs fall over his eyes in an uneven fringe. His eyes are sharp and moderately large, their irises a deep sapphire that fades to a lighter blue and their pupils a bluish-black, and are framed by thin eyebrows.
52
+ """
53
+ messages = [
54
+ {"role": "system", "content": ""},
55
+ {"role": "user", "content": "Hi !"},
56
+ {"role": "assistant", "content": "Hi human, what can help you with ?"},
57
+ ]
58
+ tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM2-1.7B-Instruct")
59
+ rendered_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
60
+ try:
61
+ # Create timezone object
62
+ tz = pytz.timezone(timezone)
63
+ # Get current time in that timezone
64
+ local_time = datetime.datetime.now(tz).strftime("%Y-%m-%d %H:%M:%S")
65
+ return f"The current local time in {timezone} is: {local_time}"
66
+ except Exception as e:
67
+ return f"Error fetching time for timezone '{timezone}': {str(e)}"
68
+
69
 
70
  final_answer = FinalAnswerTool()
71