Sheerpower Logo
F.9  Artificial Intelligence (AI) Chat

Using the aichat$() Function in Sheerpower

The aichat$() function in Sheerpower allows you to send prompts to AI models and receive responses. You can use this function to integrate AI capabilities into your application, whether it's for chat, data generation, or other AI-driven tasks.

Syntax:

answer$ = aichat$(prompt$ [, wrap_it])

Parameters:

  • prompt$: The prompt or instruction text you send to the AI (required).
  • wrap_it: A boolean (TRUE or FALSE) indicating if the response should be word-wrapped (optional).

Examples:

prompt$ = 'List the planets in our solar system' answer$ = aichat$(prompt$, TRUE) print answer$
prompt$ = 'Write a song about a cat who travels the world' answer$ = aichat$(prompt$, TRUE) print answer$
prompt$ = 'Write a haiku about the changing seasons' answer$ = aichat$(prompt$, TRUE) print answer$

This sends a prompt to the AI and prints the word-wrapped response.

Directives for AI Interactions

Directives modify how aichat$() behaves, such as specifying an API key or starting a new conversation.

  • %key xxxx: Provides your API key (xxxx) to the AI service. If omitted, a default API key is used. This directive also starts a new conversation.
  • %new: Starts a new chat conversation, clearing any prior conversation history.

Example:

answer$ = aichat$("%key my_api_key")

This sets the API key and initiates a new conversation.

Notes:

  • Response times may vary, and it can take up to 10 seconds to receive a response.
  • API keys can be obtained here (a subscription fee may apply).
Hide Description

    

       


      

Enter or modify the code below, and then click on RUN

Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.
Wide screen