Spaces:
Sleeping
Sleeping
File size: 1,795 Bytes
7945f21 a3039c8 3333dc6 a3039c8 5cda2c7 a3039c8 88ebf1d a3039c8 81ae11d a3039c8 beeefa7 a3039c8 a2464d8 e563dc0 a3039c8 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.SERPAPI])
def find_hackernews_posts(message,history):
profile = message
hacnews_agent = Agent(
role="Technical Researcher",
goal="Find the best technical posts on Hackernews",
backstory="You are a technical person who loves reading Hackernews and looking for technical posts. You spend all your time looking for interesting posts of the day.",
llm=llm,
tools=tools
)
hacnews_task = Task(
description=f"""
Use the serp tool to search for the user's twitter profile of name {profile} to read his bio,
and then scrape it. Based on his bio, find good technical hackernews posts suited to his bio.
Return one post that is most appropriate to the personality. Make it funny. Return title and link to it.
""",
expected_output="A list of 5 technical hackernews posts with titles and URLs",
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="HackerNews Post Finder",
description="Enter a Twitter username to find relevant technical HackerNews posts.",
)
if __name__ == "__main__":
chat_interface.launch() |