\TinyOllama
Minimalist ollama REST API implementation https://github.com/ollama/ollama/blob/main/docs/api.md
Synopsis
class TinyOllama
{
- // members
- protected $api = '';
- protected string $proto = 'http';
- protected string $host = 'localhost';
- protected integer $port = 11434;
- protected bool $streamingFlag = false;
- protected string $model = '';
- protected string $baseUrl = '';
- protected bool|int $temperature = false;
- // methods
- public void __construct()
- protected void initApi()
- public void setHost()
- public void setPort()
- public void setModel()
- public void setBaseUrl()
- public void setTemperature()
- public array ps()
- public array listmodels()
- public array|string generate()
- public array chat()
- public array|string chatWithImages()
- public array|string generateImage()
- protected array prepareChatImages()
- protected string prepareSingleImage()
Members
protected
- $api
—
HTTP API abstraction layer - $baseUrl
—
string
Base URL which will be used as endpoint prefix - $host
—
string
Remote API interaction host - $model
—
string
Request model name - $port
—
string
Remote API interaction port - $proto
—
string
Remote API interraction protocol - $streamingFlag
—
bool
Response live-streaming flag - $temperature
—
bool|int
Request temperature
Methods
protected
- initApi() — Initializes the API by creating a new instance of the OmaeUrl class
- prepareChatImages() — Prepares an array of images for chat request payload.
- prepareSingleImage() — Converts single image source into base64 payload item.
public
- __construct() — Creates new TinyOllama instance
- chat() — Sends a chat message to the API.
- chatWithImages() — Sends a chat message with optional images to the API.
- generate() — Generates a response based on the given prompt.
- generateImage() — Generates image using selected model via /api/generate endpoint.
- listmodels() — Returns list of available local models
- ps() — Returns list of running models
- setBaseUrl() — Set the value for baseUrl
- setHost() — Set the value of host
- setModel() — Set the value of model name for instance
- setPort() — Set the value of port
- setTemperature() — Set the value of the instance generation temperature