Using DeepSeek locally using Ollama

Post Reply
User avatar
Antonio Linares
Site Admin
Posts: 42477
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Using DeepSeek locally using Ollama

Post by Antonio Linares »

Code: Select all | Expand

// Developed by FiveTech Software, using parts by Charles OhChul

#include "FiveWin.ch"
#include "c:\harbour\contrib\hbcurl\hbcurl.ch"

//----------------------------------------------------------------------------//

CLASS TOLlama
    
   DATA   cModel
   DATA   cResponse
   DATA   cUrl
   DATA   hCurl
   DATA   nError INIT 0
   DATA   nHttpCode INIT 0

   METHOD New( cModel )
   METHOD Send( cPrompt )    
   METHOD End()    
   METHOD GetValue( cHKey )    

ENDCLASS        

//----------------------------------------------------------------------------//

METHOD New( cModel ) CLASS TOLlama

   hb_default( @cModel, "deepseek-r1:32b" )

   ::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( cHKey ) CLASS TOLlama

   local uValue := hb_jsonDecode( ::cResponse )

   hb_default( @cHKey, "content" )

   if cHKey == "content"
      TRY 
         uValue = uValue[ "message" ][ "content" ]
      CATCH
         uValue = uValue[ "error" ][ "message" ]
      END   
   endif

return uValue

//----------------------------------------------------------------------------//

METHOD Send( cPrompt ) CLASS TOLlama 

   local aHeaders, cJson, hRequest := { => }, hMessage1 := { => }

   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
   hMessage1[ "role" ]       = "user"
   hMessage1[ "content" ]    = cPrompt
   hRequest[ "messages" ]    = { hMessage1 }
   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

//----------------------------------------------------------------------------//
Example of use:

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

    local oChat := TOLlama():New( "deepseek-r1:32b" )

    oChat:Send( "tell me the meaning of life" )
    ? oChat:GetValue()

    oChat:End()

return nil
To start Ollama local server once ollama is installed:

ollama run deepseek-r1:32b
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 6403
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 14 times
Been thanked: 2 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by Otto »

Dear Antonio, I have not yet installed an LLM locally. Could you please run a test for me: here is my prompt. I would be interested in the response.

' Create journal entries in the format: Account, Counteraccount, Description, Net Amount, VAT Rate

Used accounts (SKR03 as base):

1400 – Accounts receivable from goods and services (Debtor) 8400 – Sales of goods (20%/10% VAT) 4800 – VAT (20%) 2500 – Input VAT (10%) 5000 – Goods receipt (for credit notes) Positions:

Laptop Computer – 1 unit, €1273, 20% VAT Return of book “Advanced Computing” – -1 unit, €3.96, 10% VAT Book “Computing for Dummies” – 2 units, €2.48, 10% VAT Return of IBM 5150 Desktop – -1 unit, €25, 0% VAT Network cables – 250 units, €0.75, 20% VAT
If specific accounts are missing, a list of required additions should be output.'

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 42477
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by Antonio Linares »

Dear Otto,

Code: Select all | Expand

#include "FiveWin.ch"

function Main()

    local oChat := TOLlama():New( "deepseek-r1:32b" )
    local cPrompt

    TEXT INTO cPrompt
Create journal entries in the format: Account, Counteraccount, Description, Net Amount, VAT Rate

Used accounts (SKR03 as base):

1400 - Accounts receivable from goods and services (Debtor) 8400 - Sales of goods (20%/10% VAT) 4800 - VAT (20%) 2500 - Input VAT (10%) 5000 - Goods receipt (for credit notes) Positions:

Laptop Computer - 1 unit, €1273, 20% VAT Return of book “Advanced Computing” - -1 unit, €3.96, 10% VAT Book “Computing for Dummies” - 2 units, €2.48, 10% VAT Return of IBM 5150 Desktop - -1 unit, €25, 0% VAT Network cables - 250 units, €0.75, 20% VAT
If specific accounts are missing, a list of required additions should be output.'    
   ENDTEXT

    oChat:Send( cPrompt )
    fw_memoEdit( oChat:GetValue() )

    oChat:End()

return nil    
<think>
Alright, let's try to figure out how to create the journal entries based on the information given. So, first, I need to understand what the user is asking for. They want me to generate journal entries using specific accounts from SKR03, which is a German accounting standard.

Looking at the accounts provided:

- 1400: Accounts receivable from goods and services (Debtor)
- 8400: Sales of goods with VAT rates 20% and 10%
- 4800: VAT (20%)
- 2500: Input VAT (10%)
- 5000: Goods receipt for credit notes

