LLM based multi-model framework for AI apps. The SuperPilot Framework is a robust architecture designed to build and execute various LLM app using prompt, abilities like text summarization, web searching, and more. It leverages machine learning models from providers like OpenAI to perform these tasks. The framework consists of several key components including OpenAI Provider, SimplePrompt, AbilityRegistry, and SuperTaskPilot, which are essential for smooth operation.
- Initializing OpenAI Provider
- Creating SimplePrompt
- Setting Up AbilityRegistry
- Executing SuperTaskPilot
Purpose: To set up OpenAI as a model provider for handling language completions.
- Import the necessary modules.
- Use the
OpenAIProvider.factory()
method to create an OpenAI Provider instance. - Store this instance in the
model_providers
dictionary for later use.
from superpilot.core.resource.model_providers import OpenAIProvider, ModelProviderName
from superpilot.core.configuration import get_config
config = get_config()
open_ai_provider = OpenAIProvider.factory(config.openai_api_key)
model_providers = {ModelProviderName.OPENAI: open_ai_provider}
Purpose: To generate the prompt that will be passed to the OpenAI model for completion.
- Import the SimplePrompt class.
- Initialize a SimplePrompt object.
- Build the prompt using
build_prompt()
method.
from superpilot.core.planning.strategies.simple import SimplePrompt
super_prompt = SimplePrompt.factory()
prompt = super_prompt.build_prompt("Your Query Here")
Before running any queries, make sure all necessary modules are imported and environment variables, including the OpenAI API key, are set up.
To make a query, utilize the test_pilot()
function. The query
string parameter specifies the information you're seeking.
query = "What is the weather in Mumbai"
This query instructs SimpleTaskPilot to fetch weather information for Mumbai.
query = "Analyze the stock market for today"
This query prompts SimpleTaskPilot to provide an analysis of today's stock market.
query = "Summarize the last 10 emails"
This query will lead SimpleTaskPilot to summarize the last 10 emails in your inbox.
query = "Summarize today's top 5 news"
This query tasks SimpleTaskPilot with fetching and summarizing the day's top 5 news articles.
After setting your query string, execute it with the following code:
from superpilot.core.context.schema import Context
from superpilot.core.pilot.task.simple import SimpleTaskPilot
from superpilot.core.resource.model_providers import (
ModelProviderName,
OpenAIProvider,
OpenAIModelName
)
context = Context()
# Load Model Providers
open_ai_provider = OpenAIProvider.factory(your_openai_api_key)
model_providers = {ModelProviderName.OPENAI: open_ai_provider}
task_pilot = SimpleTaskPilot(model_providers=model_providers)
print("***************** Executing SimplePilot ******************************\n")
query = "Summarize today's top 5 news"
response = await task_pilot.execute(query, context)
print(response)
print("***************** Executing SimplePilot Completed ******************************\n")
The output should be displayed on the console.
Purpose: To execute tasks using the registered abilities and model providers.
- Import the
SuperTaskPilot
class. - Initialize it with the
super_ability_registry
andmodel_providers
.
Purpose: To manage and register the abilities that your application will use.
- Import the
SuperAbilityRegistry
class. - Initialize it with the allowed abilities.
from superpilot.core.ability.super import SuperAbilityRegistry
from superpilot.tests.test_env_simple import get_env
env = get_env({})
ALLOWED_ABILITY = {
TextSummarizeAbility.name(): TextSummarizeAbility.default_configuration,
}
super_ability_registry = SuperAbilityRegistry.factory(env, ALLOWED_ABILITY)
from superpilot.core.pilot.task.super import SuperTaskPilot
search_step = SuperTaskPilot(super_ability_registry, model_providers)
Credits: This framework relies on AutoGPT's core library for its underlying functionalities.