5 steps to integrate AIaaS into software projects

Leticia Coelho
ArcTouch
Published in
8 min readNov 28, 2023
Orange in blue

The rapid advancement of artificial intelligence is an undeniable reality. However, the origins of this field can be traced back to 1943, when Walter Pitts and Warren McCulloch introduced the concept of artificial neurons as logical models or elements [1]. In 1950, A. M. Turing, also credited with devising the three robot laws, authored an article titled “Computing Machinery and Intelligence.” This article explored the capabilities of digital computers, the concept of programming, and machines’ potential abilities and limitations [2].

While artificial intelligence (AI) is not a new concept, Artificial Intelligence as a Service (AIaaS) is a relatively recent development that has gained momentum over the past decade. The largest companies (Big Techs) have been working to make AI more accessible through the concept of AIaaS. This approach uses anything-as-a-service thinking [3], which involves providing any concept, infrastructure, or model as a service that products can access through the network.

Integrate the services these big techs provide as AIaaS considers the use of trained Artificial Intelligence models using APIs or libraries. Suppose you need to store a text written by a user in a software project. If the process of saving the text is working, you can optimize efforts to enhance the quality of the text. Integrating an AI service with a trained LLM, like OpenAi API, can improve the text by verifying its integrity, grammar, or syntax.

Another possible scenario is a project where the user needs to send pictures to demonstrate objects. Once the process of storing the image is complete, it’s possible to integrate AI to instantly process the object image, analyzing changes in color and light. There are a lot of possibilities, considering you could use models to execute natural language processing, sentiment analysis in texts, image recognition, data analysis, and high-level algorithms, creating better software with many options available.

At ArcTouch, we always look to align our technical expertise with our client’s business needs. In this article, I will outline five essential steps to successfully integrate AI into software projects, considering a hypothetical scenario that exemplifies these five steps to integrate these services. The product we will suppose here is a software solution that attends to restaurant requests.

Step 1: Looking for a problem

Identifying the best solutions hinges on one’s grasp of the problem. When exploring possible applications of artificial intelligence, it is crucial to not only focus on circumstances that lack current solutions but also on those that already have them. By pinpointing opportunities for optimization and service quality enhancement, we can fully realize the potential of AI in our solutions.

The primary objective of this step is to identify potential areas for improvement. During this process, it is crucial to remember key tips to identify such opportunities. Here are a few tips that can aid in this endeavor:

  • Analyze the project business rules to identify areas and data for improvement.
  • Talk to the clients and understand their main difficulties and pain points.
  • Identify any recurring problems or errors.
  • Utilize data analytics to identify where users abandon the process or the webpage.

By following these tips, you can gain insights and identify areas where AI services can be integrated to improve the user experience and overall project performance.

Following our defined scope, we shall consider a restaurant scenario where customers can request food through a web application. To illustrate the integration of AIaaS, we will describe the process for applying and executing each integration step in this scenario. The first step involves identifying and defining the most critical problem to solve and examining all possible requirements. Upon examining the potential issues, we determined that improving our feedback analysis was necessary, as it is linked to user responses. As a result, this first step will entail identifying problems, matching them with business analysis, and determining the most effective problem to address.

Step 2: Understanding the problem-related data

In the first step, we identified the problem. In the second step, we should identify the problem-related data. The actions undertaken in this step are concerned with verifying the relationship between the data or actions and the identified problem to facilitate its resolution in the subsequent step. Web applications that address business problems invariably necessitate considering and analyzing data produced by such applications. For instance, in a restaurant web application that seeks user feedback, a range of data may be obtained, including textual feedback, scores, and categorizations. Such data can be leveraged better to understand client behavior, engagement, and retention and to devise strategies for improving key metrics.

When working on AIaaS integration, training a new artificial intelligence model is unnecessary. The service will have the purpose of offering access to trained models. In this step, we identify the data that needs to be sent to the AI services and define the expected response data format. In the restaurant scenario, we defined that we would use the text provided by users. Additionally, we expect the result to be to understand the level of engagement of each feedback.

Step 3: Integrate the service

We have defined the problem and the data related to the problem inside the web application. Now, we should implement the AIaaS integration, considering a solution that should be maintainable, pricing-compatible, easy to implement, and technologically appropriate.

To consider each of these characteristics, we can divide this into “Technology definition” and “Executing the code,” where the code is implemented at the end of this step.

3.1. Technology definition

Considering our objectives, consider the various possibilities available through AIaaS that align with our data definition and problem statement. A multitude of companies, including Microsoft, Amazon, Google, OpenAI, and smaller enterprises, offer these services, each considering several factors such as the solution type (text, image, sound), budget, service availability, use case possibilities, ease of integration, and technical compatibility, such as programming language. It is, therefore, essential to carefully assess each option to ensure that our final choice is commensurate with our requirements.

