Spaces:
Sleeping
Sleeping
Update app.py
Browse filesgenerate_image_from_wikipedia added
Tools are added to CodeAgent
6 unmodified lines7891011121314151617181920212232 unmodified lines555657585960616 unmodified linesfrom 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 yetArgs:arg1: the first argumentarg2: the second argument"""return "What magic will you build ?"@tooldef get_current_time_in_timezone(timezone: str) -> str:32 unmodified linesagent = CodeAgent(model=model,tools=[final_answer], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,6 unmodified lines7891011121314151617181920212223242526272829303132333435363732 unmodified lines707172737475766 unmodified linesfrom Gradio_UI import GradioUIimport wikipedia@tooldef generate_image_from_wikipedia(topic: str) -> str:"""Fetches a Wikipedia summary of a given topic and uses it as a prompt to generate an image.Args:topic (str): The topic to search for on Wikipedia.Returns:str: URL or path to the generated image."""try:# Set Wikipedia language to Turkishwikipedia.set_lang("tr")# Get a short summary from Wikipediasummary = wikipedia.summary(topic, sentences=2)# Generate an image based on the summaryimage = image_generation_tool(summary)return image@tooldef get_current_time_in_timezone(timezone: str) -> str:32 unmodified linesagent = CodeAgent(model=model,tools=[generate_image_from_wikipedia, get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)max_steps=6,verbosity_level=1,grammar=None,
app.py+23-8