Script Library: 1240 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Archive version of: ai-geteway.r ... version: 2 ... sergey 10-Jul

Amendment note: The update includes two new AI models || Publicly available? Yes

REBOL [
    title: "Gateway for request to AI"
    File: %ai-geteway.r
    Date: 30-06-2024
    Version: 0.0.1
    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"]
    ]
    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"
	
] [ 
	if all [blackboxai koboldai] [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]
	return first parse/all read/custom url reduce ['post append copy "q=" request] "^(null)" 
]

; simple example of using the function
print ai "Hi. Tell us about yourself and the Rebol language"
halt
Notes