A lightweight Ollama(no ollama installation needed) based LangChain-compatible LLM bridge ('LLaMA-3.2','CodeLLaMA-Instruct 7B','Gemma-2-Instruct 9B','Mistral 7B Instruct','Qwen-2.5-Coder 7B','Phi-3 Medium (8B)','Falcon 7B Instruct','Baichuan-2-7B','InternLM-Chat-7B','Vicuna 7B') built by Sonu Kumar.
Project description
npmai
npmai (by Sonu Kumar Ramashish) is a lightweight Python package that seamlessly connects you with Ollama and 10 other open-source models without any Installation, Login/Signup or API problems.
🚀 Features
Execute prompts on multiple LLMs simultaneously:["LLaMA-3.2","CodeLLaMA-Instruct 7B","Gemma-2-Instruct 9B","Mistral 7B Instruct","Qwen-2.5-Coder 7B","Phi-3 Medium (8B)","Falcon 7B Instruct","Baichuan-2-7B","InternLM-Chat-7B","Vicuna 7B"]
Fully LangChain,CrewAI and other -compatible interface.
Simple and intuitive invoke() for instant responses.
Support continuous conversation.
Encourages responsible usage.
#For documentation visit:- https://npmai.onrender.com
⚙️ Installation pip install npmai
Tip: For Python 3.13, make sure to use:
py -3.13 -m pip install npmai
💡 How to Use
for Documentation visit:- https://npmai.netlify.app or https://npmai.onrender.com
Basic Examples for Python:-
1.Import npmai Module from npmai import Ollama
Initialize Ollama:
llm = Ollama()
prompts=""
model="llama3.2" #you can keep other also
Invoke a prompt and get the response:
response = llm.invoke(prompts,model) print(response)
#If you want to use npmai through other languages consider hitting this api endpoint:- https://npmai-api.onrender.com
example:- with other languages #Java Script- async function callApi() { const payload = { prompt: "hey my name is sonu kumar what do you think about Narendra Modi", model: "llama3.2", temperature: 0.4, };
const response = await fetch("https://npmai-api.onrender.com/llm", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) });
const data = await response.json(); console.log(data.response); }
callApi();
#C++ #include <httplib.h> #include <nlohmann/json.hpp> #include
int main() { httplib::Client cli("https://npmai-api.onrender.com"); nlohmann::json payload = { {"prompt", "hey my name is sonu kumar what do you think about Narendra Modi"}, {"model", "llama3.2"}, {"temperature", 0.4} };
auto res = cli.Post("/llm", payload.dump(), "application/json");
if (res) {
auto data = nlohmann::json::parse(res->body);
std::cout << data["response"] << std::endl;
}
return 0;
}
#Java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse;
public class Main { public static void main(String[] args) throws Exception { String json = "{"prompt": "hey my name is sonu kumar what do you think about Narendra Modi", "model": "llama3.2", "temperature": 0.4}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://npmai-api.onrender.com/llm"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
// Note: For simple output, print full body; for parsing, use a library like Jackson or Gson
System.out.println(response.body());
}
}
#C #include <stdio.h> #include <curl/curl.h>
int main(void) { CURL *curl = curl_easy_init(); if(curl) { struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: application/json");
const char *data = "{\"prompt\": \"hey my name is sonu kumar what do you think about Narendra Modi\", \"model\": \"llama3.2\", \"temperature\": 0.4}";
curl_easy_setopt(curl, CURLOPT_URL, "https://npmai-api.onrender.com/llm");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
CURLcode res = curl_easy_perform(curl);
if(res != CURLE_OK) fprintf(stderr, "Request failed: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
}
return 0;
}
#Latest Update : version 0.1.2 Here in this version we added Memory concept so that you do not need to define memory concept and no need to rely on Agentic Frameworks for Memory.
⚠️ Important Notes
Designed for educational ,small-scale experimentation, for demo projets and small scale users.
If using at a larger scale, consider supporting the original AI platforms—they invest heavily in research and infrastructure.
use responsibly to help us.
✅ npmai makes it effortless to connect Ollam models with Python, bringing automation, experimentation, and LangChain,Crew AI integration together in a single, easy-to-use package.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file npmai-0.1.2.tar.gz.
File metadata
- Download URL: npmai-0.1.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe38609838f24160be9e2892b1813d3aa4eee6bf50e864a14a14521ef9f69f4c
|
|
| MD5 |
f397d5dd1d4a548ea1f11ff6aa000629
|
|
| BLAKE2b-256 |
3805240c78084419dc1bf5eafaf5bf185a531a10a02e60a996b7fe65cc901c3f
|
File details
Details for the file npmai-0.1.2-py3-none-any.whl.
File metadata
- Download URL: npmai-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94d1907573699024a80aa1626534cb017640d2bb8b15d7dd865a894b7566fe86
|
|
| MD5 |
5d12857cca79337d3136358d34ec667b
|
|
| BLAKE2b-256 |
b6007d39b04fa297123a84552d167b97712f627a332f653a5cd85d235682d551
|