Jump to content

Search the Community

Showing results for tags 'ollama'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. SciTE AI assistant The first approach, to integrate an AI assistant into SciTE works directly with the ollama. I use a small model qwen2.5-coder:3b as default, 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 The first job is to make function headers Simply run the script, select a function body within SciTE and press the {End} key It's not perfect, but it's a template. ; https://www.autoitscript.com/forum/topic/212888-scite-ai-assistant ;---------------------------------------------------------------------------------------- ; Title...........: SciTE_AI_Assistant.au3 ; Description.....: SciTE AI assistant - first feature: Function headers generator ; Simply select a function within SciTE and press the {End} key. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.3 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #include "JSON.au3" ;" https://www.autoitscript.com/forum/topic/209502-json-udf-in-pure-autoit/#comment-1511873 " #include <Array.au3> #include <SendMessage.au3> #include <String.au3> #include <WindowsConstants.au3> Global $DebugInfo = False ; True = debug info * <-- HotKeySet("{END}", "GenerateFunctionHeader") ; * <-- While 1 Sleep(100) WEnd ;--------------------------------------------------------------------------------------- Func GenerateFunctionHeader() HotKeySet("{END}") Local $hWnd = WinActivate("[CLASS:SciTEWindow]") If Not $hWnd Then Return SetError(HotKeySet("{END}", "GenerateFunctionHeader")) Local $sSelected = _SciteIO() ;Get Selection If @error Then ToolTip(" Copy failed.") Else DW("$sSelected=" & $sSelected & @CRLF) If StringLeft($sSelected, 4) = "func" Then Send('{UP}') Local $sOut = AI_GenerateFunctionHeader($sSelected) If @error Then ToolTip(@error) Else _SciteIO(@CRLF & @CRLF & $sOut & @CRLF & @CRLF) EndIf Else ToolTip("No Func selected") EndIf EndIf Sleep(2000) ToolTip("") HotKeySet("{END}", "GenerateFunctionHeader") EndFunc ;==>GenerateFunctionHeader ;--------------------------------------------------------------------------------------- Func AI_GenerateFunctionHeader($sFullFunction, $sAssistant = -1) If $sAssistant = -1 Then $sAssistant = "qwen2.5-coder:3b" Local $sInstruction, $sSystem, $sOut $sInstruction = "Generate a function header for the given AutoIt function." & @CRLF $sInstruction &= "Use the exact standard UDF comment format, as shown in the example." & @CRLF $sInstruction &= "DO NOT invent or assume any parameters, return values, or behavior not explicitly visible in the function." & @CRLF $sInstruction &= "If the function has no parameters, leave 'Parameters' empty." & @CRLF $sInstruction &= "If it does not return a value, then in 'Return values' write 'None'." & @CRLF $sInstruction &= "Align all parameter names to the same column width using consistent spaces. The hyphen (-) must appear in the same column for all parameters." & @CRLF $sInstruction &= "If the function interacts with GUI elements, include that in the 'Remarks' section." & @CRLF $sInstruction &= "If the 'Remarks' line exceeds 130 characters, break it into multiple lines starting each with '; ' like in the example." & @CRLF $sInstruction &= "Optional parameters must be shown using nested brackets as per the example." & @CRLF $sInstruction &= "Match spacing exactly as in the example (e.g., align parameter names and descriptions)." & @CRLF $sInstruction &= "Use concise, factual language—do not embellish or rephrase beyond what's explicit in the function." & @CRLF $sInstruction &= "In 'Return values', include detailed descriptions of any @error values that may be set." & @CRLF $sInstruction &= "Use the following format for @error documentation: '@error = X: Explanation' as shown in the example." & @CRLF $sInstruction &= "If applicable, describe both the success and failure outcomes clearly, using 'Success:' and 'Failure:'." & @CRLF $sInstruction &= "The 'Author' is ioa747. Dependencies must match actual function calls only. Do not invent links or libraries." & @CRLF $sInstruction &= "Avoid unnecessary technical jargon. Keep lines compact and accurate." & @CRLF & @CRLF $sInstruction &= "Example format:" & @CRLF $sInstruction &= "; #FUNCTION# ====================================================================================================================" & @CRLF $sInstruction &= "; Name...........: StreamToEdit" & @CRLF $sInstruction &= "; Description....: Generate response from the AI assistant with streaming support." & @CRLF $sInstruction &= "; Syntax.........: StreamToEdit( $sPrompt [, $sAssistant = ""qwen2.5-coder:1.5b"" [, $sSystem = ""You are an AI assistant."" [, $fTemperature = 0.3 [, $iSeed = 0]]]] )" & @CRLF $sInstruction &= "; Parameters.....: $sPrompt - The prompt to be sent to the assistant." & @CRLF $sInstruction &= "; $sAssistant - [optional] The name of the AI assistant. (Default is ""qwen2.5-coder:3b"")" & @CRLF $sInstruction &= "; $sSystem - [optional] The system instruction provided by the user. (Default is ""You are an AI assistant."")" & @CRLF $sInstruction &= "; $fTemperature - [optional] The temperature value for the assistant's output. (Default is 0.3)" & @CRLF $sInstruction &= "; $iSeed - [optional] The seed value for the assistant's response. (Default is 0)" & @CRLF $sInstruction &= "; Return values .: Success: Returns the available models if the specified model is found." & @CRLF $sInstruction &= "; Failure: Sets @error and returns an empty string with a custom message." & @CRLF $sInstruction &= "; @error = 1: Ollama is not running at the default URL." & @CRLF $sInstruction &= "; @error = 2: The specified model was not found." & @CRLF $sInstruction &= "; Author ........: ioa747" & @CRLF $sInstruction &= "; Modified ......: " & @CRLF $sInstruction &= "; Remarks .......: This function uses a WinHttp request to communicate with the Ollama API." & @CRLF $sInstruction &= "; Related .......: " & @CRLF $sInstruction &= "; Link ..........: " & @CRLF $sInstruction &= "; Example .......: " & @CRLF $sInstruction &= "; ===============================================================================================================================" & @CRLF & @CRLF $sInstruction &= "Now generate a header comment for the following function:" & @CRLF $sInstruction &= "```AutoIt" & @CRLF $sInstruction &= $sFullFunction & @CRLF $sInstruction &= "```" & @CRLF Local $hTimer = TimerInit() $sOut = AskToAI($sInstruction, $sAssistant, $sSystem, 0, 1) If @error Then Return @error Return "> " & $sAssistant & " processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds " & @CRLF & $sOut EndFunc ;==>AI_GenerateFunctionHeader ;--------------------------------------------------------------------------------------- Func AskToAI($sPrompt, $sAssistant = -1, $sSystem = -1, $Temperature = -1, $Seed = -1) If $sSystem = "" Or $sSystem = -1 Or $sSystem = Default Then $sSystem = "You are an AI assistant designed to analyze AutoIt code." ; best mini models result with: qwen2.5-coder:1.5b ; qwen2.5-coder:3b 1.8 GB ; llama3.2:3b-instruct-q8_0 3.2 GB If $sAssistant = "" Or $sAssistant = -1 Or $sAssistant = Default Then $sAssistant = "qwen2.5-coder:3b" If $Temperature = "" Or $Temperature = -1 Or $Temperature = Default Then $Temperature = 0.3 If $Seed = "" Or $Seed = -1 Or $Seed = Default Then $Seed = 0 __JSON_FormatString($sPrompt) Local $sRequest = '{' $sRequest &= '"model": "' & $sAssistant & '", ' $sRequest &= '"system": "' & $sSystem & '", ' $sRequest &= '"prompt": "' & $sPrompt & '", ' $sRequest &= '"stream": false, ' $sRequest &= '"temperature": ' & $Temperature & ', ' $sRequest &= '"seed": ' & $Seed $sRequest &= '}' DW("$sRequest=" & $sRequest & @CRLF) Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHttp.Open("POST", "http://localhost:11434/api/generate", False) $oHttp.SetRequestHeader("Content-Type", "application/json") $oHttp.Send($sRequest) ; Check if request was successful If $oHttp.Status <> 200 Then Local $aErr = HTTP_STATUS_CODES($oHttp.Status) MsgBox(16, "(" & $aErr[0] & ") " & $aErr[1], $aErr[2]) Return EndIf Local $sResponse = $oHttp.ResponseText ; Parse response and display $o_Json = _JSON_Parse($sResponse) $sText = _JSON_Get($o_Json, ".response") $sText = StringRegExpReplace($sText, "(\r\n|\n)", @CRLF) Return $sText EndFunc ;==>AskToAI ;--------------------------------------------------------------------------------------- Func _SciteIO($sTxt = "") Local $hWnd = WinActivate("[CLASS:SciTEWindow]") If Not $hWnd Then Return SetError(1) Local $ClipBack = ClipGet() ; backup clip data Local $hCtrlHnd, $ClipData, $iTimeout = 2000 ClipPut("<empty>") Local $iStartTime = TimerInit() If $sTxt = "" Then ; ### get selection to clip ### $hCtrlHnd = ControlGetHandle($hWnd, '', 'Scintilla1') _SendMessage($hCtrlHnd, $WM_COPY) While TimerDiff($iStartTime) < $iTimeout ; Wait until the timeout $ClipData = ClipGet() If $ClipData <> "<empty>" Then ExitLoop Sleep(10) WEnd Else ; ### set Txt to Console ### $hCtrlHnd = ControlGetHandle($hWnd, '', 'Scintilla2') ClipPut($sTxt) While TimerDiff($iStartTime) < $iTimeout ; Wait until the timeout $ClipData = ClipGet() If $ClipData <> "<empty>" Then ExitLoop Sleep(10) WEnd If $ClipData <> "<empty>" Then If Not $hCtrlHnd Then WinMenuSelectItem($hWnd, "", "&View", "&Output") If Not $DebugInfo Then WinMenuSelectItem($hWnd, "", "&Tools", "Clear &Output") _SendMessage($hCtrlHnd, $WM_PASTE) EndIf EndIf ClipPut($ClipBack) ; Restore clip data Return ($ClipData = "<empty>" ? SetError(2) : $ClipData) EndFunc ;==>_SciteIO ;--------------------------------------------------------------------------------------- Func HTTP_STATUS_CODES($iStatus) Local $aResult[3] = [$iStatus, "HTTP_STATUS", "description"] Local $HTTP_STATUS_CODES[41][3] = [[40, "HTTP status", "description"] _ , [100, "HTTP_STATUS_CONTINUE", "The request can be continued."] _ , [101, "HTTP_STATUS_SWITCH_PROTOCOLS", "The server has switched protocols " & @CRLF & "in an upgrade header."] _ , [200, "HTTP_STATUS_OK", "The request completed successfully."] _ , [201, "HTTP_STATUS_CREATED", "The request has been fulfilled and resulted " & @CRLF & "in the creation of a new resource."] _ , [202, "HTTP_STATUS_ACCEPTED", "The request has been accepted for processing, " & @CRLF & "but the processing has not been completed."] _ , [203, "HTTP_STATUS_PARTIAL", "The returned meta information in the entity-header " & @CRLF & "is not the definitive set available " & @CRLF & "from the originating server."] _ , [204, "HTTP_STATUS_NO_CONTENT", "The server has fulfilled the request, " & @CRLF & "but there is no new information to send back."] _ , [205, "HTTP_STATUS_RESET_CONTENT", "The request has been completed, " & @CRLF & "and the client program should reset the document view " & @CRLF & "that caused the request to be sent to " & @CRLF & "allow the user to easily initiate another input action."] _ , [206, "HTTP_STATUS_PARTIAL_CONTENT", "The server has fulfilled " & @CRLF & "the partial GET request for the resource."] _ , [207, "HTTP_STATUS_WEBDAV_MULTI_STATUS", "During a World Wide Web " & @CRLF & "Distributed Authoring and Versioning (WebDAV) operation, " & @CRLF & "this indicates multiple status codes for a single response. " & @CRLF & "The response body contains Extensible Markup Language (XML) " & @CRLF & "that describes the status codes."] _ , [300, "HTTP_STATUS_AMBIGUOUS", "The requested resource is available " & @CRLF & "at one or more locations."] _ , [301, "HTTP_STATUS_MOVED", "The requested resource has been assigned " & @CRLF & "to a new permanent Uniform Resource Identifier (URI), " & @CRLF & "and any future references to this resource " & @CRLF & "should be done using one of the returned URIs."] _ , [302, "HTTP_STATUS_REDIRECT", "The requested resource " & @CRLF & "resides temporarily under a different URI."] _ , [303, "HTTP_STATUS_REDIRECT_METHOD", "The response to the request " & @CRLF & "can be found under a different URI " & @CRLF & "and should be retrieved using a GET HTTP verb on that resource."] _ , [304, "HTTP_STATUS_NOT_MODIFIED", "The requested resource " & @CRLF & "has not been modified."] _ , [305, "HTTP_STATUS_USE_PROXY", "The requested resource must be accessed through " & @CRLF & "the proxy given by the location field."] _ , [307, "HTTP_STATUS_REDIRECT_KEEP_VERB", "The redirected request " & @CRLF & "keeps the same HTTP verb. HTTP/1.1 behavior."] _ , [400, "HTTP_STATUS_BAD_REQUEST", "The request could not be processed by the server " & @CRLF & "due to invalid syntax."] _ , [401, "HTTP_STATUS_DENIED", "The requested resource requires " & @CRLF & "user authentication."] _ , [402, "HTTP_STATUS_PAYMENT_REQ", "Not implemented in the HTTP protocol."] _ , [403, "HTTP_STATUS_FORBIDDEN", "The server understood the request, " & @CRLF & "but cannot fulfill it."] _ , [404, "HTTP_STATUS_NOT_FOUND", "The server has not found anything that matches the requested URI."] _ , [405, "HTTP_STATUS_BAD_METHOD", "The HTTP verb used is not allowed."] _ , [406, "HTTP_STATUS_NONE_ACCEPTABLE", "No responses acceptable to the client were found."] _ , [407, "HTTP_STATUS_PROXY_AUTH_REQ", "Proxy authentication required."] _ , [408, "HTTP_STATUS_REQUEST_TIMEOUT", "The server timed out waiting for the request."] _ , [409, "HTTP_STATUS_CONFLICT", "The request could not be completed due to a conflict " & @CRLF & "with the current state of the resource. " & @CRLF & "The user should resubmit with more information."] _ , [410, "HTTP_STATUS_GONE", "The requested resource is no longer available at the server, and no forwarding address is known."] _ , [411, "HTTP_STATUS_LENGTH_REQUIRED", "The server cannot accept the request " & @CRLF & "without a defined content length."] _ , [412, "HTTP_STATUS_PRECOND_FAILED", "The precondition given in one " & @CRLF & "or more of the request header fields " & @CRLF & "evaluated to false when it was tested on the server."] _ , [413, "HTTP_STATUS_REQUEST_TOO_LARGE", "The server cannot process the request " & @CRLF & "because the request entity is larger than the server is able to process."] _ , [414, "HTTP_STATUS_URI_TOO_LONG", "The server cannot service the request " & @CRLF & "because the request URI is longer than the server can interpret."] _ , [415, "HTTP_STATUS_UNSUPPORTED_MEDIA", "The server cannot service the request " & @CRLF & "because the entity of the request is in a format not supported " & @CRLF & "by the requested resource for the requested method."] _ , [449, "HTTP_STATUS_RETRY_WITH", "The request should be retried " & @CRLF & "after doing the appropriate action."] _ , [500, "HTTP_STATUS_SERVER_ERROR", "The server encountered an unexpected condition " & @CRLF & "that prevented it from fulfilling the request."] _ , [501, "HTTP_STATUS_NOT_SUPPORTED", "The server does not support the functionality " & @CRLF & "required to fulfill the request."] _ , [502, "HTTP_STATUS_BAD_GATEWAY", "The server, while acting as a gateway or proxy, " & @CRLF & "received an invalid response from the upstream server " & @CRLF & "it accessed in attempting to fulfill the request."] _ , [503, "HTTP_STATUS_SERVICE_UNAVAIL", "The service is temporarily overloaded."] _ , [504, "HTTP_STATUS_GATEWAY_TIMEOUT", "The request was timed out waiting for a gateway."] _ , [505, "HTTP_STATUS_VERSION_NOT_SUP", "The server does not support the HTTP protocol version " & @CRLF & "that was used in the request message."]] For $i = 1 To $HTTP_STATUS_CODES[0][0] If $HTTP_STATUS_CODES[$i][0] = $iStatus Then $aResult[0] = $HTTP_STATUS_CODES[$i][0] $aResult[1] = $HTTP_STATUS_CODES[$i][1] $aResult[2] = $HTTP_STATUS_CODES[$i][2] ConsoleWrite("$aResult[0]=" & $aResult[0] & ", $aResult[1]=" & $aResult[1] & ", $aResult[2]=" & $aResult[2] & @CRLF) ExitLoop EndIf Next Return $aResult EndFunc ;==>HTTP_STATUS_CODES ;--------------------------------------------------------------------------------------- Func DW($sString, $iLine = @ScriptLineNumber) If Not $DebugInfo Then Return ConsoleWrite("(" & $iLine & ") " & $sString) EndFunc ;==>DW ;--------------------------------------------------------------------------------------- I will update the thread as soon as anything new comes up. Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
×
×
  • Create New...