File size: 1,659 Bytes
7945f21
a3039c8
 
 
 
 
 
 
 
3333dc6
a3039c8
 
f0873e7
a3039c8
88ebf1d
8e52166
a3039c8
 
8e52166
 
 
a3039c8
 
 
 
 
 
8e52166
5682b27
 
a3039c8
8e52166
a3039c8
 
 
 
 
 
 
 
 
 
 
 
a2464d8
 
e563dc0
a3039c8
 
 
d1754a8
5ba8b56
7945f21
 
 
a3039c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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()