feat: Vllm url support v1
parent
6ddad88357
commit
d2463abaac
|
|
@ -158,9 +158,12 @@ class PromptGenerateSerializer(serializers.Serializer):
|
||||||
q = prompt.replace("{userInput}", message)
|
q = prompt.replace("{userInput}", message)
|
||||||
messages[-1]['content'] = q
|
messages[-1]['content'] = q
|
||||||
|
|
||||||
model_exist = QuerySet(Model).filter(workspace_id=workspace_id, id=model_id).exists()
|
model_exist = QuerySet(Model).filter(workspace_id=workspace_id,
|
||||||
|
id=model_id,
|
||||||
|
model_type = "LLM"
|
||||||
|
).exists()
|
||||||
if not model_exist:
|
if not model_exist:
|
||||||
raise Exception(_("model does not exists"))
|
raise Exception(_("Model does not exists or is not an LLM model"))
|
||||||
|
|
||||||
def process():
|
def process():
|
||||||
model = get_model_instance_by_model_workspace_id(model_id=model_id, workspace_id=workspace_id)
|
model = get_model_instance_by_model_workspace_id(model_id=model_id, workspace_id=workspace_id)
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,11 @@ class VllmBgeReranker(MaxKBBaseModel, BaseDocumentCompressor):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
|
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
|
||||||
|
r_url = model_credential.get('api_url')[:-3] if model_credential.get('api_url').endswith('/v1') else model_credential.get('api_url')
|
||||||
return VllmBgeReranker(
|
return VllmBgeReranker(
|
||||||
model=model_name,
|
model=model_name,
|
||||||
api_key=model_credential.get('api_key'),
|
api_key=model_credential.get('api_key'),
|
||||||
api_url=model_credential.get('api_url'),
|
api_url=r_url,
|
||||||
params=model_kwargs,
|
params=model_kwargs,
|
||||||
**model_kwargs
|
**model_kwargs
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,9 @@ class VllmWhisperSpeechToText(MaxKBBaseModel, BaseSpeechToText):
|
||||||
self.speech_to_text(audio_file)
|
self.speech_to_text(audio_file)
|
||||||
|
|
||||||
def speech_to_text(self, audio_file):
|
def speech_to_text(self, audio_file):
|
||||||
base_url = f"{self.api_url}/v1"
|
|
||||||
|
base_url = self.api_url if self.api_url.endswith('v1') else f"{self.api_url}/v1"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client = OpenAI(
|
client = OpenAI(
|
||||||
api_key=self.api_key,
|
api_key=self.api_key,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue