|
Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
|
Ollama driver for the AI unified interface. More...
#include <curl/curl.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "cJSON.h"#include "csilk/drivers/ai.h"
Data Structures | |
| struct | ollama_state_t |
| Per-instance state for the Ollama driver. More... | |
| struct | curl_response |
| Accumulates a complete HTTP response body in memory. More... | |
Functions | |
| static void * | ollama_init (const char *api_key, const char *base_url) |
| Initialize the Ollama driver state. | |
| static void | ollama_free (void *state_ptr) |
| Free the Ollama driver state and associated resources. | |
| static size_t | write_cb (void *contents, size_t size, size_t nmemb, void *userp) |
| libcurl write callback that appends data to a growing buffer. | |
| static int | ollama_chat (void *state_ptr, const csilk_ai_chat_request_t *req, csilk_ai_chat_response_t *res) |
| Execute a chat completion against the Ollama /api/chat endpoint. | |
| static int | ollama_embeddings (void *state_ptr, const char *model, const char **input, size_t count, csilk_ai_embeddings_response_t *res) |
| Generate embeddings via Ollama (stub – not yet implemented). | |
| void | csilk_ai_ollama_init_driver (void) |
| Register the Ollama driver with the AI subsystem. Called during startup to make "ollama" available to csilk_ai_new(). | |
Variables | |
| static const csilk_ai_driver_t | ollama_driver |
| Driver vtable for the Ollama AI backend. | |
Ollama driver for the AI unified interface.
Implements the csilk_ai_driver_t vtable for local LLM inference via Ollama. Key differences from the OpenAI driver:
| struct ollama_state_t |
Per-instance state for the Ollama driver.
| Data Fields | ||
|---|---|---|
| char * | base_url |
Base URL of the Ollama server (e.g., http://localhost:11434). |
| struct curl_response |
Accumulates a complete HTTP response body in memory.
Accumulates a complete HTTP response body (used for embeddings).
| void csilk_ai_ollama_init_driver | ( | void | ) |
Register the Ollama driver with the AI subsystem. Called during startup to make "ollama" available to csilk_ai_new().
|
static |
Execute a chat completion against the Ollama /api/chat endpoint.
Flow:
|
static |
Generate embeddings via Ollama (stub – not yet implemented).
|
static |
Free the Ollama driver state and associated resources.
|
static |
Initialize the Ollama driver state.
|
static |
libcurl write callback that appends data to a growing buffer.
|
static |
Driver vtable for the Ollama AI backend.