Jump to content

Recommended Posts

Posted (edited)

I divide the project into parts for easier management.

The project is in early beta stage, for research and development.  🚀

 

AI_Assistant.au3

which is included in SciTE_AI_Assistant.au3, but can also be used as a standalone UDF

in which I #include "StringSize.au3" ; "https://www.autoitscript.com/forum/topic/114034-stringsize-m23-bugfix-version-27-dec-23"  by  Melba23  -  thanks for that
So that it folds the console output, and is visible within its boundaries (especially when it is on the side and is slim)  for more comfortable reading

works directly with the ollama. I use a small models  qwen2.5-coder:3b  as default, llama3.2:3b ,  phi4-mini:3.8b  so that I don't have to wait too long for a response.
However, I have set as a parameter which model it calls, so that it changes the model per job if necessary

I added a new function: _AI_Request which asynchronously sends a request to _AI_Call() and waits for the response.

I also added a new parameter $iThink -  Enable or disable thinking if Model supporting (0=none, 1=yes/not visible, 2=yes/visible). (Default is 0)
to conform with the new ability to enable or disable thinking.  (feature since version 0.9.0)

Ollama now has the ability to enable or disable thinking. This gives users the flexibility to choose the model’s thinking behavior for different applications and use cases.
When thinking is enabled, the output will separate the model’s thinking from the model’s output. When thinking is disabled, the model will not think and directly output the content.

Models that support thinking:


AI_Assistant\Example\Example2.au3  -  thinking example

#include "..\AI_Assistant.au3"

_AI_DebugInfo(True)

Example2()

Func Example2()

    Local $sPrompt = "how many r's are in strawberry?"
    Local $sModel = "qwen3:4b"

    ; _AI_Request with thinking Enable (0=none, 1=yes/not visible, 2=yes/visible)
    Local $sResponse = _AI_Request($sPrompt, $sModel, Default, 1, 2)
    ConsoleWrite($sResponse & @CRLF & @CRLF)

EndFunc

Output:

Thinking...

Okay, so the user is asking how many R's are in the word "strawberry". Let me think. First, I need to write out the word and check each letter. Let me spell it out: S-T-R-A-W-B-E-R-R-Y. Wait, let me make sure I have that right. Strawberry is S-T-R-A-W-B-E-R-R-Y. Let me break it down letter by letter.

S, T, R, A, W, B, E, R, R, Y. So that's 10 letters in total. Now, I need to count the number of R's. Let's go through each letter one by one. The first letter is S, not R. Second is T, no. Third is R—that's one. Fourth is A, no. Fifth is W, no. Sixth is B, no. Seventh is E, no. Eighth is R—that's two. Ninth is R—that's three. Tenth is Y, no. So that's three R's. Wait, let me check again to make sure I didn't miss any. S-T-R-A-W-B-E-R-R-Y. Yes, positions 3, 8, and 9 are R. So three R's in total. I think that's correct. Maybe I should write it out again to confirm. Strawberry: S T R A W B E R R Y. Yep, three R's. So the answer is 3.

...done thinking.

The word **"strawberry"** contains **3 R's**.  

Breaking it down:  
**S-T-R-A-W-B-E-R-R-Y**  
R's are in positions 3, 8, and 9.  

**Answer: 3** 🍓

 

SciTE_AI_Assistant.au3

I changed the approach, and made it as SciTE tool.
This way, the selection process, and console writing, is handled internally by SciTE.
To do this you need to add the following to SciTEUser.properties    (Adding_utilities_to_the_SciTE_Tools_menu)

#------------------------------------------------------------------------------
# 41 SciTE_AI_Assistant
command.41.$(au3)="$(SciteDefaultHome)\..\AutoIt3.exe" "D:\i\Pro\.AutoIT\SciTE_AI_Assistant\SciTE_AI_Assistant.au3"
command.subsystem.41.$(au3)=0
command.name.41.$(au3)=SciTE AI Assistant
command.shortcut.41.*.au3=F10
command.save.before.41.$(au3)=2
# command.replace.selection.41.$(au3)=1
# command.quiet.41.$(au3)=0
# command.input.41.$(au3)=$(CurrentSelection)
#------------------------------------------------------------------------------
#---------------------- Contex Menu -------------------------------------------
user.context.menu=\
||\
>>>  SciTE AI Assistant  <<< |1141|\
||\
Execute Selected Path|IDM_OPENSELECTED|\
#------------------------------------------------------------------------------

and make the necessary adjustments

e.g. in 
command.41.$(au3)="$(SciteDefaultHome)\..\AutoIt3.exe" "D:\i\Pro\.AutoIT\SciTE_AI_Assistant\SciTE_AI_Assistant.au3"

