![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) AI: Set Ask ParamsSee more AI ExamplesDemonstrates how to set the followingAsk parameters: temperature, effort, and max_output_tokens.Note: This example requires Chilkat v11.2.0 or greater.
load ./chilkat.dll set success 0 # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set ai [new_CkAi] CkAi_put_VerboseLogging $ai 1 CkAi_put_Provider $ai "google" CkAi_put_ApiKey $ai "MY_API_KEY" CkAi_put_Model $ai "gemini-3-flash-preview" # Note: Not all models support all params. # Set Ask params. set askParams [new_CkJsonObject] CkJsonObject_UpdateNumber $askParams "temperature" "1.2" CkJsonObject_UpdateString $askParams "effort" "low" CkJsonObject_UpdateInt $askParams "max_output_tokens" 1024 CkJsonObject_put_EmitCompact $askParams 0 puts [CkJsonObject_emit $askParams] CkAi_SetAskParams $ai $askParams # Add a text input. CkAi_InputAddText $ai "Say Hello." # Ask the AI for text output. set success [CkAi_Ask $ai "text"] if {$success == 0} then { puts [CkAi_lastErrorText $ai] delete_CkAi $ai delete_CkJsonObject $askParams exit } # Get the text response. set sbResponse [new_CkStringBuilder] CkAi_GetOutputTextSb $ai $sbResponse puts [CkStringBuilder_getAsString $sbResponse] # Sample output: # Hello! How can I assist you today? # ------------------------------------------------------------- # The response is in markdown format. # Also see Markdown to HTML Conversion Examples. # ------------------------------------------------------------- delete_CkAi $ai delete_CkJsonObject $askParams delete_CkStringBuilder $sbResponse |
||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.