Spaces:
Runtime error
Runtime error
Upload 3 files
Browse filesFiles changed (3)
- README.md+9-12
- app.py+94-19
- requirements.txt+7
123456789101112131415161718---title: First Agent Templateemoji: ⚡colorFrom: pinkcolorTo: yellowsdk: gradiosdk_version: 5.15.0app_file: app.pypinned: falsetags:- smolagents- agent- smolagent- tool- agent-course---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112131415---title: Astrological Birth Chart Generatoremoji: 🌟colorFrom: indigocolorTo: purplesdk: gradioapp_file: app.pypinned: falselicense: mittags:- astrology- kerykeion- birth-chart- gradio---
3 unmodified lines45678910111213141516171819202122239 unmodified lines333435363738394041424344454647482 unmodified lines515253545556573 unmodified lines61626364653 unmodified linesimport pytzimport yamlfrom tools.final_answer import FinalAnswerToolfrom Gradio_UI import GradioUI# Below is an example of a tool that does nothing. Amaze us with your creativity !@tooldef my_cutom_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:"""A tool that fetches the current local time in a specified timezone.9 unmodified linesexcept Exception as e:return f"Error fetching time for timezone '{timezone}': {str(e)}"final_answer = FinalAnswerTool()model = HfApiModel(max_tokens=2096,temperature=0.5,model_id='https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud',# it is possible that this model may be overloadedcustom_role_conversions=None,)# Import tool from Hubimage_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)2 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,3 unmodified linesprompt_templates=prompt_templates)GradioUI(agent).launch()3 unmodified lines4567891011121314159 unmodified lines252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384852 unmodified lines888990919293943 unmodified lines98991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391403 unmodified linesimport pytzimport yamlfrom tools.final_answer import FinalAnswerToolfrom typing import Any, Optionalimport duckduckgo_searchfrom kerykeion import AstrologicalSubject, Report, KerykeionChartSVGimport gradio as grfrom Gradio_UI import GradioUI@tooldef get_current_time_in_timezone(timezone: str) -> str:"""A tool that fetches the current local time in a specified timezone.9 unmodified linesexcept Exception as e:return f"Error fetching time for timezone '{timezone}': {str(e)}"@tooldef create_birth_chart(name: str, year: int, month: int, day: int, hour: int, minute: int, city: str, nation: str) -> str:"""Creates an astrological birth chart based on user's birth information.Args:name: Person's nameyear: Birth yearmonth: Birth monthday: Birth dayhour: Birth hourminute: Birth minutecity: Birth citynation: Birth countryReturns:str: Path to the generated SVG file and astrological report"""try:# Create birth chartperson = AstrologicalSubject(name=name,year=year,month=month,day=day,hour=hour,minute=minute,city=city,nation=nation,)# Create SVG filechart = KerykeionChartSVG(person)svg_path = f"charts/{name.lower().replace(' ', '_')}_birth_chart.svg"chart.makeSVG(svg_path)# Create astrological reportreport = Report(person)report_text = report.get_full_report()return {"svg_path": svg_path,"report": report_text}except Exception as e:return f"Error occurred: {str(e)}"final_answer = FinalAnswerTool()model = HfApiModel(max_tokens=2096,temperature=0.5,model_id='https://wxknx1kg971u7k1n.us-east-1.aws.endpoints.huggingface.cloud',custom_role_conversions=None,)# Import tool from Hubimage_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)2 unmodified linesagent = CodeAgent(model=model,tools=[final_answer, create_birth_chart],max_steps=6,verbosity_level=1,grammar=None,3 unmodified linesprompt_templates=prompt_templates)def process_birth_chart(text_input: str):"""Processes user input to create a birth chart."""try:# Send query to agent and get responseresponse = agent.run(text_input)if isinstance(response, dict) and "svg_path" in response:# Return SVG file and reportreturn gr.Image(value=response["svg_path"]), response["report"]else:return None, "Sorry, couldn't create the birth chart."except Exception as e:return None, f"An error occurred: {str(e)}"# Create Gradio interfacewith gr.Blocks() as demo:gr.Markdown("# 🌟 Astrological Birth Chart Generator")with gr.Row():text_input = gr.Textbox(label="Enter Your Birth Information",placeholder="Example: My name is John Doe, I was born on May 5, 1990 at 15:30 in Istanbul, Turkey.")with gr.Row():submit_btn = gr.Button("Generate Birth Chart")with gr.Row():chart_output = gr.Image(label="Birth Chart")report_output = gr.Textbox(label="Astrological Report", lines=10)submit_btn.click(fn=process_birth_chart,inputs=[text_input],outputs=[chart_output, report_output])if __name__ == "__main__":demo.launch()
2 unmodified lines3452 unmodified linesrequestsduckduckgo_searchpandas2 unmodified lines34567891011122 unmodified linesrequestsduckduckgo_searchpandaskerykeiongradiopytzpyyamlpython-dateutilephempyswisseph
README.md+9-12
app.py+94-19
requirements.txt+7