Skip to content

Commit b486d51

Browse files
committed
fix: handle optional IP address in chat creation and filter model kwargs in embedding
1 parent b5ec773 commit b486d51

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

apps/models_provider/impl/volcanic_engine_model_provider/model/embedding.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ def is_cache_model():
2424

2525
@staticmethod
2626
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
27+
optional_params = MaxKBBaseModel.filter_optional_params(model_kwargs)
2728
return VolcanicEngineEmbeddingModel(
2829
api_key=model_credential.get("api_key"),
2930
model=model_name,
3031
api_base=model_credential.get("api_base"),
31-
**model_kwargs
32+
**optional_params
3233
)
3334

3435
def embed_query(self, text: str):

apps/trigger/handler/impl/task/application_task.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,16 @@ def execute(self, trigger_task, **kwargs):
203203
parameters['stream'] = True
204204
parameters['chat_record_id'] = chat_record_id
205205
message = parameters.get('message')
206+
ip_address = '-'
207+
if kwargs.get('body') is not None:
208+
ip_address = kwargs.get('body').get('ip_address')
206209
Chat.objects.get_or_create(id=chat_id, defaults={
207210
'application_id': application_id,
208211
'abstract': message,
209212
'chat_user_id': chat_user_id,
210213
'chat_user_type': ChatUserType.ANONYMOUS_USER.value,
211214
'asker': {'username': "游客"},
212-
'ip_address': kwargs.get('body')['ip_address'],
215+
'ip_address': ip_address,
213216
'source': {
214217
'type': ChatSourceChoices.TRIGGER.value
215218
},

0 commit comments

Comments
 (0)