mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 19:09:14 -04:00
fix: LM Studio url and endpoints
This commit is contained in:
23
providers/ProviderUrlUtils.hpp
Normal file
23
providers/ProviderUrlUtils.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace QodeAssist::Providers {
|
||||
|
||||
// LM Studio presents its OpenAI-compatible API as <host>/v1/..., while the
|
||||
// OpenAI-style clients expect the base URL to already include /v1. Accept the
|
||||
// configured URL either with or without the /v1 suffix and return it normalized.
|
||||
inline QString ensureOpenAIV1Base(const QString &url)
|
||||
{
|
||||
QString base = url.trimmed();
|
||||
while (base.endsWith(QLatin1Char('/')))
|
||||
base.chop(1);
|
||||
if (!base.endsWith(QStringLiteral("/v1")))
|
||||
base += QStringLiteral("/v1");
|
||||
return base;
|
||||
}
|
||||
|
||||
} // namespace QodeAssist::Providers
|
||||
Reference in New Issue
Block a user