You can communicate with ChatGPT using this Clarion code and integrate it into your software. However, please remember that the application requires Nettalk and StringTheory templates developed by Capesoft to function properly. Additionally, please be reminded that you need to generate an API key from the following link: OpenAI Platform and input this key into the software. I hope this is helpful.
ChatGPT.zip (3.0 MB)
Nice âGelen cevapâ translate to Incoming replyâŚ
The inclusion of LLMâs in applications going forward where the app can be recognised and driven by AI is surely next.
And products with this in mind where its internal structures are command friendly is surely the way forward. It might be a decade away but the pace of change is always surprising and we changed to command drive a decade ago instead of GUI operator driven.
Nice demo of using Cape softs web client in a clarion app.
Thanks for thatâŚ
Philosophically speaking; everything began on the day when writing was invented. The knowledge accumulated over thousands of years is now being presented to humanity, blended according to our needs. The momentum of progress with artificial intelligence will elevate this further and make the growth of the human population unnecessary. More importantly, we are no longer limited by a human lifespan.
I hope the tool serves your needs.
Indeed may save the planet!
MS office Open AI Turbo outâŚ
Surely Office suite will one day come with Office AI 64 Bit engine that you run locally on your home business server creating a private data model that sync to the cloud.
You wont have to buy a separate license and it will come in the bundle.
It will surely become an operating system tool (not an office part) one day, but until then, it will help you to use it in your applications
Hi Nikola,
This line doesnât seem too long. If you give me your AnyDesk ID, I can connect remotely to understand your issue and suggest a solution.
Regards,
Serhat
check this
looks like you need just double some chars
You need to double up the { characters.
You may need to double up the < character, if the character following is numeric.
I was about to say the same as Rick and Guennadi about doubling up â{â.
It depends which version of Clarion you have as some of the recent builds were more âfussyâ or âstrictâ about getting strings correct.
Anyway change that string to be
Loc:PostString='{{"model": "gpt-3.5-turbo","messages": [{{"role": "user", "content": "'&st.GetValue()&'"}],"temperature": 0.7}'
in fact looking at that code there appears to be a memory leak of the value returned from st.AnsiToUtf8 so suggest instead of:
ReformatQuestion ROUTINE
st.SetValue(CLIP(MyQuestion))
st.JsonEncode()
Loc:PostString='{"model": "gpt-3.5-turbo","messages": [{"role": "user", "content": "'&st.GetValue()&'"}],"temperature": 0.7}'
Loc:PostString=st.AnsiToUtf8(Loc:PostString,uz#,st:CP_ISO_8859_9)
I suggest you instead try something like:
ReformatQuestion ROUTINE
data
myStr &string
code
st.SetValue(MyQuestion,st:clip)
st.JsonEncode()
st.prepend('{{"model": "gpt-3.5-turbo","messages": [{{"role": "user", "content": "')
st.append('"}],"temperature": 0.7}')
myStr &= st.AnsiToUtf8(st.getValuePtr(),uz#,st:CP_ISO_8859_9)
Loc:PostString=myStr
dispose(myStr)
there is actually a âneaterâ way to do this so you donât have to define myStr or remember to dispose it, cunningly using st._stealValue:
ReformatQuestion ROUTINE
st.SetValue(MyQuestion,st:clip)
st.JsonEncode()
st.prepend('{{"model": "gpt-3.5-turbo","messages": [{{"role": "user", "content": "')
st.append('"}],"temperature": 0.7}')
st._StealValue(st.AnsiToUtf8(st.getValuePtr(),uz#,st:CP_ISO_8859_9))
Loc:PostString=st.getValue()
the fact that â_stealValueâ has an underscore at the front tells you it is really an internal method and not documented, but it is really handy for situations like this as it means you donât run the risk of a memory leak (as you donât have to dispose the returned value).
in fact I notice a similar memory leak in ReformatAnswer so again, instead of:
ReformatAnswer ROUTINE
ChatGPTResponse=st.Utf8ToAnsi(Loc:GetString,uz#,st:CP_ISO_8859_9)
baslangic#=INSTRING('"content": "',ChatGPTResponse,1,1)
bitis#=INSTRING('"finish_reason": "',ChatGPTResponse,1,1)
IF baslangic#=0 OR bitis#=0 THEN
!ChatGPTResponse=''
Loc:Status='Couldn''t get legal response from ChatGPT'
EXIT
END
st.SetValue(SUB(ChatGPTResponse,baslangic#+12,bitis#-baslangic#-29))
st.Replace('\n','<13,10>')
st.JsonDecode()
ChatGPTResponse=st.GetValue()
I suggest instead:
ReformatAnswer ROUTINE
st._StealValue(st.Utf8ToAnsi(Loc:GetString,uz#,st:CP_ISO_8859_9))
if st.setBetween('"content": "', '"finish_reason": "') = st:notFound
!ChatGPTResponse=''
Loc:Status='Couldn''t get legal response from ChatGPT'
EXIT
end
st.Replace('\n','<13,10>')
st.JsonDecode()
ChatGPTResponse=st.GetValue()
also note the use there of st.setBetween which simplifies the code (and writing less code means less chance of introducing a bug, so always a win in my book).
hth and cheers
Geoff R
Thank you very much for the improvements, Geoff.
Hi again. You can download the latest versions from my Github address. The code is publicly available. Local GPT (Ollama) & ChatGPT voice added to source.
serhatsatir/Clarion-AI: Connect to ChatGPT, Ollama or Gemini (github.com)