your path for the d:\your\location\SciTE_AI_Assistant\SciTE_AI_Assistant.au3

You may need to adjust the 41 to the first tool number available to you.

in this case, change the   >>>  SciTE AI Assistant  <<< |1141|\   as well in the Context Menu

 

After that, select the text in the SciTE, right-click and select  'instruction'  from the context menu '>>>  SciTE AI Assistant  <<<'

Clipboard_06-09-2025_01.pngClipboard_06-09-2025_03.png

output:

; #FUNCTION# ====================================================================================================================
; Name...........: IsMouseOverWin
; Description....: Determines if the mouse pointer is positioned over a specified window.
; Syntax.........: IsMouseOverWin($hWnd)
; Parameters.....: $hWnd - The handle of the window to check for mouse position.
; Return values .: Success: Returns True if the mouse is over the window, False otherwise.
;                  @error = 0: No error occurred.
; Author ........: ioa747
; Modified ......: 
; Remarks .......: This function uses MouseGetPos() to retrieve the current mouse position and WinGetPos($hWnd) to obtain
;                  the dimensions of the specified window. It checks if the mouse position falls within the boundaries of the window.
; Related .......: 
; Link ..........: 
; Example .......: 
; ===============================================================================================================================

 

FIM (Fill-in-the-Middle <??> )

when it comes to FIM (Fill-in-the-Middle <??> ), the '<??>' tag is to specify the-Middle
e.g. as in the example below,  highlight the text , right click , and select,   >>>  SciTE AI Assistant  <<< ,    FIM (Fill-in-the-Middle <??> )

Func SumNumbers($aNumbers)
    Local $iTotal = 0
        For $i = 0 To UBound($aNumbers) - 1
        <??>
        Next
    Return $iTotal
EndFunc

 

 

Prompt Builder GUI

250610-022819-090_AutoIt3_tL6Xs.png

The script described is an advanced AI prompt builder tool
The tool provides a user-friendly interface that allows users to create, manage, and execute AI prompts based on predefined
templates or customizable settings from .ini file.

macros in the Prompt Builder GUI
@Selection@  = the Selection of SciTE
@ScriptName@ = the Script Name (useful as title)
@ScriptFullPath@ = all the content of Script
@ClipGet@ = the content of Clipboard
@FileRead(FilePath)@ = the content of FilePath

 

 

self-introduction - ReadMe

  Reveal hidden contents

 

I will update the thread as soon as anything new comes up.
 

SciTE_AI_Assistant_0.12.zipFetching info...


Please, every comment is appreciated!
leave your comments and experiences here!
Thank you very much  :)

 

 

Edited by ioa747
update to Version: 0.12

I know that I know nothing

Posted (edited)
... ...
Global $__g_OllamaAssistant_DefaultURL = "http://localhost:11434"

Func OllamaAssistant_DefaultURL($sStr = Default)
    If $sStr <> Default Then $__g_OllamaAssistant_DefaultURL = $sStr
    Return $__g_OllamaAssistant_DefaultURL
EndFunc

ConsoleWrite(Ollama_IsModelAvailable() & @CRLF)
If @error Then Exit 5

Func Ollama_IsModelAvailable($sStr = "qwen2.5-coder")
    Local $sRet = OllamaAPI() ; default is get models at default URL
    If @error Then
        ConsoleWrite("! Ollama is not running there  =(" & @CRLF)
        Return SetError(1, 0, "")
    EndIf
    If StringInStr($sRet, $sStr) Then Return $sRet
    ConsoleWrite(@CRLF & $sRet & @CRLF & "! the model was not found. Pull it !  =)" & @CRLF )
    Return SetError(2, 0, $sRet)
EndFunc

; "/api/tags" ; List models that are available locally.
; "/api/ps" ; List models that are currently loaded into memory.
; "/api/pull"  '{"model": "qwen2.5-coder:3b"}' ; well, pull the model
Func OllamaAPI($sAPI = "/api/tags", $sURL = $__g_OllamaAssistant_DefaultURL)
    Local $sStr = BinaryToString(InetRead($sURL & $sAPI))
    ; this is not the function I should use, but it works to present the idea

    Return SetError(@error, @extended, $sStr)
EndFunc ; ..you may need to retry at times ?, ..I don't have much experience with it to know much

ConsoleWrite('HotKeySet = ' & HotKeySet("{END}", "GenerateFunctionHeader") & @CRLF) ; * <--
... ...

Nice !.
I was thinking yesterday that "I don't wanna leave SciTE" in a child tantrum kind of childish voice :lol:

