Spaces:
Sleeping
Sleeping
Update app.py
Browse filesajuste de metodo custon
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
|
15 |
Args:
|
16 |
arg1: A string input to guide the generation.
|
17 |
-
arg2: An integer input to specify the type of generation (1 for
|
18 |
"""
|
19 |
if arg2 == 1:
|
20 |
-
# Generate
|
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
|
26 |
-
prompt = f"Generate
|
27 |
-
|
28 |
-
|
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
|
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:
|