- class pipableai.llm_client.pipllm.PipLlmApiClient(api_base_url: str)
Bases:
LlmApiClientInterface
A client class for interacting with the Pipable Language Model API.
This class provides methods to communicate with a language model API to generate SQL queries based on contextual information and user queries. It facilitates sending requests to the API and receiving generated SQL queries as responses.
- Args:
api_base_url (str): The base URL of the Language Model API.
- Attributes:
api_base_url (str): The base URL of the Language Model API.
- Example:
To use this client, create an instance of PipLlmApiClient, configure it with the API base URL, and use the generate_text method to generate SQL queries.
from pipable.pip_llm_api_client import PipLlmApiClient # Create a PipLlmApiClient instance llm_api_client = PipLlmApiClient(api_base_url="https://your-llm-api-url.com") # Generate an SQL query based on context and user query context = "CREATE TABLE Employees (ID INT, NAME TEXT);" user_query = "List all employees." generated_query = llm_api_client.generate_text(context, user_query)
- Methods:
generate_text(context: str, question: str) -> str: Generate an SQL query based on context and user query.
- Raises:
requests.exceptions.RequestException: If there is an issue with the API request.
- generate_text(context: str, question: str) str
Generate an SQL query based on contextual information and user query.
- Args:
context (str): The context or CREATE TABLE statements for the query. question (str): The user’s query in simple English.
- Returns:
str: The generated SQL query.
- Raises:
requests.exceptions.RequestException: If there is an issue with the API request.