33
44use std:: {
55 collections:: { HashMap , HashSet } ,
6- sync:: { Arc , RwLock } ,
6+ sync:: Arc ,
77} ;
88
9- use parking_lot:: Mutex ;
9+ use parking_lot:: { Mutex , RwLock } ;
1010
1111use dynamo_runtime:: component:: Component ;
1212use dynamo_runtime:: prelude:: DistributedRuntimeProvider ;
@@ -64,8 +64,8 @@ impl ModelManager {
6464 }
6565
6666 pub fn has_model_any ( & self , model : & str ) -> bool {
67- self . chat_completion_engines . read ( ) . unwrap ( ) . contains ( model)
68- || self . completion_engines . read ( ) . unwrap ( ) . contains ( model)
67+ self . chat_completion_engines . read ( ) . contains ( model)
68+ || self . completion_engines . read ( ) . contains ( model)
6969 }
7070
7171 pub fn model_display_names ( & self ) -> HashSet < String > {
@@ -77,23 +77,23 @@ impl ModelManager {
7777 }
7878
7979 pub fn list_chat_completions_models ( & self ) -> Vec < String > {
80- self . chat_completion_engines . read ( ) . unwrap ( ) . list ( )
80+ self . chat_completion_engines . read ( ) . list ( )
8181 }
8282
8383 pub fn list_completions_models ( & self ) -> Vec < String > {
84- self . completion_engines . read ( ) . unwrap ( ) . list ( )
84+ self . completion_engines . read ( ) . list ( )
8585 }
8686
8787 pub fn list_embeddings_models ( & self ) -> Vec < String > {
88- self . embeddings_engines . read ( ) . unwrap ( ) . list ( )
88+ self . embeddings_engines . read ( ) . list ( )
8989 }
9090
9191 pub fn add_completions_model (
9292 & self ,
9393 model : & str ,
9494 engine : OpenAICompletionsStreamingEngine ,
9595 ) -> Result < ( ) , ModelManagerError > {
96- let mut clients = self . completion_engines . write ( ) . unwrap ( ) ;
96+ let mut clients = self . completion_engines . write ( ) ;
9797 clients. add ( model, engine)
9898 }
9999
@@ -102,7 +102,7 @@ impl ModelManager {
102102 model : & str ,
103103 engine : OpenAIChatCompletionsStreamingEngine ,
104104 ) -> Result < ( ) , ModelManagerError > {
105- let mut clients = self . chat_completion_engines . write ( ) . unwrap ( ) ;
105+ let mut clients = self . chat_completion_engines . write ( ) ;
106106 clients. add ( model, engine)
107107 }
108108
@@ -111,22 +111,22 @@ impl ModelManager {
111111 model : & str ,
112112 engine : OpenAIEmbeddingsStreamingEngine ,
113113 ) -> Result < ( ) , ModelManagerError > {
114- let mut clients = self . embeddings_engines . write ( ) . unwrap ( ) ;
114+ let mut clients = self . embeddings_engines . write ( ) ;
115115 clients. add ( model, engine)
116116 }
117117
118118 pub fn remove_completions_model ( & self , model : & str ) -> Result < ( ) , ModelManagerError > {
119- let mut clients = self . completion_engines . write ( ) . unwrap ( ) ;
119+ let mut clients = self . completion_engines . write ( ) ;
120120 clients. remove ( model)
121121 }
122122
123123 pub fn remove_chat_completions_model ( & self , model : & str ) -> Result < ( ) , ModelManagerError > {
124- let mut clients = self . chat_completion_engines . write ( ) . unwrap ( ) ;
124+ let mut clients = self . chat_completion_engines . write ( ) ;
125125 clients. remove ( model)
126126 }
127127
128128 pub fn remove_embeddings_model ( & self , model : & str ) -> Result < ( ) , ModelManagerError > {
129- let mut clients = self . embeddings_engines . write ( ) . unwrap ( ) ;
129+ let mut clients = self . embeddings_engines . write ( ) ;
130130 clients. remove ( model)
131131 }
132132
@@ -136,7 +136,6 @@ impl ModelManager {
136136 ) -> Result < OpenAIEmbeddingsStreamingEngine , ModelManagerError > {
137137 self . embeddings_engines
138138 . read ( )
139- . unwrap ( )
140139 . get ( model)
141140 . cloned ( )
142141 . ok_or ( ModelManagerError :: ModelNotFound ( model. to_string ( ) ) )
@@ -148,7 +147,6 @@ impl ModelManager {
148147 ) -> Result < OpenAICompletionsStreamingEngine , ModelManagerError > {
149148 self . completion_engines
150149 . read ( )
151- . unwrap ( )
152150 . get ( model)
153151 . cloned ( )
154152 . ok_or ( ModelManagerError :: ModelNotFound ( model. to_string ( ) ) )
@@ -160,7 +158,6 @@ impl ModelManager {
160158 ) -> Result < OpenAIChatCompletionsStreamingEngine , ModelManagerError > {
161159 self . chat_completion_engines
162160 . read ( )
163- . unwrap ( )
164161 . get ( model)
165162 . cloned ( )
166163 . ok_or ( ModelManagerError :: ModelNotFound ( model. to_string ( ) ) )
0 commit comments