So, I highlighted a function, pressed the end key and got me a "1" in the console.
But I don't know if is all that is so, add a start and end line, like:

---- 8< ---- start
1
---- >8 ---- end

so I get some feedback.

Again, thanks for working on my wish :) 

Edited by argumentum
fixed OllamaAPI() default

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)
... ...
    If $oHttp.Status <> 200 Then
;~      MsgBox(0, "Error", "WinHttp request failed with status code: " & $oHttp.Status)
        FileWriteLine(StringTrimRight(@ScriptFullPath, 4) & ".log", 'Error: $oHttp.Status:' & $oHttp.Status & @CRLF)
... ...

Error: $oHttp.Status:400  :(
What does it mean ?


I pasted the question in open-webui ( ..not quite like that but I forgot what I did )

  Reveal hidden contents

and returned it's answer:

  Reveal hidden contents

 so, maybe sending the $sSystem and $sPrompt as a single string is better ?
( am just talking out of my ... imagination here )

Edited by argumentum
more

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
... ...
    $sRequest &= '"system": "' & $sSystem & '", '
    $sPrompt = StringReplace($sPrompt, @CRLF, "\r\n")
    $sPrompt = StringReplace($sPrompt, @TAB, "\t")
    $sPrompt = StringReplace($sPrompt, '"', "\""")
    $sRequest &= '"prompt": "' & $sPrompt & '", '
... ...

..it needed to escape stuff. All good :) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
  On 5/11/2025 at 9:00 PM, argumentum said:

I understand you answer. But it only worked for me when I "man handle" the string 🤷‍♂️

Expand  
  Quote
#include "JSON.au3"   ;" https://www.autoitscript.com/forum/topic/209502-json-udf-in-pure-autoit/#comment-1511873 "
Expand  

I went to the git and pulled the file from there. Maybe the version there is bad ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

i have this

  Reveal hidden contents

 

Edited by ioa747

I know that I know nothing

Posted
  On 5/11/2025 at 9:36 PM, ioa747 said:

; helper function for converting a AutoIt-string into a json formatted string
Func __JSON_FormatString(ByRef $s_String)
    $s_String = _
        StringReplace( _
            StringReplace( _
                StringReplace( _
                    StringReplace( _
                        StringReplace( _
                            StringReplace( _
                                StringReplace( _
                                    StringReplace($s_String, '\', '\\', 0, 1) _
                                , Chr(8), "\b", 0, 1) _
                            , Chr(12), "\f", 0, 1) _
                        , @CRLF, "\n", 0, 1) _
                    , @LF, "\n", 0, 1) _
                , @CR, "\r", 0, 1) _
            , @TAB, "\t", 0, 1) _
        , '"', '\"', 0, 1)
EndFunc   ;==>__JSON_FormatString

Expand  

and I 

; helper function for converting a AutoIt-string into a json formatted string
Func __JSON_FormatString(ByRef $sString)
    Return StringLen($sString) < 50 ? _
    StringTrimRight(StringRegExpReplace($sString & '\\\b\f\n\r\t\"', '(?s)(?|\\(?=.*(\\\\))|[\b](?=.*(\\b))|\f(?=.*(\\f))|\r\n(?=.*(\\n))|\n(?=.*(\\n))|\r(?=.*(\\r))|\t(?=.*(\\t))|"(?=.*(\\")))', '\1'), 15) : _
    StringReplace( _
        StringReplace( _
            StringReplace( _
                StringReplace( _
                    StringReplace( _
                        StringReplace( _
                            StringReplace( _
                                StringReplace($sString, '\', '\\', 0, 1) _
                            , Chr(8), "\b", 0, 1) _
                        , Chr(12), "\f", 0, 1) _
                    , @CRLF, "\n", 0, 1) _
                , @LF, "\n", 0, 1) _
            , @CR, "\r", 0, 1) _
        , @TAB, "\t", 0, 1) _
    , '"', '\"', 0, 1)
EndFunc

hence the oops =/

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
  On 5/11/2025 at 9:47 PM, ioa747 said:

and which is the right one?
 ; Version .......: 0.10  ?

Expand  

..good question.
 https://github.com/Sylvan86/autoit-json-udf/blob/master/JSON.au3 claims to be "0.10" and "Last changed ..: 2023-04-29" but,
was changed 2 month ago ( changed: _JSON_Parse(): removed Byref - direct input is now possible ).
I guess the one that works is the answer ? 😅

<rant>
That's why I rather have the files in the forum. Static.
These git places are here today and changed or gone some other time :(
</rant>

<note>I'll have to use a git of sorts/providers, to work with modern/current technologies 😭 </note>

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted
  On 5/12/2025 at 12:57 AM, argumentum said:

https://github.com/Sylvan86/autoit-json-udf/blob/master/JSON.au3 claims to be "0.10" and "Last changed ..: 2023-04-29" but,
was changed 2 month ago

Expand  

Yes, version 0.10 is correct, but it should be 0.11.0 instead I would say.
As you already mentioned @argumentum, @AspirinJunkie added few commits (changes) to the UDF which should lead to 0.11.0 from 2025-04-01.

  On 5/12/2025 at 12:57 AM, argumentum said:

<rant>
That's why I rather have the files in the forum. Static.
These git places are here today and changed or gone some other time :(
</rant>

Expand  

I understand your point of view, but exactly for this situation the idea of forking a repository exists. Then you have your static version or you decide on your own when you want to pull new changes in your repository/fork. To be honest, to search within the forum is way harder then on GitHub (at least for me).

Best regards
Sven

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

  Reveal hidden contents
Posted
  On 5/12/2025 at 7:13 AM, SOLVE-SMART said:

To be honest, to search within the forum is way harder then on GitHub (at least for me).

Expand  

but what about the future user going to use it and have for breakfast that it ( the code ) don't work because one of the dependencies changed fundamentally and, ...suck it.
I understand selfishness and still advocate for ethical behaviors that don't lead to forking. A letter R apart from the same trend of thought.
And I do understand that you are just adjusted to the current way of developing and you have to do what you must ( at least for you ).

I strongly disagree with this way of participation mainly because anyone trying to replicate what is claimed, is out of phase with time. The time at witch it was all put together because the forks are not what they were.

Pardon my less than nice posture but it is just non-functional. How can one be expected to have forked 2 years ago something so today ( because it was posed 1 day ago ) can not use what is supposed to be there as it was ?

Even tho this chat is with you @SOLVE-SMART, is not necessarily personal. Is the way it is, and leads to these mishaps, hence the concept is wrong.

And no, I can not change it ( the I fork what I need ) because it takes people to feel different, and people adjust for survival of the self over the survival of the group.
That's all there is to it so, foRk it, I guess.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

@argumentum I am not sure i get if it's the platform, the repositories, the individual users or a combination you dislike? :)
When it comes to git, keeping the version in the file seems wrong, in my opinion. Git tags and/or releases on some git platforms seems the best way to keep good track of the available versions of scripts/projects.

In regards to the same code being available at a later date, unless they delete or change the visibility of the repository, you could keep a commit hash reference for a perma-link to the code you were able to access last time ;)

I personally prefer git (GitHub more specifically). Old files on this forum sometimes go poof, and sometimes no one can provide a replica (it's rare, i know).

Both Git and this forum can be a time waster, if dependencies are not kept with the project, and you are forced to go on a treasure hunt to find the necessary files (happened once or twice to me 🫠).

Personally i am working towards a package manager, using primarily git to automatically resolve and fetch dependencies of a project. If developers use the semver standard, patches should be pain free and allow upgrading dependencies using a single command :)

I agree forking is not exactly a perfect solution, but is sometimes necessary, for example when dealing with abandoned projects or not agreeing on where a project is heading ;)

Posted
  On 5/12/2025 at 3:09 PM, genius257 said:

you could keep a commit hash reference for a perma-link to the code you were able to access last time ;)

Expand  

Good to know.
Since am not familiar with git, going to get "the file" and is not it, ..is frustrating.
I code so I can debug it but those that expect the stuff to run ( because is stuff we/they discover, run it, and if it didn't, meh, it does not work, next... ) will miss in using it and participating with bugs or code or anything.

  On 5/12/2025 at 3:09 PM, genius257 said:

Both Git and this forum can be a time waster, if dependencies are not kept with the project, and you are forced to go on a treasure hunt to find the necessary files (happened once or twice to me 🫠).

Expand  

I've found myself uploading files for those occasions when I have them ( and I have them because I hoard them ). 

Maybe I went overboard in my rant, maybe. I should have advised to include all the external includes and that is a better solution :) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted

Off topic

  Reveal hidden contents

Best regards
Sven

==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet

  Reveal hidden contents
Posted
  On 5/12/2025 at 3:34 PM, argumentum said:

Good to know.
Since am not familiar with git, going to get "the file" and is not it, ..is frustrating.

Expand  

I think then the reference link should be https://github.com/Sylvan86/autoit-json-udf/blob/8f326597f402c1576ef793b68552171472db62c9/JSON.au3 ( untested, just looking at it )
But it would be nice to fix just that function given that the file had many patches after that.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...