@@ -71,6 +71,19 @@ pub struct InferenceGatewayClient {
7171 token : Option < String > ,
7272}
7373
74+ pub trait InferenceGatewayAPI {
75+ fn list_models ( & self ) -> Result < Vec < ProviderModels > , Box < dyn Error > > ;
76+
77+ fn generate_content (
78+ & self ,
79+ provider : Provider ,
80+ model : & str ,
81+ messages : Vec < Message > ,
82+ ) -> Result < GenerateResponse , Box < dyn Error > > ;
83+
84+ fn health_check ( & self ) -> Result < bool , Box < dyn Error > > ;
85+ }
86+
7487impl InferenceGatewayClient {
7588 pub fn new ( base_url : & str ) -> Self {
7689 Self {
@@ -84,8 +97,10 @@ impl InferenceGatewayClient {
8497 self . token = Some ( token. into ( ) ) ;
8598 self
8699 }
100+ }
87101
88- pub fn list_models ( & self ) -> Result < Vec < ProviderModels > , Box < dyn Error > > {
102+ impl InferenceGatewayAPI for InferenceGatewayClient {
103+ fn list_models ( & self ) -> Result < Vec < ProviderModels > , Box < dyn Error > > {
89104 let url = format ! ( "{}/llms" , self . base_url) ;
90105 let mut request = self . client . get ( & url) ;
91106 if let Some ( token) = & self . token {
@@ -97,7 +112,7 @@ impl InferenceGatewayClient {
97112 Ok ( models)
98113 }
99114
100- pub fn generate_content (
115+ fn generate_content (
101116 & self ,
102117 provider : Provider ,
103118 model : & str ,
@@ -118,7 +133,7 @@ impl InferenceGatewayClient {
118133 Ok ( response)
119134 }
120135
121- pub fn health_check ( & self ) -> Result < bool , Box < dyn Error > > {
136+ fn health_check ( & self ) -> Result < bool , Box < dyn Error > > {
122137 let url = format ! ( "{}/health" , self . base_url) ;
123138 let response = self . client . get ( & url) . send ( ) ?;
124139 Ok ( response. status ( ) . is_success ( ) )
0 commit comments