HoMi264 commited on
Commit
02c6c77
·
verified ·
1 Parent(s): ae7a494

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -7
app.py CHANGED
@@ -9,14 +9,41 @@ 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 import to specify the return type
13
- #Keep this format for the description / args / 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:
@@ -55,7 +82,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def create_fantasy_story(heros_name: str, number_of_chapter: int) -> str:
13
+ """A tool that generates a fantasy story based on a hero's name and a specified number of chapters.
 
14
  Args:
15
+ arg1: The name of the hero or heroine.
16
+ arg2: The number of chapters in the story.
17
  """
18
+ # Story templates for chapters
19
+ settings = [
20
+ "in the deep, enchanted forests",
21
+ "on the rugged, misty mountains",
22
+ "in the mysterious ruins of an ancient civilization",
23
+ "in the bustling city of magic"
24
+ ]
25
+ conflicts = [
26
+ "facing a dragon that terrorizes the land",
27
+ "battling a dark sorceress who unleashes sinister magic",
28
+ "confronting an ancient curse that turns villagers to stone",
29
+ "challenging an army of shadow warriors threatening the kingdom"
30
+ ]
31
+ resolutions = [
32
+ "bravely saving the day",
33
+ "finding a magical ally who helped defeat the threat",
34
+ "discovering the secret of an ancient spell",
35
+ "engaging in an epic battle that became legendary"
36
+ ]
37
+
38
+ story = f"The Story of {arg1}:\n\n"
39
+ for i in range(1, arg2 + 1):
40
+ setting = random.choice(settings)
41
+ conflict = random.choice(conflicts)
42
+ resolution = random.choice(resolutions)
43
+ chapter = (f"Chapter {i}: {arg1} ventures {setting} to confront "
44
+ f"{conflict} and ultimately {resolution}.\n")
45
+ story += chapter
46
+ return story
47
 
48
  @tool
49
  def get_current_time_in_timezone(timezone: str) -> str:
 
82
 
83
  agent = CodeAgent(
84
  model=model,
85
+ tools=[create_fantasy_story,final_answer], ## add your tools here (don't remove final answer)
86
  max_steps=6,
87
  verbosity_level=1,
88
  grammar=None,