How to Develop Customized AI Applications with Council

Nov 29, 2021 | Educational

Welcome to the world of Council, an open-source platform designed for the rapid development and robust deployment of generative AI applications. With Council, you can create sophisticated AI agents that are not just capable of executing various tasks but also possess predictable behavior. This article will guide you through the process of setting up and using Council to develop your custom AI applications effectively.

Installation

Before you can start using Council, you need to install it. Here are some ways to do that:

  • Install with pip via PyPI: Use the command pip install council-ai
  • Install from git ref: Run pip install git+https://github.com/chain-ml/council.git@branch_name. More documentation is available here.
  • Install from local copy: Clone the repository, navigate to the root directory and run pip install -e git+https://github.com/chain-ml/council.git@branch_name.

To uninstall, simply run pip uninstall council-ai.

Setup

Next, set up your required API keys by creating a .env file. Reference the .env.example for guidance.

Usage

Let’s dive into some code to create your first AI agents.

# Import necessary libraries
from council.chains import Chain
from council.skills import LLMSkill
from council.llm import OpenAILLM

# Load environment variables
import dotenv
dotenv.load_dotenv()

# Set up LLM from environment variables
openai_llm = OpenAILLM.from_env()

# Create a 'Hello World' skill
prompt = "You are responding to every prompt with a short poem titled hello world."
hw_skill = LLMSkill(llm=openai_llm, system_prompt=prompt)
hw_chain = Chain(name="Hello World", description="Answers with a poem titled Hello World", runners=[hw_skill])

# Create an emoji responding skill
prompt = "You are responding to every prompt with an emoji that best addresses the statement."
em_skill = LLMSkill(llm=openai_llm, system_prompt=prompt)
em_chain = Chain(name="Emoji Agent", description="Responds with an emoji for every prompt", runners=[em_skill])

# Create a controller
from council.controllers import LLMController
controller = LLMController(llm=openai_llm, chains=[hw_chain, em_chain], response_threshold=5)

# Create an evaluator
from council.evaluators import LLMEvaluator
evaluator = LLMEvaluator(llm=openai_llm)

# Finalize the agent setup
from council.agents import Agent
from council.filters import BasicFilter
agent = Agent(controller=controller, evaluator=evaluator, filter=BasicFilter())

# Invoke the agent
result = agent.execute_from_user_message("hello world?!")
print(result.best_message.message)

Understanding the Components of Council

Think of Council as a dynamic concert conductor orchestrating various musicians (agents, skills, chains) to create a beautiful symphony (custom AI applications).

  • Agents: These are your lead musicians. They encapsulate the entire application logic from prompt input to the final response.
  • Controllers: Act like a director, managing user intent and routing the prompts through predefined chains.
  • Skills: These are the individual capabilities or instruments – each skill handles specific tasks or responses.
  • Chains: These are directed graphs connecting skills, creating a harmony of operations when executed.
  • Evaluators: Think of these as the audience, assessing the performance and selecting the best responses based on quality.

Troubleshooting

If you encounter any issues while setting up or using Council, consider the following troubleshooting tips:

  • Ensure that your API keys are correctly set in the .env file.
  • If you face installation issues, try upgrading your pip version or ensuring that you’re using an appropriate Python version.
  • Check for active internet connectivity, as some operations require online access to retrieve models.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

With Council, you have a powerful tool at your disposal to create, deploy, and manage advanced AI agents at scale. Dive in and start building your intelligent applications!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox