Skip to content

Commit c591e96

Browse files
committed
feat: Vllm url support v1
1 parent 6ddad88 commit c591e96

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

apps/chat/serializers/chat.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,12 @@ def generate_prompt(self, instance: dict, with_valid=True):
158158
q = prompt.replace("{userInput}", message)
159159
messages[-1]['content'] = q
160160

161-
model_exist = QuerySet(Model).filter(workspace_id=workspace_id, id=model_id).exists()
161+
model_exist = QuerySet(Model).filter(workspace_id=workspace_id,
162+
id=model_id,
163+
model_type = "LLM"
164+
).exists()
162165
if not model_exist:
163-
raise Exception(_("model does not exists"))
166+
raise Exception(_("Model does not exists or is not an LLM model"))
164167

165168
def process():
166169
model = get_model_instance_by_model_workspace_id(model_id=model_id, workspace_id=workspace_id)

apps/models_provider/impl/vllm_model_provider/model/reranker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ def is_cache_model():
2828

2929
@staticmethod
3030
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
31+
r_url = model_credential.get('api_url')[:-3] if model_credential.get('api_url').endswith('/v1') else model_credential.get('api_url')
3132
return VllmBgeReranker(
3233
model=model_name,
3334
api_key=model_credential.get('api_key'),
34-
api_url=model_credential.get('api_url'),
35+
api_url=r_url,
3536
params=model_kwargs,
3637
**model_kwargs
3738
)

apps/models_provider/impl/vllm_model_provider/model/whisper_sst.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def check_auth(self):
4444
self.speech_to_text(audio_file)
4545

4646
def speech_to_text(self, audio_file):
47-
base_url = f"{self.api_url}/v1"
47+
48+
base_url = self.api_url if self.api_url.endswith('v1') else f"{self.api_url}/v1"
49+
4850
try:
4951
client = OpenAI(
5052
api_key=self.api_key,

0 commit comments

Comments
 (0)