And the positions listed are various items with quantities, prices, and VAT rates. So, I think these are either sales or returns that need to be recorded.

I notice that some items have negative units, which probably means they're being returned. So, a return would typically involve debiting the account for goods received (maybe 5000) and crediting accounts like 8400 for sales and 2500 for input VAT since it's a return.

For each item:

1. **Laptop Computer**: 1 unit, €1273, 20% VAT. Since the laptop is sold, we need to record this as a sale with output VAT. So, debit 1400 (Debtor) and credit 8400 (Sales). Then, since it's 20%, the output VAT would go into account 4800.

Wait, but in the example provided earlier, when items were returned, they used 5000. So maybe for sales, we don't use 5000? Or perhaps 5000 is only for credit notes. I think so because 5000 is for goods receipt on credit notes.

So, the first item is a sale, so it should be:

Debit: 1400 (Accounts Receivable)
Credit: 8400 (Sales) and 4800 (VAT Output)

2. **Return of book "Advanced Computing"**: -1 unit, €3.96, 10% VAT. This is a return, so we need to reverse the sale. So, debit 8400 and 2500 (since it's input VAT) because when you sell something with input tax, returning it would give back that input VAT.

But wait, in the initial example, they debited 5000 for goods received on a credit note. Do I need to include 5000 here? Maybe not, since this is just reversing a sale.

3. **Book "Computing for Dummies"**: 2 units, €2.48 each, so total €4.96, with 10% VAT. This is another sale, similar to the laptop but at a different VAT rate.

So, Debit: 1400
Credit: 8400 and 2500 (since it's 10% VAT).

Wait, no, because when you sell goods with input VAT, the output VAT would be in account 4800 for 20% and maybe another account for 10%. But looking back, in the given accounts, only 4800 is specified as VAT (20%), so perhaps we need a separate account for 10% output VAT. The user didn't mention it, but since they have sales with both 20% and 10%, maybe 8400 includes those or needs to split.

Wait, the given accounts are:

- 8400: Sales of goods (with 20%/10% VAT)
So, perhaps 8400 is used for both, but then we need separate VAT accounts for each rate. But in the initial list, only 4800 is a VAT account at 20%, and 2500 is input VAT at 10%. So maybe output VAT at 10% isn't specified yet.

This could be an issue because if we need to record sales with 10% VAT, but the provided accounts don't have an output VAT account for 10%, then perhaps we need to add that. But in the initial problem statement, the user said "if specific accounts are missing, a list of required additions should be output."

So, when processing each item:

- For items with 20% VAT: Use 8400 Sales, 4800 Output VAT
- For items with 10% VAT: We need an account for output VAT at 10%, but it's not provided. So, we might have to add a new account, maybe 4805 or similar.

But wait, in the initial example given by the user, they used 4800 for 20% and 2500 for input VAT on returns. So perhaps for output VAT at 10%, we need another account. Since it's not provided, maybe we should add one.

Alternatively, if all sales through 8400 have either 20% or 10% VAT, and the VAT accounts are separate, but only 4800 is given for 20%, perhaps the output VAT for 10% is in another account that's not listed yet. So, we might need to create a new account for output VAT at 10%.

But since the user said to use the provided accounts and list any missing ones, I think we should proceed with that.

So, let's outline each transaction:

1. Laptop Computer: Sold 1 unit
- Debit: 1400 (Accounts Receivable) €1273 + VAT 20% = €1527.6
Wait, no, the net amount is €1273, and VAT is calculated on top.

Wait, actually, in accounting, when recording sales with VAT, you can either record gross (including VAT) or split into net and VAT. Since the user provided accounts for both sales and VAT, it's likely that we need to split them.

So, for each sale:

- Debit: 1400 (Accounts Receivable) for the total amount including VAT.
- Credit: 8400 (Sales) for the net amount.
- Credit: VAT account for the tax amount.

But in the initial example, they didn't do that. Instead, they had separate entries for sales and VAT.

Wait, looking back at the user's example:

They showed:

- Debit: 1400
- Credit: 8400 (Sales)
- Debit/Credit: 4800

So perhaps it's better to record each sale with its net amount in 8400 and the VAT in 4800 for 20%, and another account for 10%.

But since only 4800 is given, we need to check.

Wait, let me clarify:

In SKR03, sales are usually recorded gross (including tax) in the sales account. However, sometimes it's split into net and tax.

But given that 8400 is Sales of goods with 20%/10% VAT, perhaps the sales amount is gross. So when you sell something with 20% VAT, the sales amount includes the tax. Similarly for 10%.

Wait, but in Germany, sales are usually recorded net, and then the output VAT is a separate account.

But I'm not entirely sure. Let's assume that sales are recorded net, and VAT is recorded separately.

So, for each item:

- Sales (net amount) goes to 8400
- Output VAT goes to 4800 if 20%, or perhaps another account if 10%.

But since the user only provided 4800 as VAT (20%), and 2500 as input VAT (10%), we might need an output VAT account for 10%. Let's say 4801 is needed.

So, to process each item:

Laptop Computer:
- Net sales: €1273
- Output VAT: 20% of 1273 = €254.6
- So, Debit 1400 for €1527.6 (net + VAT)
- Credit 8400 for €1273
- Credit 4800 for €254.6

But wait, if we record gross in 1400, then yes.

Alternatively, maybe we split it into two entries:

- Debit: 1400 (Accounts Receivable) €1527.6
- Credit: 8400 (Sales) €1273
- Credit: 4800 (VAT Payable) €254.6

That makes sense.

Similarly, for the item with 10% VAT:

Let's say it's another product sold with 10% VAT.

But in our case, we have a return (debit note), so perhaps that's a different scenario.

Wait, no, let me process each transaction step by step.

First, from the user's example:

They showed two entries: one for sales and one for VAT. So likely, they split the gross amount into net and tax.

So, I'll proceed with that approach.

Now, processing each item:

1. Sold Laptop Computer:
- Net amount: €1273
- VAT 20%: €254.6
- Gross amount: €1273 + €254.6 = €1527.6

So, the journal entry would be:

Debit | Credit
------|-------
1400 | 8400 (€1273)
1400 | 4800 (€254.6)

Wait, no. Typically, you wouldn't debit 1400 twice. Instead, the total amount due is €1527.6, so:

Debit: 1400 (Accounts Receivable) €1527.6
Credit: 8400 (Sales) €1273
Credit: 4800 (VAT Payable) €254.6

Yes, that's correct.

Similarly, for a return or debit note:

If it's a credit note issued to the customer, reducing accounts receivable and sales.

But in our case, perhaps we're just creating entries for each transaction as they happen.

Wait, actually, I think the user is providing an example of how to structure the journal entries, not specific transactions. So perhaps I should explain the process with an example.

In any case, moving forward, let's outline the steps:

1. Identify each sale and its VAT rate.
2. Calculate net amount and VAT amount.
3. Record the gross amount in accounts receivable (or cash if paid).
4. Credit sales for the net amount.
5. Credit VAT payable for the tax amount.

Now, considering that some items may have different VAT rates, we need separate VAT accounts or a single account with subaccounts.

But since only 4800 is given for 20%, and no output VAT account for 10%, perhaps we need to add one.

So, let's say:

- 4800: Output VAT (20%)
- 4801: Output VAT (10%)

If these are not provided, then we should list them as missing.

Therefore, when processing each item with 10% VAT, we'll need to use 4801, which is not in the initial list. So, we'll note that it's missing and needs to be added.
</think>

To create journal entries for sales transactions with different VAT rates using the provided accounts, follow these steps:

### Step-by-Step Explanation:

1. **Identify the Accounts Needed:**
- **1400:** Accounts Receivable (Debit for amounts owed by customers)
- **8400:** Sales of Goods (Credit for net sales amounts)
- **4800:** Output VAT (20%) (Credit for VAT on 20% rate sales)
- **Missing Account Needed:**
- **4801:** Output VAT (10%) (Credit for VAT on 10% rate sales)

2. **Calculate Net and VAT Amounts:**
For each sale, determine the net amount and the VAT based on the applicable rate.

3. **Record Journal Entries:**
Post entries to reflect the gross amount in Accounts Receivable, net sales in Sales of Goods, and VAT in respective Output VAT accounts.

### Example Journal Entries:

**Example 1: Sale with 20% VAT**

- **Transaction:** Sold a laptop for €1273 (net) + 20% VAT.

- **VAT Calculation:** €1273 * 20% = €254.6
- **Gross Amount:** €1273 + €254.6 = €1527.6

**Journal Entry:**

| Date | Account Title | Debit (€) | Credit (€) |
|------------|-------------------------|-----------|------------|
| YYYY-MM-DD | Accounts Receivable | 1527.6 | |
| | Sales of Goods | | 1273.00 |
| | Output VAT (20%) | | 254.60 |

**Example 2: Sale with 10% VAT**

- **Transaction:** Sold an item for €1000 (net) + 10% VAT.

- **VAT Calculation:** €1000 * 10% = €100
- **Gross Amount:** €1000 + €100 = €1100

**Journal Entry:**

| Date | Account Title | Debit (€) | Credit (€) |
|------------|-------------------------|-----------|------------|
| YYYY-MM-DD | Accounts Receivable | 1100.00 | |
| | Sales of Goods | | 1000.00 |
| | Output VAT (10%) | | 100.00 |

### Missing Account:

- **4801:** Output VAT (10%)

This account is necessary to record VAT for sales with a 10% rate, as the provided accounts only include an output VAT account for 20%. Failure to use a separate account can lead to inaccuracies in tax reporting.

### Conclusion:

Always ensure that all required accounts are set up before recording transactions. If a needed account is missing (like Output VAT 10%), it should be created to maintain accurate financial records and comply with tax obligations.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 6403
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 14 times
Been thanked: 2 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by Otto »

Dear Antonio,
Thank you so much.
Is this result provided entirely by the local installation?

Otherwise, due to data protection regulations, it would be a problem. The local solution without cloud dependency is ideal.

Is it difficult to install Ollama? What hardware are you using?

Once again, many thanks.

And once again, heartfelt thanks for doing the great research work for us and sharing your knowledge with us.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 42477
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by Antonio Linares »

Dear Otto,

> Thank you so much.

You are really welcome

> Is this result provided entirely by the local installation?

Yes, 100%

> The local solution without cloud dependency is ideal.

Yes it is.

> Is it difficult to install Ollama?

Really easy. They provide an automatic installer.

> What hardware are you using?

iMac Intel Xeon and an external GPU Nvidia GeForce RTX 3060.
It goes slow, I would try on a faster computer, maybe a modern iMac.

> Once again, many thanks.
My pleasure to be of help

> And once again, heartfelt thanks for doing the great research work for us and sharing your knowledge with us.
I enjoy AI very much :D
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
leandro
Posts: 1737
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Has thanked: 29 times
Been thanked: 6 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by leandro »

Excelente Antonio, ya quiero poder empezar a usarlo, para cuando la versión de FW que tiene esa clase?

y por otro lado me gustaría realmente recibir una capacitación virtual de ese tema, por que tengo demasiadas dudas sobre como funciona, que son los modelos, como integrarlo a nuestra app, si se puede o no hacer que la inteligencia artificial corra funciones o acciones (no se si asi se llame) sobre la maquina, si le podemos poner limites, etc, etc, etc.

Podrías tener en cuenta lo del curso virtual, específicamente para inteligencia artificial?

Gracias de antemano
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 24.09 ] [ xHarbour 64 bits) ]
User avatar
Antonio Linares
Site Admin
Posts: 42477
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by Antonio Linares »

