Dołącz do BOT Libre projekt open source na BotLibre.org
Bot Libre Forum : The Bot Libre chat bot web API

RE: The Bot Libre chat bot web API

w malachite_gaming wysłany Jun 21 2023, 23:55

hi, im trying to modify the chat gpt proxy self script to use a different chat api. 

The API is based on the following guiding principles:

  • Only available over HTTPS.
  • Uses Bearer authentication with token in the Authorization header.
  • Utilizes standard HTTP verbs and error codes.
  • Parameters should be sent as JSON unless stated otherwise.
  • Always returns JSON (properties with null values will be omitted from the response).
  • All dates return in UTC time, using the ISO 8601 format YYYY-MM-DDTHH:MM:SSZ.

let response = await fetch('https://c486fc7bddd4472fb32bbbbd550bb3a3.weavy.io/api/users/demouser/tokens', { method: 'POST', headers: { 'content-type': 'application/json', 'Authorization': `Bearer <my api key>` }, body: JSON.stringify({ name: 'Demo User', expires_in: 7200 }) }); if (response.ok) { let resp = await response.json(); let accessToken = resp.access_token }

let response = await fetch('https://c486fc7bddd4472fb32bbbbd550bb3a3.weavy.io/api/apps/init', { method: 'POST', headers: { 'content-type': 'application/json', 'Authorization': `Bearer <my api key>` }, body: JSON.stringify({ app: { uid: "demochat", name: "Demo chat", type: "Chat" }, user: { uid: "demouser" } }) }); "Environment The Weavy environment is the backend of Weavy and takes care of all the server side logic and data storage.
The environment exposes a Web API and handles realtime communication through websockets and event notification via webhooks."
this is our enviroment: "https://c486fc7bddd4472fb32bbbbd550bb3a3.weavy.io"

// This script forwards the user's input and conversation to the Weavy API.
// Your Weavy API key and endpoint need to be filled in.

state Proxy {
pattern "*" answer proxy();

function proxy() {
var url = "https://your-weavy-endpoint";
var headers = new Object();
var apiKey = "your-weavy-api-key";

if (result === null || result.status !== 200) {
// Uncomment the next line to search the bot's responses when not available.
// return null;
return "Bot is not available";
}

var result = Http.postJSON(url, json, headers);

if (result == null) {
// Uncomment the next line to search the bot's responses when not available.
// return null;
return "Bot is not available";
}

var text = result.message; // Modify this line based on the response format from Weavy

return text;
}
}

 

this is what i tried and failed at. Do you know a way?


Identyfikator: 47970459
Wysłany: Jun 21 2023, 23:55
Odpowiedzi: 0
Widok: 1016, dziś: 3, tydzień: 15, miesiąc: 76
0 0 0.0/5