Skip to content

SK_Connector API Interface

Jose Moreira Batista Neto edited this page Dec 15, 2023 · 4 revisions

The C# Web API Connector Class serves as an interface for interacting with various Semantic Kernel AI functions including basic calls to Semantic Kernel functions, perform CRUD operation on SK Functions and execute basic memory operations.

Screenshot

POST: /Function/Execute

Purpose:

Execute a specific semantic function (aka, skill). This API end point will use OpenAI’s Completion API end point, and does not recall existing knowledge base/memory configured for this copilot, to generate responses with relevant information.

Input Parameter(s):

Screenshot

Execute Semantic Function

Description: Executes a specified function.

URL: /Function/Execute
Method: POST
Request Parameters:
pluginName (string): The name of the plugin containing the function.
functionName (string): The name of the function to execute.
input (string): The input data for the function.
Response:
Success: 200 OK, with the function execution result.
Error: 400 Bad Request if an error occurs during execution.

POST: /Function/ExecuteWithMemory

Purpose

Execute a specific semantic function (aka, skill) with OpenAI’s Temperature setting, Reverence setting, and input query string. This API end point will retrieve/recall existing knowledge base/memory configured for this specific skill to generate responses with relevant information. Note that the specific skill should implement the Recall tag functionality to make this API end point work. Otherwise, an error code will be returned.

Input parameters

Screenshot

Execute Semantic Function with Memory

Description: Executes a function with memory search.

URL: /Function/ExecuteWithMemory
Method: POST
Request Parameters:
pluginName (string): The name of the plugin containing the function.
functionName (string): The name of the function to execute.
Relevance (double): The relevance threshold for memory search.
input (string): The input data for the function.
Response:
Success: 200 OK, with the function execution result.
Error: 400 Bad Request if an error occurs during execution.
Not Found: 404 Not Found if the input is not found within the relevance threshold.

GET: /SK/ListPlugins

Purpose:

Return a list of available sills for this copilot. These skills can be configured and may come from the following categories:

  • Common or general skills from Semantic Kernal SDK, github or other open sources, such as CalendarSkill, ClassificationSkill, CodingSKill, WriterSKill, ChatSkill
  • First-party skills from Microsoft (such as skills for Microsoft 365 functionality) or other third-party providers’ skills
  • Custom-built skills for specific purposes, such as Clinical related skills similar to the Hackathon project for healthcare professionals’ custom copilot.

Input Parameter(s):

None

Screenshot

Description: Lists all available plugins and their functions.

URL: /SK/ListPlugins
Method: GET
Response:
Success: 200 OK, with a JSON document containing plugin information.
Error: 400 Bad Request if an error occurs during execution.

CRUD Operations: Skills and Semantic Functions

The API supports Uploading Skills and Semantic Functions, Deleting or Retrieving the Prompt and Configuration JSON for Semantic Functions.

These are the endpoints for CRUD Operations:

Screenshot

## SkGet
Description: Retrieves the prompt and configuration for a specified function.

URL: /SK/Get
Method: GET
Request Parameters:
pluginName (string): The name of the plugin containing the function.
functionName (string): The name of the function.
Response:
Success: 200 OK, with a JSON document containing the prompt and configuration.
Not Found: 404 Not Found if the prompt file is not found.
Error: 400 Bad Request if an error occurs during execution.

## SKInsert
Description: Inserts a new prompt and configuration for a specified function.

URL: /SK/Post
Method: POST
Request Parameters:
pluginName (string): The name of the plugin containing the function.
functionName (string): The name of the function.
SKPrompt (string): The prompt for the function.
SkConfigjson (string, optional): The configuration JSON for the function.
Response:
Success: 200 OK if the prompt and configuration are successfully inserted.
Error: 400 Bad Request if an error occurs during execution.

## SKDelete
Description: Deletes the prompt and configuration for a specified function.

URL: /SK/Delete
Method: DELETE
Request Parameters:
pluginName (string): The name of the plugin containing the function.
functionName (string): The name of the function.
Response:
Success: 200 OK if the prompt and configuration are successfully deleted.
Not Found: 404 Not Found if the prompt file is not found.
Error: 400 Bad Request if an error occurs during execution.

GET: /Memory/List

Purpose

Return a list of memory items, which can be used for retrieving relevant information as part of the RAG pattern. These memory/knowledge base facts items are configurable and stored as files in Azure storage account. These memory/knowledge base facts can be categorized as follows:

  • Domain specific knowledge base facts: which should be curated and/or validated by human domain experts or extracted from authoritative data sources (for enterprise customers, this implies the internal curated and approved knowledge base). Example: Healthcare industry’s clinical policies or guidelines from authoritative sources such as government web sites, CDC.gov, FDA.gov or UK’s NIH web sites and/or enterprise’s own proprietary authoritative sources (such as CVS Pharmacy’s Drugs Database – containing all known drugs’ comprehensive info in the world).
  • Short-term memory: such as chat context info or most recent interactions with a specific user, recent patient medical records, etc.
  • Long-term memory: such as individual user’s profile (e.g., skills set, preference, interests) or organizational institution knowledge or history facts. Just like human intelligence, the impact of long-term memory is still a research topic. Based on our previous building custom copilot experience, we recommend setting up certain guiderails for long-term memory, such as valid duration (e.g., longer than 60 days and less than 3 years), relevance or impact scores curated by human experts, evaluating feedback from recent interactions with users, etc. to avoid overly relying on long-term memory. In other words, we recommend focusing on domain specific knowledge base and short-term memory initially until the development team (with support and feedback from business stakeholders and product owners) has gained confidence on combining both short-term and long-term memory together.

Input parameters(s):

None

Screenshot

Description: Lists items in the memory.

URL: /Memory/List
Method: GET
Response:
Success: 200 OK, with a JSON document containing memory items.
Error: 400 Bad Request if an error occurs during execution.

POST: /Memory/Search

Purpose

Search the list of memory items, which can be used for retrieving relevant information as part of the RAG pattern. These memory/knowledge base facts items are configurable and stored as files in Azure storage account.

Screenshot

Description: Searches for an item in the memory.

URL: /Memory/Search
Method: POST
Request Parameters:
Input (string): The input data for memory search.
Response:
Success: 200 OK, with the search result and relevance information.
Error: 400 Bad Request if an error occurs during execution.
Notes