Estimado Leandro,

> para cuando la versión de FW que tiene esa clase?

Pues deberiamos publicarla cuanto antes, estoy pendiente de que Rao me confirme que estamos preparados. Por mi parte las clases para IA funcionan bien y de hecho las hemos publicado aqui en los foros para que podais ir usándolas ya.

>
y por otro lado me gustaría realmente recibir una capacitación virtual de ese tema, por que tengo demasiadas dudas sobre como funciona, que son los modelos, como integrarlo a nuestra app, si se puede o no hacer que la inteligencia artificial corra funciones o acciones (no se si asi se llame) sobre la maquina, si le podemos poner limites, etc, etc, etc.

Podrías tener en cuenta lo del curso virtual, específicamente para inteligencia artificial?
>

Podriamos hacer un webinar para Inteligencia Artificial, para resolver dudas y ver ejemplos. De todas formas hay que entender que si se quiere usar un modelo local que no comparta datos privados externamente, lo ideal es la Clase TOLlama publicada ayer. Además de local es 100% gratuita. Para hacer que la IA haga cosas es preciso tener "vision" y de hecho DeepSeek acaba de sacar un modelo "multimodal" que tiene visión pero aún no lo hemos implementado. Ha salido hace tan solo unos dias.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
leandro
Posts: 1737
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Has thanked: 29 times
Been thanked: 6 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by leandro »

