Skip to content

rwth-acis/las2peer-openai-service

Repository files navigation

las2peer-openai-service

This service acts as a wrapper for the social bot manager service to use OpenAI API functions.

Preparations

Java

Build Dependencies

Important Repositories:

How to run with the Social-Bot-Manager Service

Start a las2peer network as usual with the Social-Bot-Manager service at the default port 9011

Gradle build the las2peer-openai-service and add your IP Address to the bootstrap flag -b YOUR_IP_ADDRESS:9011 in /bin/start_network.sh

java -cp ... --port 9012 -b YOUR_IP_ADDRESS:9011 --service-directory service uploadStartupDirectory startService\(\'[email protected]\'\) startWebConnector interactive

The REST-API will be available via http://localhost:8080/openai and the las2peer node is available via port 9011.

Bot Functions

Path Function name Description Parameters Returns
/personalize personalize Sends the current conversation path, including the most recent prompt and the bot's original response to it, to OpenAI's chat completion function to generate a more personalized response. model: specify an openai model
openaikey: insert your own openaiKey
messages: Contains a list of system messages that primes chatGPT. Each message is formatted as a map, with "role" and "content" as the keys. (e.g. Role: "system", content: "You are an assistant that personalizes the generated example assistant message and returns it")
conversationPath: Contains the entire conversation path between the user and the bot along with the most recent user prompt, with each message structured in the same way as specified above
openai A flag that indicates the request was an openai request
text: The personalized response from OpenAI
tokens: total tokens used
/chat chat Handles standard messages that are not recognized by the NLU training model and forwards the message to OpenAI's chat completion function to not interrupt the chat flow. model: specify an openai model
openaikey: insert your own openaiKey
systemMessage: define your own system Prompt (Default: "You are a helpul assistant that helps students with their questions.")
msg: user message
text: Response from OpenAI
costs: total costs and total tokens used