This project provides a ServiceNow application to facilitate the integration between ServiceNow instances and Azure's OpenAI service. It enables the sending of prompts to Azure OpenAI and receiving responses, which can be utilized within ServiceNow for various purposes such as chatbots, automated customer support, and more.
- Easy Configuration: Set up your Azure OpenAI API key, endpoint, version, and deployment ID directly within the script.
- Flexible Messaging: Supports adding user, assistant, and system messages to the context sent to Azure OpenAI.
- Customizable Parameters: Adjust the behavior of the OpenAI model with parameters like
maxTokens
,temperature
,topP
,frequencyPenalty
, andpresencePenalty
. - Context Management: Maintain a conversation context to make interactions with the AI more coherent and contextually aware.
Before you can use this integration, you'll need:
- An Azure account with access to OpenAI services.
- A ServiceNow instance where you can create or modify Script Includes.
-
Azure OpenAI Configuration: Ensure you have an Azure OpenAI API key, endpoint, API version, and deployment ID. These will be used to configure the script include to communicate with Azure OpenAI.
-
Clone the repository: Clone the repository to your own Github account.
-
Link the repository to your SN instance: Create a personal access token and store this in a SN credential record. More info from SN on this process here.
-
Pull the source code: Once the connection is made you can pull the source code to your instance.
-
System Properties: Ensure you set the following global system properties according to the values in your Azure OpenAI environment.
azure_openai.api_key
azure_openai.api_version
azure_openai.api_endpoint
azure_openai.deployment_id
After setting up the Script Include, you can use it in your ServiceNow applications to interact with Azure OpenAI. Here's a basic example of sending a prompt and receiving a response:
var openAI = new x_bits2_az_openai.AzureOpenAI();
gs.info(openAI.prompt('hello world'));
// output: Hello there! How can I assist you today?
You can customize the behavior of the Azure OpenAI model by adjusting the parameters in the AzureOpenAI
object, such as MAX_TOKENS
, TEMPERATURE
, TOP_P
, etc., to fine-tune the AI's responses based on your requirements.
Contributions to this project are welcome! Please fork the repository and submit a pull request with your enhancements or fixes.
This project is licensed under the MIT License.