emroca commited on
Commit
34d55ef
·
verified ·
1 Parent(s): 01cc349

Update app.py

Browse files

ajuste de metodo custon

Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -11,26 +11,23 @@ import os
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
14
- """A tool that generates text or an image based on the provided arguments.
15
  Args:
16
  arg1: A string input to guide the generation.
17
- arg2: An integer input to specify the type of generation (1 for text, 2 for image).
18
  """
19
  if arg2 == 1:
20
- # Generate text using LLM
21
  prompt = f"Generate a detailed description based on the following input: {arg1}"
22
  response = model.generate(prompt)
23
  return response['choices'][0]['text']
24
  elif arg2 == 2:
25
- # Generate image using image generation tool
26
- prompt = f"Generate an image based on the following input: {arg1}"
27
- try:
28
- image_response = image_generation_tool(prompt)
29
- return f"Image generated: {image_response['image_url']}"
30
- except Exception as e:
31
- return f"Failed to generate image. Error: {str(e)}"
32
  else:
33
- return "Invalid argument for arg2. Use 1 for text generation and 2 for image generation."
34
 
35
  @tool
36
  def get_current_time_in_timezone(timezone: str) -> str:
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
14
+ """A tool that generates text based on the provided arguments.
15
  Args:
16
  arg1: A string input to guide the generation.
17
+ arg2: An integer input to specify the type of generation (1 for detailed description, 2 for summary).
18
  """
19
  if arg2 == 1:
20
+ # Generate detailed description using LLM
21
  prompt = f"Generate a detailed description based on the following input: {arg1}"
22
  response = model.generate(prompt)
23
  return response['choices'][0]['text']
24
  elif arg2 == 2:
25
+ # Generate summary using LLM
26
+ prompt = f"Generate a summary based on the following input: {arg1}"
27
+ response = model.generate(prompt)
28
+ return response['choices'][0]['text']
 
 
 
29
  else:
30
+ return "Invalid argument for arg2. Use 1 for detailed description and 2 for summary."
31
 
32
  @tool
33
  def get_current_time_in_timezone(timezone: str) -> str: