MCPcopy Create free account
hub / github.com/PAIR-code/lit / get_query_str

Method get_query_str

lit_nlp/notebook.py:70–87  ·  view source on GitHub ↗

Convert config object to query string for LIT URL.

(self)

Source from the content-addressed store, hash-verified

68 datapoints: Optional[Sequence[JsonDict]] = None
69
70 def get_query_str(self):
71 """Convert config object to query string for LIT URL."""
72 def _encode(v):
73 if isinstance(v, (list, tuple)):
74 return ','.join(v)
75 return v
76
77 string_params = {
78 k: _encode(v)
79 for k, v in attr.asdict(self).items()
80 if (v is not None and k != 'datapoints')
81 }
82 if self.datapoints:
83 for i, ex in enumerate(self.datapoints):
84 for field in ex:
85 string_params[f'data{i}_{field}'] = _encode(ex[field])
86
87 return '?' + urllib.parse.urlencode(string_params)
88
89
90class LitWidget(object):

Callers 2

_display_colabFunction · 0.80
_display_jupyterFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected