Skip to content

Commit

Permalink
feat: content hook generator agent added
Browse files Browse the repository at this point in the history
  • Loading branch information
Prat011 committed Feb 13, 2025
1 parent 05a9892 commit 2a7ab0d
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COMPOSIO_API_KEY=KEY
GROQ_API_KEY=KEY
OPENAI_API_KEY=KEY
46 changes: 46 additions & 0 deletions python/examples/quickstarters/content_hook_generator_agent/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import dotenv
from composio_llamaindex import App, ComposioToolSet
from llama_index.core.agent import FunctionCallingAgentWorker
from llama_index.core.llms import ChatMessage
from llama_index.llms.openai import OpenAI
from llama_index.llms.groq import Groq

dotenv.load_dotenv()
composio_toolset = ComposioToolSet()
tools = composio_toolset.get_tools(apps=[App.GOOGLESHEETS])

sheet_id = '1fVAkbBVeocPIPRMgaH-rO2kkswXWLUBVSZ8jf-xputs'
#llm = Groq(model="llama3-70b-8192", api_key=os.environ['GROQ_API_KEY'])
llm = Groq(

)

prefix_messages = [
ChatMessage(
role="system",
content=(
"You are an Content Hook Generator Agent."
"First scrape the google spreadsheet info"
"You have access to a google sheet that is a database of Hook Lines with metrics and categories"
"The user will describe their content to you and you'll look at this sheet to find the perfect hookline and tailor it to the usecase."
),
)
]

while True:
main_task = input("Describe your content (or type 'exit' to quit): ")
if main_task.lower() == 'exit':
break

agent = FunctionCallingAgentWorker(
tools=tools,
llm=llm,
prefix_messages=prefix_messages,
max_function_calls=10,
allow_parallel_tool_calls=False,
verbose=True,
).as_agent()

response = agent.chat(f"This is the content: {main_task}, the sheet id is {sheet_id}. Figure out the best hookline by using the tools available to you. Rephrase the content idea to match the spreadsheet content.")
print("Response:", response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Perplexity for Hackernews Agent Guide

This guide provides detailed steps to create an agent that searches relevant hackernews posts, it leverages LlamaIndex, Composio, and Groq to perform searches. Ensure you have Python 3.8 or higher installed.

## Steps to Run
**Navigate to the Project Directory:**
Change to the directory where the `setup.sh`, `main.py`, `requirements.txt`, and `README.md` files are located. For example:
```sh
cd path/to/project/directory
```

### 1. Run the Setup File
Make the setup.sh Script Executable (if necessary):
On Linux or macOS, you might need to make the setup.sh script executable:
```shell
chmod +x setup.sh
```
Execute the setup.sh script to set up the environment, install dependencies, login to composio and
add necessary tools:
```shell
./setup.sh
```
Now, Fill in the .env file with your secrets.
### 2. Run the python script
```shell
python cookbook/examples/quickstarters/perplexity_for_hackernews/main.py
```



Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
composio-llamaindex
llama-index-llms-groq
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Create a virtual environment
echo "Creating virtual environment..."
python3 -m venv ~/.venvs/content

# Activate the virtual environment
echo "Activating virtual environment..."
source ~/.venvs/content/bin/activate

# Install libraries from requirements.txt
echo "Installing libraries from requirements.txt..."
pip install -r requirements.txt

# Copy env backup to .env file
if [ -f ".env.example" ]; then
echo "Copying .env.example to .env..."
cp .env.example .env
else
echo "No .env.example file found. Creating a new .env file..."
touch .env
fi

# Prompt user to fill the .env file
echo "Please fill in the .env file with the necessary environment variables."

echo "Setup completed successfully!"

0 comments on commit 2a7ab0d

Please sign in to comment.