Connecting Zoho Cliq with an open AI assistant
I am looking to connect with an openai assistant. I have successfully connected open ai chat but can not get the assistant connected.
Code:
<variable> = <expression> ;
response = Map();
info message;
response = Map();
question = message;
// Need to add openAI token
token = "*******";
Assistant_ID = "*******"
header = Map();
header.put("Authorization",token);
header.put("OpenAI-Beta","assistants=v2");
header.put("Content-Type","application/json");
params = {"model":"gpt-3.5-turbo-instruct","prompt":question,"temperature":0.9,"max_tokens":256,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"stop":{" Human:"," AI:"}};
// Making post request
fetchCompletions = invokeurl
[
url :"https://api.openai.com/v1/assistants/{Assistant_ID}/completions"
type :POST
parameters:params.toString()
headers:header
detailed:true
];
info "Fetch Completions: " + fetchCompletions;
if(fetchCompletions.get("responseCode") == 200)
{
// Populating the response to human readable format
answer = fetchCompletions.get("responseText").get("choices").getJSON("text");
info "answer" + answer;
response.put("text",answer);
}
else if(fetchCompletions.get("responseCode") == 429)
{
response = {"text":fetchCompletions.get("responseText").get("error").get("message")};
}
// Deluge task used to post message in channel as bot
info response;
info zoho.cliq.postToBot("internalprocedures",response);
return Map();