llm
LLM-APIs (OpenAI, Gemini, Cloudflare) direkt aus SQL mit Unterstützung für strukturierte Ausgaben aufrufen.
Maintainer: onnimonni
Installation und Laden
INSTALL llm FROM community;LOAD llm;Über llm
Rufen Sie LLM-APIs direkt aus SQL auf, mit Unterstützung für OpenAI, Gemini, Cloudflare Workers AI und lokale OpenAI-kompatible Server.
Funktionen
- Tabellenfunktion
llm()mit Unterstützung für Lateral Join und benannte Parameter - Skalarfunktion
prompt()mit automatischer Erkennung von API-Schlüsseln llm_and_cache()für unmittelbare Antworten mit Zwischenspeicherllm_batch_and_cache()für 50 % günstigere Batch-API-Verarbeitungllm_hash()für LEFT-JOIN-Unterstützung mit zwischengespeicherten Ergebnissen- CREATE-SECRET-Unterstützung für sichere Speicherung von API-Schlüsseln
- Strukturierte Ausgabe mit
return_typeundjson_schema
Beispiele für strukturierte Ausgabe
Ganzzahlige Ausgabe:
SELECT response FROM llm('What is 15 + 27?', provider := 'gemini', model := 'gemini-2.5-flash', return_type := 'INTEGER');-- Returns: {"value":42}Array-Ausgabe:
SELECT response FROM llm('List the first 5 prime numbers.', provider := 'gemini', model := 'gemini-2.5-flash', return_type := 'INTEGER[]');-- Returns: {"value": [2, 3, 5, 7, 11]}Struct-Ausgabe:
SELECT response FROM llm('Info about Paris.', provider := 'gemini', model := 'gemini-2.5-flash', json_schema := '{ "type": "OBJECT", "properties": { "city": {"type": "STRING"}, "country": {"type": "STRING"}, "population": {"type": "INTEGER"} }, "required": ["city", "country", "population"] }');-- Returns: {"city": "Paris", "country": "France", "population": 2140000}Array von Structs:
SELECT response FROM llm('List 3 European capitals.', provider := 'gemini', model := 'gemini-2.5-flash', json_schema := '{ "type": "OBJECT", "properties": { "cities": { "type": "ARRAY", "items": { "type": "OBJECT", "properties": { "name": {"type": "STRING"}, "country": {"type": "STRING"} } } } } }');-- Returns: {"cities": [{"name": "Paris", "country": "France"}, ...]}Weitere Informationen finden Sie in der Dokumentation.
Hinzugefügte Funktionen
Diese Erweiterung fügt keine Funktionen hinzu.
Überladene Funktionen
Diese Erweiterung fügt keine Funktionsüberladungen hinzu.
Hinzugefügte Typen
Diese Erweiterung fügt keine Typen hinzu.
Hinzugefügte Einstellungen
Diese Erweiterung fügt keine Einstellungen hinzu.