-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add detector type to config #205
Conversation
d620933
to
4e9400d
Compare
@@ -129,16 +129,31 @@ impl From<tonic::Status> for Error { | |||
pub struct HttpClient { | |||
base_url: Url, | |||
client: reqwest::Client, | |||
detector_type: DetectorType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this okay, or should we have a "subclass" for detector clients?
pub fn endpoint(&self) -> String { | ||
let path = match self.detector_type { | ||
DetectorType::Content => "/api/v1/text/contents", | ||
DetectorType::Generated => "/api/v1/text/generation", | ||
DetectorType::Chat => "/api/v1/text/context/chat", | ||
DetectorType::Context => "/api/v1/text/context/doc", | ||
}; | ||
self.base_url.join(path).unwrap().to_string() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to return String
, &'static str
or &Url
here?
#[cfg_attr(test, derive(PartialEq))] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum DetectorType { | ||
#[default] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: even though this is set as default, "type" is mandatory on the YAML.
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
This reverts commit 96c5098. Signed-off-by: Mateus Devino <[email protected]>
Signed-off-by: Mateus Devino <[email protected]>
8a817b9
to
61348f3
Compare
Signed-off-by: Mateus Devino <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not add detector concepts, e.g. detector_type
and endpoint
with detector-specific endpoints to HttpClient
. This is meant to be a reusable abstraction for any HTTP API, e.g. we will be using it for the upcoming OpenAI chat & chat completions implementation.
@declark1 Agreed, but not quite sure on how to go about this in a Rusty way. Should I move these out to a trait, or create a whole new struct? |
Closing this as we are consolidating client-related changes into #220 |
This addresses #165.
I'm opening this as I'd like to get some feedback on what I've done so far.
Missing tasks:
text_contents(),
text_generation()and
text_context_doc()` - as faux has a limitation when dealing with generics, I've rolled back this change and will work on it in a different PR.