Skip to content

API docs

Alex edited this page Feb 19, 2023 · 4 revisions

App currently has two main api endpoints:

/api/answer

Its a POST request that sends a JSON in body with 4 values. Here is a JavaScript fetch example It will recieve an answer for a user provided question

// answer (POST http://127.0.0.1:5000/api/answer)
fetch("http://127.0.0.1:5000/api/answer", {
      "method": "POST",
      "headers": {
            "Content-Type": "application/json; charset=utf-8"
      },
      "body": JSON.stringify({"question":"Hi","history":null,"api_key":"OPENAI_API_KEY","embeddings_key":"OPENAI_API_KEY",
      "active_docs": "javascript/.project/ES2015/openai_text-embedding-ada-002/"})
})
.then((res) => res.text())
.then(console.log.bind(console))

In response you will get a json document like this one:

{
  "answer": " Hi there! How can I help you?\n",
  "query": "Hi",
  "result": " Hi there! How can I help you?\nSOURCES:"
}

/api/docs_check

It will make sure documentation is loaded on a server (just run it everytime user is switching between libraries (documentations) Its a POST request that sends a JSON in body with 1 value. Here is a JavaScript fetch example

// answer (POST http://127.0.0.1:5000/api/docs_check)
fetch("http://127.0.0.1:5000/api/docs_check", {
      "method": "POST",
      "headers": {
            "Content-Type": "application/json; charset=utf-8"
      },
      "body": JSON.stringify({"docs":"javascript/.project/ES2015/openai_text-embedding-ada-002/"})
})
.then((res) => res.text())
.then(console.log.bind(console))

In response you will get a json document like this one:

{
  "status": "exists"
}
Clone this wiki locally