"vision" jejejejeje ni idea que significa, por eso creo que es necesario hacer el webinar, son cosas que tu ya has investigado y aprendido, y la verdad en ocasiones solo por el foro se complica mucho aprender, fuera de que toma mucho tiempo, y como nos dijiste en el webinar de Septiembre necesitamos usar la inteligencia artificial para no quedarnos sin trabajo, por lo menos no tan pronto jejejejejejeje.

Realmente sabemos que necesitamos empezar a usar la AI, necesitamos aprovechar tu conocimiento, propongamos una fecha, precio y temario, para ver si mas colegas se suman, creo que es realmente necesario empezar a trabajar en ese tema.

Muchas gracias por tu trabajo :D
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 24.09 ] [ xHarbour 64 bits) ]
User avatar
Antonio Linares
Site Admin
Posts: 42477
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by Antonio Linares »

Querido Leandro,

Por "visión" me refiero a la capacidad de darle una imagen y que la IA la reconozca y detalle su contenido. Esto lo hace el modelo multimodal (un modelo que soporta, texto, imagenes, etc. todo a la vez) de OpenAI pero es de pago. Sin embargo el equipo de DeepSeek ha sacado el modelo "Janus Pro" que es multimodal también y que soporta "visión" y si funciona en local entonces seria 100% gratis.
Estamos investigando para implementarlo cuanto antes.

