A wrapper around Hugging Face's Inference API (written in Python)
from intellecto import Intellecto
client = Intellecto(
access_token="xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
response = client.nlp.generate(
model="microsoft/phi-2",
input='Top 10 programming languages in the world.'
)
Intellecto
has the following properties --
property | description |
---|---|
nlp | A property of type IntellectoNLP that deals with various NLP related tasks |
audio | A property of type IntellectoAudio that deals with various audio related tasks |
vision | A property of type IntellectoVision that deals with various vision related tasks |
IntellectoBase
spawns and holds onto a IntellectoClient
which aids it in sending network requests to Inference API end points.
It receives the following parameters -
parameter | description |
---|---|
model |
A <model-id> as specified on HF's model page |
token |
A <bearer-token> as extracted from HF's console |
IntellectoBase
is extended by the classes mentioned below. They're divided & grouped as per their niche and tasks.
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of IntellectoAPIError
is raised.
When the API returns a non-success status code (that is, 4xx or 5xx response), a subclass of IntellectoAPIStatusError
is raised, containing status_code
.
Error codes are as followed:
Status Code | Error Type |
---|---|
400 | BadRequestError |
401 | AuthenticationError |
403 | PermissionDeniedError |
404 | NotFoundError |
422 | UnprocessableEntityError |
429 | RateLimitError |
5xx | InternalServerError |
N/A | APIConnectionError |
A wrapper around Hugging Face's Inference API (written in Python) with async support
from asyncio import run
from intellecto import AsyncIntellecto
client = AsyncIntellecto(
access_token="xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
async def main() -> None:
response = await client.nlp.client.nlp.generate(
model="microsoft/phi-2",
input='Top 10 programming languages in the world.'
)
run(main())
AsyncIntellecto
has the following properties --
property | description |
---|---|
nlp | A property of type AsyncIntellectoNLP that deals with various NLP related tasks |
audio | A property of type AsyncIntellectoAudio that deals with various audio related tasks |
vision | A property of type AsyncIntellectoVision that deals with various vision related tasks |
AsyncIntellectoBase
spawns and holds onto an AsyncIntellectoClient
which aids it in sending network requests to Inference API end points.
It receives the following parameters -
parameter | description |
---|---|
model |
A <model-id> as specified on HF's model page |
token |
A <bearer-token> as extracted from HF's console |
AsyncIntellectoBase
is extended by the classes mentioned below. They're divided & grouped as per their niche and tasks.