Prat0's picture
Update app.py
59ead7f verified
raw
history blame
2.7 kB
import gradio as gr
from composio_llamaindex import ComposioToolSet, App, Action
from llama_index.core.agent import FunctionCallingAgentWorker
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai import OpenAI
from dotenv import load_dotenv
load_dotenv()
# Initialize Composio ToolSet and OpenAI model
composio_toolset = ComposioToolSet()
tools = composio_toolset.get_tools(apps=[App.EXA, App.BROWSERBASE_TOOL, App.GOOGLESHEETS])
llm = OpenAI(model="gpt-4o")
# Set up prefix messages for the agent
prefix_messages = [
ChatMessage(
role="system",
content=(
"You are a domain name suggestion agent. Based on the latest news of business mergers and acquisitions, suggest creative domain names."
"Use the information available to you. Provide at least 10 relevant domain name suggestions based on the merger or acquisition."
"Include the following elements in your suggestions:"
"""
Suggested Domain Names:
1. Domain Name
2. Availability Status
3. Related Keywords
4. Industry Relevance
"""
"Once the suggestions have been generated, present them in a clear format."
),
)
]
# Define the function that interacts with the agent
def generate_domain_suggestions(industry, reason):
# Initialize the agent worker
agent = FunctionCallingAgentWorker(
tools=tools,
llm=llm,
prefix_messages=prefix_messages,
max_function_calls=10,
allow_parallel_tool_calls=False,
verbose=True,
).as_agent()
user_input = f"Based on the Industry {industry} look for latest merger and business deals and then suggest domain names that can be bought for these mergers and deals."
response = agent.chat(user_input)
return response.response
# Create Gradio Interface with two input fields and Markdown output
iface = gr.Interface(
fn=generate_domain_suggestions,
inputs=[
#gr.HTML("<h2>Built with Composio</h2><a href='https://github.com/composiohq/composio'>GitHub Repository</a>"),
gr.Textbox(label="Industry Name", placeholder="Enter the name of the industry"),
],
outputs=[
gr.Markdown(label="Domain Suggestions and Sponsorship Request"),
],
title="Domain Name Suggestion Tool for Mergers and Acquisitions",
description="Built with [Composio](https://www.github.com/composiohq/composio) Use this tool to generate domain name suggestions based on the latest business mergers and acquisitions.",
theme=gr.themes.Default(), # Ensure to set a theme if needed
)
# Launch the interface
iface.launch()