Skip to content

AI plugin service

In this tutorial you will learn how to use the giga sdk to use a plugin service in your Personal Feature. This allows your personal feature to use the plugin service in the background. This tutorial will use the giga-ai plugin service.

INFO

The AI-service allows you to send data from your personal feature to the giga-ai service where it will execute on a given prompt. As the world is currently in the phase of using AI services we wanted to give you the opportunity to combine it with your own financial data and external data to provide insight unique to you.

After completing this page, you should be able to:

  1. Use the giga sdk to add the background plugin service to your personal feature
  2. Use the giga sdk to get data from the platform service
  3. Use the giga-ai plugin to set context and send/receive messages

This page will explain each step:

1. Use the giga sdk to add the background plugin service to your personal feature

The following code will add the giga-ai plugin to your personal feature.

ts
giga.ai.gigaChat.open()
giga.ai.gigaChat.open()

2. Use the giga sdk to get data from the platform service

The following code snippet will get your account information and get all your transactions from one of the accounts for a set date range.

ts
async function getTransactionData() {
    try {
      const accountList = await giga.api.privateClient.pbsa.accounts.list();
      const transactions = await giga.api.privateClient.pbsa.transactions.get({
        accountId: accountList.result.PrivateBankAccounts[0].AccountNumberForRequests,
        dateFrom: '09/10/2022',
        dateTo: '08/11/2022'
      });
      return transactions.result;
    } catch (error) {
      console.error(error);
    }
  }
async function getTransactionData() {
    try {
      const accountList = await giga.api.privateClient.pbsa.accounts.list();
      const transactions = await giga.api.privateClient.pbsa.transactions.get({
        accountId: accountList.result.PrivateBankAccounts[0].AccountNumberForRequests,
        dateFrom: '09/10/2022',
        dateTo: '08/11/2022'
      });
      return transactions.result;
    } catch (error) {
      console.error(error);
    }
  }

You can execute the function by calling it:

ts
this.getTransactionData().then(res => {
      console.log(res)
    })
this.getTransactionData().then(res => {
      console.log(res)
    })

3. Use the giga-ai plugin to send/receive messages

In order to use the giga-ia, you need to tell it a promt of what it should do and how it must respond. The following code will send the prompt to the giga-ai plugin and return information to our personal features.

ts
const prompt = 'Analyse the following transactions and explain what i am spending most of my money on and provide any recommendations on what i can do to better manage my finances. \n' +
    '# transaction data:\n' +
    ' \n' + myTransactions +
    ' Return the answer in markdown'
const prompt = 'Analyse the following transactions and explain what i am spending most of my money on and provide any recommendations on what i can do to better manage my finances. \n' +
    '# transaction data:\n' +
    ' \n' + myTransactions +
    ' Return the answer in markdown'

We can now pass the prompt to the giga-ai plugin service and receive a message response.

ts
giga.ai.message.add(prompt).then(res => {
        console.log(res)
    })
giga.ai.message.add(prompt).then(res => {
        console.log(res)
    })