generate nick name agent
Browse files
app.py
CHANGED
|
@@ -6,17 +6,31 @@ 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
|
| 12 |
-
def
|
| 13 |
-
|
| 14 |
-
|
| 15 |
Args:
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
"""
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
@tool
|
| 22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -40,10 +54,10 @@ final_answer = FinalAnswerTool()
|
|
| 40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 41 |
|
| 42 |
model = HfApiModel(
|
| 43 |
-
max_tokens=2096,
|
| 44 |
-
temperature=0.5,
|
| 45 |
-
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
| 46 |
-
custom_role_conversions=None,
|
| 47 |
)
|
| 48 |
|
| 49 |
|
|
@@ -55,7 +69,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,
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
+
import random
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def generate_nick_name(first_name: str, special_number: int) -> str:
|
| 14 |
+
"""Generates a creative nickname using the user's first name and a special number.
|
| 15 |
+
|
| 16 |
Args:
|
| 17 |
+
first_name: The user's first name.
|
| 18 |
+
special_number: A special number associated with the user.
|
| 19 |
+
|
| 20 |
+
Returns:
|
| 21 |
+
A dynamically generated nickname.
|
| 22 |
"""
|
| 23 |
+
adjectives = ["Swift", "Mighty", "Shadow", "Electric", "Blazing", "Frosty", "Cosmic", "Iron", "Ghost"]
|
| 24 |
+
suffixes = ["X", "Storm", "Knight", "Nova", "Phantom", "Hunter", "Rider", "Specter", "Cobra"]
|
| 25 |
+
|
| 26 |
+
# Randomly select an adjective and suffix
|
| 27 |
+
adjective = random.choice(adjectives)
|
| 28 |
+
suffix = random.choice(suffixes)
|
| 29 |
+
|
| 30 |
+
# Create a nickname based on the input
|
| 31 |
+
nickname = f"{adjective}{first_name[:3]}{special_number}{suffix}"
|
| 32 |
+
|
| 33 |
+
return f"Your generated nickname is: {nickname}"
|
| 34 |
|
| 35 |
@tool
|
| 36 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 54 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 55 |
|
| 56 |
model = HfApiModel(
|
| 57 |
+
max_tokens=2096,
|
| 58 |
+
temperature=0.5,
|
| 59 |
+
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
| 60 |
+
custom_role_conversions=None,
|
| 61 |
)
|
| 62 |
|
| 63 |
|
|
|
|
| 69 |
|
| 70 |
agent = CodeAgent(
|
| 71 |
model=model,
|
| 72 |
+
tools=[final_answer, generate_nick_name, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
|
| 73 |
max_steps=6,
|
| 74 |
verbosity_level=1,
|
| 75 |
grammar=None,
|