Content Creation Assistant With Humanizer
In this notebook, we demonstrate how to use the Lyzr Agent API to create an AI-driven content creation assistant capable of generating various content formats such as articles, blog posts, and social media updates. The process begins by configuring an environment with LLM capabilities, including a key feature called HUMANIZER
that ensures the content generated is more human-like and relatable. Additionally, tools like “perplexity_search” are integrated to assist with information retrieval and analysis. Next, we set up an agent specifically trained to create, refine, and humanize content based on user input, providing personalized outputs tailored to the requested format. To learn more about building agents, refer to the official Lyzr Agent API documentation.
To try this, refer to this Google Colab guide
1. Install Package:
2. Setup and Initialization:
This line initializes the AgentAPI client to interact with the Lyzr Agent API. It sets the base URL for API requests, passes the required API key (lyzr-api-key) for authentication, and specifies a timeout of 3600 seconds for API responses. This client will be used to communicate with the API, allowing functions such as environment and agent creation, as well as content generation.
3. Environment Creation:
This configuration sets up an environment for a content creation agent using the EnvironmentConfig class. The environment is named “Content Creation Environment” and includes a key feature called HUMANIZER, which ensures the generated content has a more human-like quality. The environment is equipped with the “perplexity_search” tool, which can assist in information retrieval or processing tasks. For language model capabilities, the environment is configured to use OpenAI’s “gpt-4o-mini” model. The model’s behavior is fine-tuned with a temperature setting of 0.5, allowing for a balance between creative diversity and focus in responses, along with a top-p value of 0.9. The OpenAI API key is also specified in the environment for secure communication with the language model.
4. Create Content Creation Agent:
The agent_config defines the configuration for creating an AI-driven content creation agent. It specifies the environment in which the agent operates using an env_id, sets a system_prompt to guide the agent’s behavior (in this case, as an expert in generating different content formats such as articles, social media posts, and code), and assigns a name and description to the agent. This configuration enables the agent to assist users in creating a variety of content, tailored to specific user requests.
5. User Interaction and Content Generation:
The response variable captures the result of sending a chat request to the content creation agent using the chat_with_agent method. In this request, the user_id and agent_id are provided to identify the user and the specific agent that will handle the task. The message field contains the user’s prompt, in this case, asking the agent to “Write a blog post on ‘The benefits of using a content creation AI assistant’.” The agent processes this request and generates the desired content, which is returned in the response.
Response