@@ -106,28 +106,31 @@ def get_all_pipelines():
106
106
107
107
return pipelines
108
108
109
+
109
110
def parse_frontmatter (content ):
110
111
frontmatter = {}
111
- for line in content .split (' \n ' ):
112
- if ':' in line :
113
- key , value = line .split (':' , 1 )
112
+ for line in content .split (" \n " ):
113
+ if ":" in line :
114
+ key , value = line .split (":" , 1 )
114
115
frontmatter [key .strip ().lower ()] = value .strip ()
115
116
return frontmatter
116
117
118
+
117
119
def install_frontmatter_requirements (requirements ):
118
120
if requirements :
119
- req_list = [req .strip () for req in requirements .split (',' )]
121
+ req_list = [req .strip () for req in requirements .split ("," )]
120
122
for req in req_list :
121
123
print (f"Installing requirement: { req } " )
122
124
subprocess .check_call ([sys .executable , "-m" , "pip" , "install" , req ])
123
125
else :
124
126
print ("No requirements found in frontmatter." )
125
127
128
+
126
129
async def load_module_from_path (module_name , module_path ):
127
130
128
131
try :
129
132
# Read the module content
130
- with open (module_path , 'r' ) as file :
133
+ with open (module_path , "r" ) as file :
131
134
content = file .read ()
132
135
133
136
# Parse frontmatter
@@ -139,8 +142,8 @@ async def load_module_from_path(module_name, module_path):
139
142
frontmatter = parse_frontmatter (frontmatter_content )
140
143
141
144
# Install requirements if specified
142
- if ' requirements' in frontmatter :
143
- install_frontmatter_requirements (frontmatter [' requirements' ])
145
+ if " requirements" in frontmatter :
146
+ install_frontmatter_requirements (frontmatter [" requirements" ])
144
147
145
148
# Load the module
146
149
spec = importlib .util .spec_from_file_location (module_name , module_path )
@@ -277,7 +280,7 @@ async def check_url(request: Request, call_next):
277
280
278
281
@app .get ("/v1/models" )
279
282
@app .get ("/models" )
280
- async def get_models ():
283
+ async def get_models (user : str = Depends ( get_current_user ) ):
281
284
"""
282
285
Returns the available pipelines
283
286
"""
0 commit comments