List model schemas. Only one in `offset`, `after` and `before` can be used at the same time. :param limit: the maximum number of model schemas to return. :param offset: the offset of model schemas to return. :param provider_id: the provider id to filter by. :param type: the
(
limit: int,
offset: Optional[int],
provider_id: Optional[str],
type: Optional[ModelType],
)
| 141 | |
| 142 | |
| 143 | async def list_model_schemas( |
| 144 | limit: int, |
| 145 | offset: Optional[int], |
| 146 | provider_id: Optional[str], |
| 147 | type: Optional[ModelType], |
| 148 | ) -> Tuple[List[ModelSchema], int, bool]: |
| 149 | """ |
| 150 | List model schemas. |
| 151 | Only one in `offset`, `after` and `before` can be used at the same time. |
| 152 | |
| 153 | :param limit: the maximum number of model schemas to return. |
| 154 | :param offset: the offset of model schemas to return. |
| 155 | :param provider_id: the provider id to filter by. |
| 156 | :param type: the model type to filter by. |
| 157 | :return: a tuple of (model schemas, total count, has more) |
| 158 | """ |
| 159 | |
| 160 | # Filter by provider_id and type |
| 161 | filtered_schemas = [ |
| 162 | schema |
| 163 | for schema in _model_schemas |
| 164 | if (provider_id is None or schema.provider_id == provider_id) and (type is None or schema.type == type.value or schema.type == ModelType.WILDCARD.value) |
| 165 | ] |
| 166 | |
| 167 | # Paginate |
| 168 | end_index = offset + limit |
| 169 | page = filtered_schemas[offset:end_index] |
| 170 | |
| 171 | # Check if there's more |
| 172 | has_more = end_index < len(filtered_schemas) |
| 173 | |
| 174 | return page, len(filtered_schemas), has_more |
| 175 | |
| 176 | |
| 177 | def get_provider(provider_id: str) -> Optional[Provider]: |
no outgoing calls
no test coverage detected