Estimados
Por si alguien esta usando modelos para embedding con ollama, pueden agregar estos metodos a tollama
Saludos
Lautaro
Por si alguien esta usando modelos para embedding con ollama, pueden agregar estos metodos a tollama
METHOD SendEmbedding( cPrompt ) CLASS TOLlama
local aHeaders, cJson, hRequest := { => }, hMessage := { => }
// arma el requerimiento
hRequest[ "model" ] = ::cModel
hRequest["input"] := cPrompt
cJson = hb_jsonEncode( hRequest )
aHeaders := { "Content-Type: application/json" }
curl_easy_setopt( ::hCurl, HB_CURLOPT_POST, .T. )
// setea el endpoint a llamar , ojo es distinto a los otros
curl_easy_setopt( ::hCurl, HB_CURLOPT_URL, "http://localhost:11434/api/embed" )
curl_easy_setopt( ::hCurl, HB_CURLOPT_HTTPHEADER, aHeaders )
curl_easy_setopt( ::hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( ::hCurl, HB_CURLOPT_POSTFIELDS, cJson )
::nError = curl_easy_perform( ::hCurl )
curl_easy_getinfo( ::hCurl, HB_CURLINFO_RESPONSE_CODE, @::nHttpCode )
if ::nError == HB_CURLE_OK
::cResponse = curl_easy_dl_buff_get( ::hCurl )
else
::cResponse := "Error code " + Str( ::nError )
endif
return ::cResponse
//----------------------------------------------------------------------------//
METHOD GetValueEmbedding() CLASS TOLlama
local hResponse, uValue
hb_jsonDecode( ::cResponse, @hResponse )
TRY
uValue = hResponse[ "embeddings" ]
CATCH
uValue = hResponse[ "error" ][ "message" ]
END
return uValueLautaro
Hola,
Soy un Contador que por necesidad aprendio a programar y se quedo programando.
Soy un Contador que por necesidad aprendio a programar y se quedo programando.