ai
Работа с AI агентами
new(ai_type, addr, params)
Создает клиент для взаимодействия с конкретным AI агенту
Параметры
# | Тип | Описание |
---|---|---|
1 | строка | тип |
2 | строка | строка подключения |
3 | таблица | параметры |
Пример
local ai = require("ai")
local sess, err = ai.new("deepseek", "", {timeout="5m", key="sk-1234567"})
-- sess, err = ai.new("ollama", "http://192.168.1.2:11434/", {timeout="5m"})
Пример #2
local inspect = require("inspect")
local ai = require("ai")
local sess, err = ai.new("openai", "https://openrouter.ai/api/v1/", {timeout="1m", key="sk-xxx"})
if err ~= nil then error(err) end
response,err = sess:generate("google/gemma-3-27b-it:free", "Расскажи анекдот")
if err ~= nil then error(err) end
print(response)