Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Does Not Return a Web Format #9

Open
smcgregor opened this issue May 25, 2022 · 7 comments
Open

API Does Not Return a Web Format #9

smcgregor opened this issue May 25, 2022 · 7 comments

Comments

@smcgregor
Copy link
Contributor

The API is currently returning data in string format like, '[(0.9944695830345154, 73), (0.9944115281105042, 160), (0.994175374507904, 81)]' is not a web format. It should return JSON formatted data.

@olsonadr
Copy link
Collaborator

olsonadr commented May 25, 2022

To be clear, are we looking for:

{
  "msg": [
    { "score": 0.994469,
      "incident_id": 73  },
    { "score": 0.994411,
      "incident_id": 160  }
  ]
}

or similar?

@smcgregor
Copy link
Contributor Author

That would work. Right now I need to do something like below, which is a lot more hacky than JSON.parse (which could process the above).

Screen Shot 2022-05-24 at 10 19 00 PM

msg also looks like it is from an example and likely should either be renamed, or the document beneath it should replace it.

@olsonadr
Copy link
Collaborator

With msg I was trying to encapsulate the return value response from the server away from header and warning information but we can modify that for sure. The string representation is very helpful for internal python work, so would it be absurd to return the data in json format as well as a string, side-by-side?

@smcgregor
Copy link
Contributor Author

Encapsulation is fine, but it isn't really a message, it is a result, a collection of similar, or another label.

But Python understands JSON as well...

import json
doc = json.loads(string_representation_json)
str_representation = json.dumps(doc)

@olsonadr
Copy link
Collaborator

We were specifically using the string because it can be literal_eval'd directly to the format that PyTorch likes for cosine similarity, but I suppose we could always write a function that generates json from the list / iterates through the json to generate that list. I'm not personally set on anything.

Would result be a redundant/poor choice for an encapsulating layer?

@smcgregor
Copy link
Contributor Author

Isn't this the result of cosine similarity and not the input to that function?

Result works. Something more specific is a bit better though.

@olsonadr
Copy link
Collaborator

It is the result but also may be the input for future endeavors in additional lambdas and such, we were wanting to talk about that this coming meeting, and I talk about it briefly in the PR I just opened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants