MohanaPrasad2002 commited on
Commit
aa95885
·
verified ·
1 Parent(s): dfec600

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -4,6 +4,7 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
 
8
  from Gradio_UI import GradioUI
9
 
@@ -18,6 +19,30 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
18
  """
19
  return "What magic will you build ?"
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
23
  """A tool that fetches the current local time in a specified timezone.
@@ -55,7 +80,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[final_answer,image_generation_tool], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ from diffusers import DiffusionPipeline
8
 
9
  from Gradio_UI import GradioUI
10
 
 
19
  """
20
  return "What magic will you build ?"
21
 
22
+
23
+ @tool
24
+ def video_generation(
25
+ prompt: str,
26
+ num_frames: int = 24,
27
+ num_inference_steps: int = 50,
28
+ guidance_scale: float = 9.0
29
+ ) -> str:
30
+ """Generate a video from text. Returns path to saved video file."""
31
+
32
+ pipe = DiffusionPipeline.from_pretrained("vdo/text-to-video-ms-1.7b")
33
+
34
+ # Generate frames
35
+ video_frames = pipe(
36
+ prompt,
37
+ num_frames=num_frames,
38
+ num_inference_steps=num_inference_steps,
39
+ guidance_scale=guidance_scale,
40
+ generator=torch.Generator().manual_seed(42) # Optional seed
41
+ ).frames[0]
42
+
43
+ print(video_frames)
44
+
45
+
46
  @tool
47
  def get_current_time_in_timezone(timezone: str) -> str:
48
  """A tool that fetches the current local time in a specified timezone.
 
80
 
81
  agent = CodeAgent(
82
  model=model,
83
+ tools=[final_answer,image_generation_tool,video_generation], ## add your tools here (don't remove final answer)
84
  max_steps=6,
85
  verbosity_level=1,
86
  grammar=None,