View in color | View documentation | View discussion [12 posts] | License |
Download script | History | Other scripts by: sergey |
18-Feb 14:24 UTC
[0.061] 13.204k
[0.061] 13.204k
ai-geteway.r;; ===================================================
;; Script: ai-geteway.r
;; downloaded from: www.REBOL.org
;; on: 21-Nov-2024
;; at: 3:12:49.521369 UTC
;; owner: sergey [script library member who can update
;; this script]
;; ===================================================
;; ===============================================
;; email address(es) have been munged to protect
;; them from spam harvesters.
;; If you were logged on the email addresses would
;; not be munged
;; ===============================================
REBOL [
title: "Gateway for request to AI"
File: %ai-geteway.r
Date: 26-08-2024
Version: 0.0.4
Author: "Sergey Pochinok"
Purpose: "A function that makes an AI request via the Internet and returns a response."
EMail: [%pochinok--bk--ru]
History: [
0.0.1 [30-06-2024 "Started"]
0.0.2 [10-07-2024 "The update includes two new AI models"]
0.0.3 [26-08-2024 "Four AI models were added"]
0.0.4 [21-11-2024 "added Image generationn"]
]
Category: [info]
library: [
level: 'intermediate
platform: 'all
type: 'function
domain: [ai text text-processing internet]
tested-under: [core & view 2.7.8.3.1 win & linux]
support: none
license: 'BSD
see-also: none
]
]
ai: func [
"Text request to AI. Default uses Phind model"
request [string!] "request text"
/blackboxai "uses BlackBox model"
/koboldai "uses koboldcpp/HF_SPACE_Tiefighter-13B only, answers from novels"
/gpt "uses gpt-4o-mini"
/meta "uses meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"
/mixtral "uses mistralai/Mixtral-8x7B-Instruct-v0.1"
/claude "uses claude-3-haiku-20240307"
/image "кeturns the generated image"
] [
if all [blackboxai koboldai gpt meta mixtral claude image] [return "ERROR! Using both parameters at the same time will result in a conflict."]
url: copy http://pochinoksergey.ru/rebol/ai/
if blackboxai [url: copy http://pochinoksergey.ru/rebol/ai/?p=blackboxai]
if koboldai [url: copy http://pochinoksergey.ru/rebol/ai/?p=koboldai]
if gpt [url: copy http://pochinoksergey.ru/rebol/ai/?p=gpt]
if meta [url: copy http://pochinoksergey.ru/rebol/ai/?p=meta]
if mixtral [url: copy http://pochinoksergey.ru/rebol/ai/?p=mixtral]
if claude [url: copy http://pochinoksergey.ru/rebol/ai/?p=claude]
if image [url: copy http://pochinoksergey.ru/rebol/ai/?p=image]
if/else NOT image [return first parse/all read/custom url reduce ['post append copy "q=" request] "^(null)"]
[return load append url append copy "&q=" request]
]
; simple example of using the function
;print ai "Tell me about yourself."
;view layout[image ai/image "sport car"]
;halt Notes
|