feat(sqlalchemy): reverted not needed api change

This commit is contained in:
Jonathan Rohde 2024-06-25 08:29:18 +02:00
parent 642c352c69
commit d4b6b7c4e8
4 changed files with 15 additions and 6 deletions

View File

@ -56,7 +56,7 @@ async def add_new_model(
############################
@router.get("/{id}", response_model=Optional[ModelModel])
@router.get("/", response_model=Optional[ModelModel])
async def get_model_by_id(id: str, user=Depends(get_verified_user)):
model = Models.get_model_by_id(id)

View File

@ -42,9 +42,9 @@ class TestModels(AbstractPostgresTest):
assert len(response.json()) == 1
with mock_webui_user(id="2"):
response = self.fast_api_client.get(self.create_url("/my-model"))
response = self.fast_api_client.get(self.create_url(query_params={"id": "my-model"}))
assert response.status_code == 200
data = response.json()
data = response.json()[0]
assert data["id"] == "my-model"
assert data["name"] == "Hello World"

View File

@ -23,14 +23,20 @@ def get_fast_api_client():
class AbstractIntegrationTest:
BASE_PATH = None
def create_url(self, path):
def create_url(self, path="", query_params=None):
if self.BASE_PATH is None:
raise Exception("BASE_PATH is not set")
parts = self.BASE_PATH.split("/")
parts = [part.strip() for part in parts if part.strip() != ""]
path_parts = path.split("/")
path_parts = [part.strip() for part in path_parts if part.strip() != ""]
return "/".join(parts + path_parts)
query_parts = ""
if query_params:
query_parts = "&".join(
[f"{key}={value}" for key, value in query_params.items()]
)
query_parts = f"?{query_parts}"
return "/".join(parts + path_parts) + query_parts
@classmethod
def setup_class(cls):

View File

@ -63,7 +63,10 @@ export const getModelInfos = async (token: string = '') => {
export const getModelById = async (token: string, id: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/models/${id}`, {
const searchParams = new URLSearchParams();
searchParams.append('id', id);
const res = await fetch(`${WEBUI_API_BASE_URL}/models?${searchParams.toString()}`, {
method: 'GET',
headers: {
Accept: 'application/json',