Delete app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950!pip install python_dotenv!pip install langchain!pip install langchain-google-genai!pip install gradio
from dotenv import load_dotenvfrom langchain_google_genai import ChatGoogleGenerativeAIfrom langchain_core.tools import toolfrom langchain.agents import create_tool_calling_agent, AgentExecutorfrom langchain_core.prompts import ChatPromptTemplateimport gradio as gr
load_dotenv()
@tool(description= "calculate math expression like '2 * 2' or '10 * 5'")def calculator(expression :str)-> str: try: return str(eval(expression)) except: return 'invalid expression'
def calculate(message: str, history: list) -> str: llm =ChatGoogleGenerativeAI(model="gemini-2.5-flash-lite") system_message ="""you are a helpfull assistant use the calculator tool when you need to perform calculations""" prompt= ChatPromptTemplate.from_messages( [("system",system_message),("human","{input}"),("placeholder","{agent_scratchpad}")]) agent = create_tool_calling_agent(llm,[calculator],prompt) executor = AgentExecutor(agent=agent,tools=[calculator],verbose=True) result = executor.invoke({"input":message}) return result["output"]
PAGE_TITLE = "Caramel AI from HERE AND NOW AI !"LOGO_URL = "https://raw.githubusercontent.com/hereandnowai/images/refs/heads/main/logos/logo-of-here-and-now-ai.png"ASSISTANT_AVATAR_URL = "https://raw.githubusercontent.com/hereandnowai/images/refs/heads/main/logos/caramel-face.jpeg"
description_md = f"""<img src='{LOGO_URL}' width='500' style='display: block; margin: auto;'> <br>Your friendly AI teacher for learning the basics of Artificial Intelligence!"""
gr.ChatInterface( fn = calculate, title = PAGE_TITLE, description = description_md, examples=["what is 2+2?","what is 2*2?"], chatbot = gr.Chatbot( type='messages', avatar_images=[None,ASSISTANT_AVATAR_URL]), type ='messages').launch()app.pyDeleted-50