A package for natural language interpretation to structured commands or actions
This package interprets user-submitted text descriptions and converts them into structured commands or actions for devices, home automation scripts, and other applications. It utilizes pattern matching with language models to translate natural language inputs into executable instructions.
pip install nl2actionfrom nl2action import nl2action
response = nl2action("user_input_text")user_input: The user-submitted text to processllm: The langchain llm instance to use (optional, defaults toChatLLM7withLLM7_API_KEY)api_key: The API key for LLM7 (optional, default is environment variableLLM7_API_KEYorNone)
from langchain_openai import ChatOpenAI
from nl2action import nl2action
llm = ChatOpenAI()
response = nl2action(user_input, llm=llm)from langchain_anthropic import ChatAnthropic
from nl2action import nl2action
llm = ChatAnthropic()
response = nl2action(user_input, llm=llm)from langchain_google_genai import ChatGoogleGenerativeAI
from nl2action import nl2action
llm = ChatGoogleGenerativeAI()
response = nl2action(user_input, llm=llm)LLM7_API_KEY: Set to use a custom API key for LLM7, orNonefor the free tier
- Get a free API key at https://token.llm7.io/
- For higher rate limits, set the
LLM7_API_KEYenvironment variable or pass it directly to thenl2actionfunction
https://github.com/chigwell/ nl2action