This repository hosts instructions and code needed to build a chatbot that integrates SAP data with Azure OpenAI's advanced GPT-35-turbo AI model, hosted on Azure. The bot is designed to address user queries regarding specific products available in an SAP system, including details about the product's name, ID, and other properties.
Before you start, make sure you have the following prerequisites:
Azure subscription https://azure.microsoft.com/en-us/
Azure Cognitive Services Instance https://azure.microsoft.com/en-us/products/cognitive-services/#overview
Azure OpenAI Service Instance https://azure.microsoft.com/en-us/products/cognitive-services/openai-service/
A SAP system with some product data
- ES5 Demo system comes with a good setup of EPM data model with Odata service, https://developers.sap.com/tutorials/gateway-demo-signup.html,
Python 3.7 or later installed on your machine (Visual Studio Code):
AzureBot setup (reference URL : https://accessibleai.dev/post/create_and_deploy_bot/)
- AzureBot service will be connected to Micrsoft Teams as Channel
Here is the overall build flow and solution desing for the SAP Bot with ChatGPT.
-
Setup the Local Project
- To use of Visual Studio Code, createa your local project for Azure Functions, https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs-code?tabs=csharp
-
Replace code (_init.py, main.py, function.json, requirement.txt)
2.1 Install the required packages: Navigate to the project directory and install the required Python packages using the following commands
pip install -r requirements.txt
2.2 Local project testing setup The solution is using APP@FastAPI, in order to test in local, you need to install the below as well in the (.venv)
2.3 Testing with Postman
2.4 Deploy to Azure Functions
2.4.1 Testign with Azure Function App
2.4.2 Get Function URL with KEY for the integration of AzureBot.
- Setup Azure Bot connection to Teams
-
Make sure you have up and running AzureBot after you follow the reference blog AzureBot setup (reference URL : https://accessibleai.dev/post/create_and_deploy_bot/)
-
Replace line 16 : Private readonly string _azureFunctionUrl = ""; with URL from section 2.4.2
-
Save All
-
Rebuild
-
Publish
The main components of the code are:
main.py: This is the main script that runs the process query. It uses the OpenAI API to process user queries and returns the appropriate responses.
_init.py: This script is responsible for connecting to the SAP system and fetching product data to HTTP trigger to AzureBot..
With the SAP Bot, you can easily fetch and interact with your SAP data using natural language queries. Leveraging the power of OpenAI's GPT model and Azure's robust infrastructure, this bot can be a valuable tool for anyone needing quick and easy access to their SAP data.
Feel free to clone, modify, and use this project as you see fit. If you have any questions or suggestions, please open an issue or submit a pull request.