dglazkov / polymath

MIT License
132 stars 9 forks source link

Add a way to pass request info back in libraries #35

Open jkomoros opened 1 year ago

jkomoros commented 1 year ago

We have a few use cases that need an extra place to stash information--mainly for results from Library.query().

for example, we need a way to pass back:

Probably the easiest way is to add a details dict to the library format that's optional:

{
  //...
  //details is optional. It's typically only included in libraries generated by Library.query()
  "details": {
    //If message is provided, then any time this library is loaded via Library(), it will print that message to the console. This is useful for example to say "This library included some content that was filtered out. Contact alex@komoroske.com for an access key"
    "message": "A message",
    //Counts and all keys inside are optional
    "counts": {
      //How many chunks are included in the `content`, or would have been had they not been omitted.
      "chunks": 5
      //How many chunks were filtered out because they didn't match the filter criteria
      "filtered": 2,
     //How many chunks were filtered out because you didn't pass an access_token that had sufficient access. Hosts by default do not divulge this, but some choose to.
      "restricted": 3
    }
  }
  //...
}
jkomoros commented 1 year ago
dglazkov commented 1 year ago

yes