Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

SQL Server Examples
Web API Categories

AI
ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Markdown
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
Regular Expressions
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(SQL Server) Full Transcript Mode vs Summarized Mode Conversations

See more AI Examples
When a conversation involves multimodal inputs, like images, files, or URLs, resending the full transcript can be costly. To address this, we send summary text instead of the previously sent data or URLs. This is the default approach. The FullTranscript property can be set to 1 to full re-send the data or URL with the next request.

Note: This example requires Chilkat v11.2.0 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @success int
    SELECT @success = 0

    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @ai int
    EXEC @hr = sp_OACreate 'Chilkat.Ai', @ai OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    -- The provider can be "openai", "google", "claude", "deepseek", "xai", or "perplexity".
    -- Support for additional providers will be added in future versions of Chilkat.
    -- xAI (Grok) will be used here..
    EXEC sp_OASetProperty @ai, 'Provider', 'xai'

    -- Use your provider's API key.
    EXEC sp_OASetProperty @ai, 'ApiKey', 'MY_API_KEY'

    -- Choose a model.
    EXEC sp_OASetProperty @ai, 'Model', 'grok-4'

    -- Create a new conversation to be maintained locally in memory.
    -- If the conversation is the first to be created, it is also automatically selected.
    DECLARE @systemMsg nvarchar(4000)
    SELECT @systemMsg = 'You are a helpful assistant'
    DECLARE @developerMsg nvarchar(4000)
    SELECT @developerMsg = 'Respond only with markdown'
    DECLARE @conversationName nvarchar(4000)
    SELECT @conversationName = 'test_conversation'
    EXEC sp_OAMethod @ai, 'NewConvo', @success OUT, @conversationName, @systemMsg, @developerMsg

    -- The FullTranscript property is set to 0 by default, enabling summary mode. 
    -- In this mode, for previously sent multimodal items, a summary message (e.g., "Previously uploaded image data") is sent instead of the actual data or URL.
    EXEC sp_OASetProperty @ai, 'FullTranscript', 0

    -- Add both text input and image data
    EXEC sp_OAMethod @ai, 'InputAddText', @success OUT, 'Describe what you see in the following image.'

    DECLARE @bd int
    EXEC @hr = sp_OACreate 'Chilkat.BinData', @bd OUT

    -- We're passing a relative local file path here.. (relative the the app's current working directory)
    EXEC sp_OAMethod @bd, 'LoadFile', @success OUT, 'qa_data/jpg/starfish.jpg'
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @bd, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @ai
        EXEC @hr = sp_OADestroy @bd
        RETURN
      END

    -- The full image data is sent in this request because it is part of the current inputs.
    -- In the followup request (below), the summary text is sent instead of the image data.
    -- (But remember, the AI's response is part of the transcript, and it will also be sent.  Therefore,
    -- the transcript sent in the followup request will have information about what is contained in the image.)
    DECLARE @summaryText nvarchar(4000)
    SELECT @summaryText = 'image previously uploaded.'
    EXEC sp_OAMethod @ai, 'InputAddImageData', @success OUT, @bd, @summaryText

    -- Ask the AI for text output.
    EXEC sp_OAMethod @ai, 'Ask', @success OUT, 'text'
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @ai, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @ai
        EXEC @hr = sp_OADestroy @bd
        RETURN
      END

    -- Get the text response.
    DECLARE @sbResponse int
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponse OUT

    EXEC sp_OAMethod @ai, 'GetOutputTextSb', @success OUT, @sbResponse
    EXEC sp_OAMethod @sbResponse, 'GetAsString', @sTmp0 OUT
    PRINT @sTmp0

    -- Sample output:

    -- ### Image Description
    -- 
    -- - **Subject**: A small, orange starfish (sea star) with five arms radiating from a central body.
    -- - **Color**: Bright orange with subtle shading for texture.
    -- - **Texture**: Bumpy or nodular surface, resembling the rough skin of a real starfish.
    -- - **Position**: Viewed from above, slightly tilted, with one arm pointing upwards.
    -- - **Background**: Plain white, making the starfish the focal point.
    -- - **Style**: Appears to be a realistic illustration or photo, possibly a clipart or icon.

    -- ---------------------------
    -- Now let's send a followup question.  The image data will not be included in what is sent because FullTranscript is 0.
    -- However, the summary text and the AI assistant's previous answer IS sent.
    EXEC sp_OAMethod @ai, 'InputAddText', @success OUT, 'How is this starfish different than a Brisingida?'

    EXEC sp_OAMethod @ai, 'Ask', @success OUT, 'text'
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @ai, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @ai
        EXEC @hr = sp_OADestroy @bd
        EXEC @hr = sp_OADestroy @sbResponse
        RETURN
      END

    -- Get the text response.
    EXEC sp_OAMethod @sbResponse, 'Clear', NULL
    EXEC sp_OAMethod @ai, 'GetOutputTextSb', @success OUT, @sbResponse
    EXEC sp_OAMethod @sbResponse, 'GetAsString', @sTmp0 OUT
    PRINT @sTmp0

    -- Sample output:

    -- ### Differences Between the Described Starfish and Brisingida
    -- 
    -- The starfish described in the image appears to be a typical shallow-water sea star (likely from the order Asteroida or similar), while Brisingida is a distinct order of deep-sea starfish. Here's a breakdown of key differences based on general characteristics:
    -- 
    -- - **Number of Arms**:
    --   - Described Starfish: 5 arms (standard for many common starfish like those in the Asterias genus).
    --   - Brisingida: Typically 6 to 20 arms (often more than 5, with some species having up to 16 or more).
    -- 
    -- - **Arm Structure and Flexibility**:
    --   - Described Starfish: Shorter, stiffer arms with a bumpy, nodular texture; arms are broader and less flexible, suited for crawling on surfaces.
    --   - Brisingida: Long, slender, highly flexible arms covered in spines; they resemble brittle stars and are adapted for suspension feeding by extending arms into water currents.
    -- 
    -- - **Size and Body Shape**:
    --   - Described Starfish: Small and compact, with a central disc and radiating arms; overall body is relatively flat and sturdy.
    --   - Brisingida: Larger central disc with arms that can be very elongated (up to several times the disc's diameter); body is more delicate and adapted for deep-sea environments.
    -- 
    -- - **Habitat and Lifestyle**:
    --   - Described Starfish: Likely shallow coastal waters; active predators or scavengers that move across the seafloor.
    --   - Brisingida: Deep-sea (abyssal) environments, often at depths of 1,000–5,000 meters; passive filter feeders that attach to substrates and capture plankton from currents.
    -- 
    -- - **Color and Appearance**:
    --   - Described Starfish: Bright orange, which is common in many shallow-water species for camouflage or warning.
    --   - Brisingida: Often reddish, orange, or purplish, but with a more spiny, feathery look due to pedicellariae (tiny pincer-like structures) and spines.
    -- 
    -- - **Regeneration and Reproduction**:
    --   - Both can regenerate arms, but Brisingida may have more specialized adaptations for deep-sea survival, including asexual reproduction in some species.
    -- 
    -- If the image represents a specific species (e.g., a common sea star like *Asterias rubens*), these differences would be even more pronounced. Brisingida are rarer and not commonly encountered outside scientific contexts. For precise identification, more details or a real photo would help!

    EXEC @hr = sp_OADestroy @ai
    EXEC @hr = sp_OADestroy @bd
    EXEC @hr = sp_OADestroy @sbResponse


END
GO

 

© 2000-2025 Chilkat Software, Inc. All Rights Reserved.