Spaces:
Runtime error
Runtime error
Update app.py
Browse files6 unmodified lines789101012131411121314151617181920161721222324251926272829303132333435363738394041424344454647484950516 unmodified lines
from Gradio_UI import GradioUI
# Below is an example of a tool that does nothing. Amaze us with your creativity !@tooldef my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type #Keep this format for the description / args / args description but feel free to modify the tool """A tool that does nothing yet def game_memory_tool( game: str, event_type: Literal["observation", "decision", "battle", "quest", "inventory", "strategy"], content: str, importance: int) -> str: """ A tool that stores important game memories for an autonomous game-playing agent.
Args: arg1: the first argument arg2: the second argument game: The name of the game the agent is playing, e.g. "Pokemon Emerald". event_type: The type of memory being saved. Options: observation, decision, battle, quest, inventory, strategy. content: A clear description of what happened or what the agent decided. importance: A number from 1 to 10 showing how important this memory is. """ return "What magic will you build ?" try: if importance < 1 or importance > 10: return "Error: importance must be between 1 and 10."
memory = { "game": game, "event_type": event_type, "content": content, "importance": importance, "timestamp": datetime.datetime.now().isoformat() }
with open("game_agent_memory.jsonl", "a", encoding="utf-8") as file: file.write(json.dumps(memory, ensure_ascii=False) + "\n")
return ( f"Memory saved for {game}. " f"Type: {event_type}. " f"Importance: {importance}/10." )
except Exception as e: return f"Error saving game memory: {str(e)}"@tooldef get_current_time_in_timezone(timezone: str) -> str: """A tool that fetches the current local time in a specified timezone.app.py+35-7