Considering our hypothetical restaurant scenario, we should request the service when users write new feedback. In this case, using a usage-based billing service is an excellent option. We will use the openAi service, which has a straightforward implementation, usage-based billing, and appropriate service, that can analyze the feedback sentiment.

3.2. Executing the code

Executing the code for AI services is generally considered a straightforward task, owing to their well-documented specifications. These services can be efficiently utilized using suitable libraries or API requests, depending on the specific requirements of each enterprise.

For example, the OpenAI API has many models that can be accessed through endpoints. These models define the correct AI training model to use when requesting each type of service. To access these services, you can use the OpenAI library or request the OpenAI API, specifying the model related to your necessity.

Following the best practices, we must refer to the official documentation to integrate the code at this stage [4]. In our hypothetical restaurant scenario, we present a code example that enables sentiment analysis verification. To add this service to the project, an openAI API request can be made.

const API_BASE_URL = 'https://api.openai.com/v1';
const API_ENDPOINT = '/completions'; // This endpoint is related to text.

const OPENAI_KEY = 'your key'; // Verify your key on the official page.

export async function fetchPost() {
return await fetch(API_BASE_URL + API_ENDPOINT, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: "Bearer " + OPENAI_KEY,
},

body: JSON.stringify({
model: "text-davinci-002",// AI model
prompt: "Sentiment analysis of the following text:\n{text}\n" // AI Task
}),
})
}

Step 4 — Test

Automated testing is a vital component of software development, encompassing a variety of testing types such as unit testing, integration testing, end-to-end testing, and UI testing. These tests offer numerous advantages, including ease of maintenance, reliability, and comprehensive testing of all implementations with a single click.

Testing the AI service response using automatic tests is not an easy task because the data could always be mutable, giving different response possibilities. In this case, an excellent way to test if the requests are correctly executed is to consider just immutable data:

  • The existence of the response.
  • The size of the response.
  • The response type.
  • Timestamps.
  • Response code.

Another possibility for testing is to ask the AI whether the response is correct. The image shows how this could work.

Automatic tests for natural language responses

In this example, the unit test verifies whether a method executes appropriately. The method only requests texts about a specific topic and responds. The test uses a new request to the API service, which will certify that the response has the same type of text that was requested previously. Performing this type of test can be risky if you use an AI service that charges per request. Therefore, it is essential to use this test only when it is essential.

These tests could help you improve your requests’ refinement, considering that you will always receive a natural response. In this case, if you need to implement some test that considers boolean responses, you need to be specific on your requests in the refinement step.

Step 5 — Refinement

The refinement stage of integrating your system with AI services is a crucial step to improve the responses obtained. This stage can be carried out considering two perspectives: AIs requiring training and AI services using already trained models.

This article will only consider the second perspective, where your software could use just services with trained AI. In this perspective, the refinement stage involves testing and monitoring the integration performance, adjusting the input data for the AI service when necessary to ensure that it continues to provide accurate and relevant responses. For example, OpenAI services provide models such as text-davinci-edit-001, which can be used to generate natural language texts.

When your application doesn’t need an AI that requires training, you can use a trained AI by adapting your requests to have specific responses. For example, when working with a text model, the model receives and responds to you in natural language. To get your response in a specific model, request it explicitly. Like in this input, which precisely determines the correct response:

const textType = "sci-fy"
const textRecommendation = "A blue house with birds"
const orientations = "Do not do comments about your response,
do not write any different orientation,
just return a "+ textType +"text considering
the recommendation. The recommendation are:"

//Considering we have the fetch encapsuled inside a method
const response = fetchPost("/completions",
"text-davinci-003",
orientations + textRecommendation)

This is just one way to solve the refinement step. For complex or high-performance systems, it may be necessary to explore how to improve the quality of trained AI models, including considering observability, error handling, and performance. As with many aspects of software development, assessing the complexity level and determining whether a trained AI or training with data and specifications is the best approach is essential.

Do you want to work on interesting website projects with world-class clients? Visit the ArcTouch careers page and join us!

References

[1]“McCulloch and Pitts”, Utsa.edu. [Online].

[2] A. M. Turing, “Computing machinery and intelligence”, Umbc.edu. [Online]

[3] J. Cobbe e J. Singh, “Artificial intelligence as a service: Legal responsibilities, liabilities, and policy challenges”, Comput. Law Secur. Rep. 2021.

[4] Openai.com. [Online].

--

--

Leticia Coelho
ArcTouch

Software Engineer @ArcTouch | Telecommunications Engineer | Automation & Systems Engineer Masters student | Tech Mentor | IoT Consultant |