Hi,
I don't understand how to use the Llama classes in Harbour.
In this folder,
c:\users\ID\.ollama\models\manifests\registry.ollama.ai\library\
, I have
dolphin-llama3
llama3
llama3.1
llama3.2
qwen2.5-coder
, but I don't see how these models relate to the .gguf references in the models.ini sample.
e.g. model1=/mnt/diskd/Arhiv/ai/tinyllama-1.1b-1t-openorca.Q5_K_M.gguf
or
model2=C:\Users\SYSADMIN\jan\models\mistral-ins-7b-q4\mistral-7b-instruct-v0.2.Q4_K_M.gguf
I searched in the ollama models folder, and there aren't any .gguf files there.
What are these .gguf files in the llama classes?
-
FWExplorer
- Posts: 115
- Joined: Fri Aug 09, 2013 12:43 am
- Antonio Linares
- Site Admin
- Posts: 44515
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: What are these .gguf files in the llama classes?
Use the Class TOllama
This class superseeds any previous llama.cpp implementations
look for samples\ollama...prg
This class superseeds any previous llama.cpp implementations
look for samples\ollama...prg
-
FWExplorer
- Posts: 115
- Joined: Fri Aug 09, 2013 12:43 am
Re: What are these .gguf files in the llama classes?
Thanks Antonio,
I searched the forum for this class, but couldn't locate it.
I can't find it here, either:
https://github.com/FiveTechSoft/llama/t ... ter/source
I searched the forum for this class, but couldn't locate it.
I can't find it here, either:
https://github.com/FiveTechSoft/llama/t ... ter/source
Antonio Linares wrote: Mon Sep 22, 2025 8:44 pm Use the Class TOllama
This class superseeds any previous llama.cpp implementations
look for samples\ollama...prg
- Antonio Linares
- Site Admin
- Posts: 44515
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: What are these .gguf files in the llama classes?
Class TOllama
tollama.prg
ollama1.prg
tollama.prg
Code: Select all | Expand
// Developed by FiveTech Software, using parts by Charles OhChul
#include "FiveWin.ch"
#include "hbcurl.ch"
//----------------------------------------------------------------------------//
CLASS TOLlama
DATA cModel
DATA cPrompt
DATA cResponse
DATA cUrl
DATA hCurl
DATA nError INIT 0
DATA nHttpCode INIT 0
DATA aAgents
METHOD New( cModel )
METHOD Send( cPrompt )
METHOD SendStream( cPrompt, bWriteFunction )
METHOD SendImage( cImageFileName, cPrompt )
METHOD End()
METHOD GetValue()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cModel ) CLASS TOLlama
DEFAULT cModel := "deepseek-r1:14b"
::cModel = cModel
::cUrl = "http://localhost:11434/api/chat"
::hCurl = curl_easy_init()
return Self
//----------------------------------------------------------------------------//
METHOD End() CLASS TOLlama
curl_easy_cleanup( ::hCurl )
::hCurl = nil
return nil
//----------------------------------------------------------------------------//
METHOD GetValue() CLASS TOLlama
local hResponse, uValue
hb_jsonDecode( ::cResponse, @hResponse )
TRY
uValue = hResponse[ "message" ][ "content" ]
CATCH
uValue = hResponse[ "error" ][ "message" ]
END
return uValue
//----------------------------------------------------------------------------//
METHOD Send( cPrompt ) CLASS TOLlama
local aHeaders, cJson, hRequest := { => }, hMessage := { => }
if ! Empty( cPrompt )
::cPrompt = cPrompt
endif
curl_easy_setopt( ::hCurl, HB_CURLOPT_POST, .T. )
curl_easy_setopt( ::hCurl, HB_CURLOPT_URL, ::cUrl )
aHeaders := { "Content-Type: application/json" }
curl_easy_setopt( ::hCurl, HB_CURLOPT_HTTPHEADER, aHeaders )
curl_easy_setopt( ::hCurl, HB_CURLOPT_USERNAME, '' )
curl_easy_setopt( ::hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( ::hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
hRequest[ "model" ] = ::cModel
hMessage[ "role" ] = "user"
hMessage[ "content" ] = cPrompt
hRequest[ "messages" ] = { hMessage }
hRequest[ "stream" ] = .F.
hRequest[ "temperature" ] = 0.5
cJson = hb_jsonEncode( hRequest )
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 SendStream( cPrompt, bWriteFunction ) CLASS TOLlama
local aHeaders, cJson, hRequest := { => }, hMessage := { => }
curl_easy_setopt( ::hCurl, HB_CURLOPT_POST, .T. )
curl_easy_setopt( ::hCurl, HB_CURLOPT_URL, ::cUrl )
aHeaders := { "Content-Type: application/json" }
curl_easy_setopt( ::hCurl, HB_CURLOPT_HTTPHEADER, aHeaders )
curl_easy_setopt( ::hCurl, HB_CURLOPT_USERNAME, '' )
curl_easy_setopt( ::hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
// Habilitar modo streaming
hRequest[ "model" ] = ::cModel
hMessage[ "role" ] = "user"
hMessage[ "content" ] = cPrompt
hRequest[ "messages" ] = { hMessage }
hRequest[ "stream" ] = .T. // ACTIVAR STREAMING
hRequest[ "temperature" ] = 0.5
cJson = hb_jsonEncode( hRequest )
curl_easy_setopt( ::hCurl, HB_CURLOPT_POSTFIELDS, cJson )
// Configurar la funci├│n de callback para recibir tokens en tiempo real
curl_easy_setopt( ::hCurl, HB_CURLOPT_WRITEFUNCTION, bWriteFunction )
::nError = curl_easy_perform( ::hCurl )
curl_easy_getinfo( ::hCurl, HB_CURLINFO_RESPONSE_CODE, @::nHttpCode )
if ::nError != HB_CURLE_OK
::cResponse := "Error code " + Str( ::nError )
endif
return ::cResponse
//----------------------------------------------------------------------------//
METHOD SendImage( cImageFileName, cPrompt ) CLASS TOLlama
local aHeaders, cJson, cBase64Image, hRequest := {=>}, hMessage := { => }
if ! File( cImageFileName )
MsgAlert( "Image " + cImageFileName + " not found" )
return nil
endif
DEFAULT cPrompt := "What is in this image?"
cBase64Image = hb_base64Encode( memoRead( cImageFileName ) )
curl_easy_setopt( ::hCurl, HB_CURLOPT_POST, .T. )
curl_easy_setopt( ::hCurl, HB_CURLOPT_URL, ::cUrl )
aHeaders := { "Content-Type: application/json" }
curl_easy_setopt( ::hCurl, HB_CURLOPT_HTTPHEADER, aHeaders )
curl_easy_setopt( ::hCurl, HB_CURLOPT_USERNAME, "" )
curl_easy_setopt( ::hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( ::hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
hRequest[ "model" ] = ::cModel
hMessage[ "role" ] = "user"
hMessage[ "content" ] = cPrompt
hMessage[ "images" ] = { cBase64Image }
hRequest[ "messages" ] = { hMessage }
hRequest[ "stream" ] = .F.
cJson := hb_jsonEncode( hRequest )
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
//----------------------------------------------------------------------------//
CLASS TAgent
DATA cCategory
DATA aTools
METHOD New( cCategory, aTools )
ENDCLASS
//----------------------------------------------------------------------------//Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oChat := TOLlama():New( "llama3.2-vision" ) // deepseek-r1:32b"
oChat:Send( "who are you ?" )
? oChat:GetValue()
oChat:End()
return nil -
FWExplorer
- Posts: 115
- Joined: Fri Aug 09, 2013 12:43 am