Promptic - A lightweight LLM application development framework that allows you to switch between different LLMs with a single line of code.
Promptic is a lightweight LLM application development framework that provides an efficient and Python-style development approach. Based on LiteLLM, Promptic allows developers to easily switch between different LLM service providers with just a single line of code change...
What is Promptic?
Promptic is a lightweight LLM application development framework that provides an efficient and Python-style development approach. Based on LiteLLM, Promptic allows developers to easily switch between different LLM service providers with just a single line of code change. Promptic supports streaming responses, built-in conversation memory, error handling and retries, and scalable state management. It helps developers focus on building functionality rather than underlying complexity. Promptic's flexibility and ease of use make it a powerful tool in the LLM development field.
Promptic's main functions
- Type-safe outputUsing the Pydantic model ensures that the data structure returned by the LLM meets expectations, improving code robustness.
- Proxy buildingCreate utility functions that can be called by LLM to implement complex task decomposition.
- Streaming supportSupports real-time response generation, suitable for long content or interactive application scenarios.
- Built-in conversation memoryIt supports LLM in maintaining context across multiple interactions, enhancing the user experience.
- Error handling and retriesIt provides error handling mechanisms and automatic retry functions to enhance the stability and reliability of applications.
The technical principles of Promptic
- LiteLLM IntegrationBuilt on LiteLLM, a lightweight LLM client library that abstracts the APIs of different LLM providers.
- Decorator patternExtend function functionality using Python decorators, such as
@llmand@llm.toolNo need to modify the function's internal code to add new behavior. - Dynamic prompt generation: Dynamically combine the function's docstring with the actual parameters to generate a prompt, which is then sent to the LLM for processing.
- Response verificationThe response of LLM is validated based on the Pydantic model to ensure the correctness and integrity of the data.
- State Management:based on
StateThis class manages the dialogue state, supports dialogue memory functionality, and allows developers to customize storage solutions.
Promptic's project address
- Project official website:pypi.org/project/promptic
- GitHub repository:https://github.com/knowsuchagency/promptic
Application scenarios of Promptic
- ChatbotBuild intelligent chatbots to engage in natural language conversations with users and provide customer service or information retrieval.
- Content generationAutomatically generate articles, stories, poems, or other creative writing content.
- Language translationTo provide real-time language translation services and help users overcome language barriers.
- Sentiment AnalysisAnalyze the sentiment of customer feedback, comments, or social media posts to improve customer service and product development.
- Data SummaryGenerate short summaries for long articles or reports, saving users reading time.