Welcome to the world of AI-powered language models! In this article, we’ll explore how to use SimplerLLM, an open-source Python library that simplifies interactions with Large Language Models (LLMs) for both researchers and beginners. If you’re looking to dive into AI development without getting lost in a sea of complexities, you’re in the right place!
What is SimplerLLM?
SimplerLLM provides a unified interface for various LLM providers, making it super easy to develop AI-powered tools and applications. Whether you’re working with OpenAI or Google Gemini, you can streamline your workflow with this remarkable library.
Easy Installation
Getting started with SimplerLLM is a breeze. Just use pip to install it:
pip install simplerllm
Features of SimplerLLM
- Unified LLM Interface: Set up an LLM instance in a single line for different providers.
- Generic Text Loader: Load text effortlessly from various formats including DOCX, PDF, or even YouTube scripts.
- RapidAPI Connector: Easily connect with multiple AI services.
- SERP Integration: Perform searches using DuckDuckGo.
- Prompt Template Builder: Create and manage prompts with ease.
Setting Up Environment Variables
To protect your API keys, it’s essential to set environment variables. Create a .env file in your project’s root directory and include your API keys. Here’s what it should look like:
OPENAI_API_KEY=your_openai_api_key_here
GEMENI_API_KEY=your_gemeni_api_key_here
CLAUDE_API_KEY=your_claude_api_key_here
RAPIDAPI_API_KEY=your_rapidapi_key_here
VALUE_SERP_API_KEY=your_value_serp_api_key_here
SERPER_API_KEY=your_serper_api_key_here
STABILITY_API_KEY=your_stability_api_key_here
Creating an LLM Instance
Creating an LLM instance is as simple as pie. Let’s say you want to bake a cake; you would gather your ingredients. In programming, your ingredients are just the right code:
from SimplerLLM.language.llm import LLM, LLMProvider
# For OpenAI
llm_instance = LLM.create(provider=LLMProvider.OPENAI, model_name='gpt-3.5-turbo')
# For Google Gemini
# llm_instance = LLM.create(provider=LLMProvider.GEMINI, model_name='gemini-pro')
# For Anthropic Claude
# llm_instance = LLM.create(LLMProvider.ANTHROPIC, model_name='claude-3-opus-20240229')
response = llm_instance.generate_response(prompt='generate a 5 words sentence')
In this analogy, choosing the right model is like selecting the best recipe for your cake. Once you’ve done that, just run the code and voilà! You’ve generated content.
Using Tools
SimplerLLM isn’t just for generating text; it’s packed with tools to enhance your capabilities:
SERP
from SimplerLLM.tools.serp import search_with_serper_api
search_results = search_with_serper_api(your_search_query, num_results=3)
# Use the search results however you want!
Generic Text Loader
from SimplerLLM.tools.generic_loader import load_content
text_file = load_content('file.txt')
print(text_file.content)
Calling any RapidAPI API
from SimplerLLM.tools.rapid_api import RapidAPIClient
api_url = 'https://domain-authority1.p.rapidapi.com/seo/get-domain-info'
api_params = {'domain': 'learnwithhasan.com'}
api_client = RapidAPIClient() # API key read from environment variable
response = api_client.call_api(api_url, method='GET', params=api_params)
Prompt Template Builder
from SimplerLLM.prompts.prompt_builder import create_multi_value_prompts, create_prompt_template
basic_prompt = 'Generate 5 titles for a blog about [topic] and [style]'
prompt_template = create_prompt_template(basic_prompt)
prompt_template.assign_parms(topic='marketing', style='catchy')
print(prompt_template.content)
Chunking Functions
Simplifying text is now a piece of cake with chunking functions that can segment text based on various criteria:
from SimplerLLM.tools import text_chunker as chunker
blog_url = 'https://www.semrush.com/blog/digital-marketing'
blog_post = loader.load_content(blog_url)
text = blog_post.content
chunks = chunker.chunk_by_max_chunk_size(text, 100, True)
Next Updates
Stay tuned for exciting updates that will further enrich your experience with SimplerLLM, including:
- More tools
- Local LLM interactions
- Integration with vector databases
- Agent Builder
Troubleshooting
If you encounter any issues during installation or while setting up, here are some troubleshooting tips:
- Check your API keys: Ensure that the API keys in your
.envfile are correct and your file is in the root directory. - Missing Dependencies: If you receive an error regarding missing packages, try reinstalling or checking your Python environment.
- Connection Issues: Verify your internet connection when trying to interact with APIs.
- If problems persist, consider reaching out to platforms like **[fxis.ai](https://fxis.ai/edu)** for further support.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
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.

