Spaces:
Sleeping
Sleeping
import gradio as gr | |
from composio_crewai import ComposioToolSet, App, Action | |
from crewai import Agent, Task, Crew, Process | |
from langchain_openai import ChatOpenAI | |
from dotenv import load_dotenv | |
import os | |
load_dotenv() | |
llm = ChatOpenAI(model="gpt-4o") | |
toolset = ComposioToolSet() | |
tools = toolset.get_tools(apps=[App.BROWSERBASE_TOOL, App.WEBTOOL, App.BROWSER_TOOL, App.IMAGE_ANALYSER]) | |
def find_hackernews_posts(message,history): | |
input_website = message | |
hacnews_agent = Agent( | |
role="Web Roaster", | |
goal="Roast the website based on content and design", | |
backstory="You are a funny website roaster that reads the web content and the image of the website and roasts it.", | |
llm=llm, | |
tools=tools | |
) | |
hacnews_task = Task( | |
description=f""" | |
Use the serp tool to search for the website of name {input_website} to read its content and take a screenshot, | |
and then roast it. Be insanely funny, make it shareworthy. | |
Note: Write a detailed roast. | |
""", | |
expected_output="The Website was roasted", | |
agent=hacnews_agent, | |
tools=tools | |
) | |
crew = Crew( | |
agents=[hacnews_agent], | |
tasks=[hacnews_task], | |
process=Process.sequential, | |
verbose=True | |
) | |
result = crew.kickoff() | |
# Return the result in the format expected by the Chatbot component | |
return str(result) | |
chat_interface = gr.ChatInterface( | |
fn=find_hackernews_posts, | |
title="Website Roaster", | |
description="Enter a Website url to get it roasted. Built using Composio :)", | |
) | |
if __name__ == "__main__": | |
chat_interface.launch() |