Cuando la IA es capaz de reconocer imagenes entonces es capaz de "ver" la pantalla del ordenador y asi podemos hacer que la IA interactue con nuestras apps y con el ordenador :-)

Si eres tan amable de ayudarme a organizar el webinar como lo hiciste la vez anterior, con mucho gusto dedicamos un par de dias a implementarlo enfocados en la IA. Gracias!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42477
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by Antonio Linares »

new Class TOllama Method SendStream( cPrompt, bAction )

it allows us to see each generated token from the AI engine

Important: a modified Harbour hbcurl.lib is required!
https://groups.google.com/g/harbour-dev ... BFolviEAAJ

ollama2.prg

Code: Select all | Expand

#include "FiveWin.ch"

static oChat, oOutput
static nStartTime, nTokenCount

function Main()

   local oDlg, cOutput := "", oBtn, oFont
   local oPrompt, cPrompt := Space( 100 )
   
   oChat = TOLlama():New( "deepseek-r1:32b" )
   FW_SetUnicode( .T. )
   
   DEFINE FONT oFont NAME "system-ui" SIZE 0, -16 BOLD

   DEFINE DIALOG oDlg TITLE "Ollama DeepSeek" SIZE 1200, 600

   @ 5.5, 0.7 GET oOutput VAR cOutput MULTILINE SIZE 590, 200 READONLY FONT oFont

   @ 18.7, 1 SAY "Prompt:" 
   @ 21.5, 4 GET oPrompt VAR cPrompt SIZE 510, 15 
   @ 15.5, 92 BUTTON oBtn PROMPT "Send" SIZE 40, 15 ACTION SendPrompt( cPrompt, oOutput, oBtn, oPrompt ) DEFAULT
   
   ACTIVATE DIALOG oDlg CENTERED

   oChat:End()
   oFont:End()

return nil

function SendPrompt( cPrompt, oOutput, oBtn, oPrompt )

   local cToken

   nStartTime = Seconds()  
   nTokenCount = 0  

   oBtn:Disable()
   oChat:SendStream( AllTrim( cPrompt ), { | cBuffer | ShowTokens( cBuffer ) } )
   ShowTokenStats()
   oBtn:Enable()
   oPrompt:SetFocus()
    
return nil    

function ShowTokens( cBuffer )

    local hResponse := hb_jsonDecode( cBuffer )

    oOutput:Append( hResponse[ "message" ][ "content" ] )
    nTokenCount++
    SysRefresh()

return nil    

function ShowTokenStats()

    local nElapsedTime := Seconds() - nStartTime
    local nTokensPerSecond := iif(nElapsedTime > 0, nTokenCount / nElapsedTime, 0)
 
    oOutput:Append( StrTran( "Tokens por segundo: " + Str( nTokensPerSecond, 10, 2 ), ".", "," ) )
    SysRefresh()
 
 return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
wilsongamboa
Posts: 608
Joined: Wed Oct 19, 2005 6:41 pm
Location: Quito - Ecuador
Been thanked: 2 times

Re: Using DeepSeek locally using Ollama

Post by wilsongamboa »

Master Antonio buenas tardes
no he podido generar la libcurl en 64 bits me interesa
podrias disponer esa lib con tus cambio y publicar la clase donde se utiliza
gracias por compartir tus conocimientos con todos
Un abrazo
Wilson
Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
User avatar
Antonio Linares
Site Admin
Posts: 42477
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 28 times
Been thanked: 63 times
Contact:

Re: Using DeepSeek locally using Ollama

Post by Antonio Linares »

Estimado Wilson,

Los nuevos builds de Harbour y xHarbour en 32 y 64 bits ya estan disponibles desde:

https://github.com/FiveTechSoft/harbour ... our_builds

Gracias a Enrico por su inestimable ayuda! :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply