Add helper functions to detect bad responses#31
Conversation
| Query = str | ||
| Context = str | ||
| Prompt = str |
There was a problem hiding this comment.
note to self, will want to check how/if these appear in docs
| context=cast(str, context), | ||
| query=cast(str, query), |
There was a problem hiding this comment.
just curious, do we need the cast(str) here? I would've thought type checker would be smart enough to know it's a str but maybe not
There was a problem hiding this comment.
Don't remember why, but it complained there.
There was a problem hiding this comment.
Ah it seems like because we're assigning the context is not None and query is not None to a variable and then doing the if check, mypy is not able to realize context and query aren't null 🥲
There was a problem hiding this comment.
Ahh yes, now I remember!
axl1313
left a comment
There was a problem hiding this comment.
just one question, but looks good otherwise!
| if TYPE_CHECKING: | ||
| try: | ||
| from cleanlab_studio.studio.trustworthy_language_model import TLM # type: ignore | ||
| except ImportError: | ||
| TLM = TLMProtocol | ||
| else: | ||
| TLM = TLMProtocol |
There was a problem hiding this comment.
Is there a need to do the if TYPE_CHECKING: try import TLM?
There was a problem hiding this comment.
I suppose not, no. I'll remove it and stick with using the type alias:
TLM = TLMProtocolThere was a problem hiding this comment.
Actually, what do you say about doing, the following:
- class TLMProtocol(Protocol):
+ class TLM(Protocol):
...There was a problem hiding this comment.
Yeah renaming the protocol class to TLM sounds good to me
There was a problem hiding this comment.
Side note, from the from cleanlab_studio import ... # type: ignore, I was reminded that our client libraries don't export types; we could fix that, and then we can use the exported types here. https://github.com/cleanlab/cleanlab-studio-integration/issues/1861
Files copied from #11.
Specificall, from: 49f9a9d