-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: content hook generator agent added
- Loading branch information
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
python/examples/quickstarters/content_hook_generator_agent/.env.example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
46
python/examples/quickstarters/content_hook_generator_agent/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
30 changes: 30 additions & 0 deletions
30
python/examples/quickstarters/content_hook_generator_agent/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
||
|
||
|
2 changes: 2 additions & 0 deletions
2
python/examples/quickstarters/content_hook_generator_agent/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
composio-llamaindex | ||
llama-index-llms-groq |
27 changes: 27 additions & 0 deletions
27
python/examples/quickstarters/content_hook_generator_agent/setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" |