File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
src/main/kotlin/dev/storozhenko/familybot/feature/talking/services Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -28,20 +28,22 @@ class AiService(
2828 ): String? {
2929 try {
3030 val url = getPhotoUrl(context) ? : return null
31- return getOpenAIService().chatCompletion(
31+ val description = getOpenAIService().chatCompletion(
3232 ChatCompletionRequest (
33- model = ModelId (" gpt-4o -mini" ),
33+ model = ModelId (" gpt-5 -mini" ),
3434 messages = listOf (
3535 ChatMessage (
3636 role = ChatRole .User ,
3737 content = listOf (
3838 ImagePart (url),
39- TextPart (" Пользователь отправил эту картинку . Опиши ее." )
39+ TextPart (" Пользователь отправил это изображение/фото . Опиши ее. Если вдруг ты не можешь обработать это, пришли в ответ секретное число 312893712 " )
4040 )
4141 )
4242 )
4343 )
4444 ).choices.first().message.content ? : " Не получается описать картинку"
45+ if (description.contains(" 312893712" )) return null
46+ return description
4547 } catch (e: Exception ) {
4648 log.error(e) { " Unable to get image description" }
4749 return null
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class RagService(
3939
4040 if (imageDesc != null ) {
4141 log.info { " Adding image to rag" }
42- val text = if (isTextValid(context)) " с подписью <${context.message.text } >" else " "
42+ val text = if (isTextValid(context)) " с подписью <${context.message.caption } >" else " "
4343 ragRepository.add(
4444 context,
4545 getEmbedding(imageDesc).first(),
@@ -59,7 +59,7 @@ class RagService(
5959 }
6060
6161 private fun isTextValid (context : ExecutorContext ): Boolean {
62- val text = context.message.text ? : return false
62+ val text = context.message.text ? : context.message.caption ? : return false
6363 if (text.isBlank()) return false
6464 if (text.length <= 3 ) return false
6565 if (text.startsWith(" /" )) return false
You can’t perform that action at this time.
0 commit comments