Skip to content

Commit

Permalink
✨ feat(controller): add option to hide long text in tagger response
Browse files Browse the repository at this point in the history
Added `hidden_long_text` parameter to `tagger` method to control
the display of long text responses. Updated relevant method calls
to include the new parameter.
  • Loading branch information
sudoskys committed Sep 27, 2024
1 parent ef02ba2 commit ef862c8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions app/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def download(self, file):
downloaded_file = await self.bot.download_file(_file_info.file_path)
return downloaded_file

async def tagger(self, file) -> str:
async def tagger(self, file, hidden_long_text=False) -> str:
raw_file_data = await self.download(file=file)
if raw_file_data is None:
return "🥛 Not An image"
Expand All @@ -56,7 +56,7 @@ async def tagger(self, file) -> str:
result = await pipeline_tag(trace_id="test", content=file_data)
content = [
f"**🥽 AnimeScore: {result.anime_score}**",
f"**🔍 Infer Tags**: " f"\n>{result.anime_tags}\n",
"**🔍 Infer Tags**",
]
try:
file_data.seek(0)
Expand All @@ -73,8 +73,11 @@ async def tagger(self, file) -> str:
mode += "+VibeTransfer"
except Exception as e:
logger.info(f"Empty metadata {e}")
content.append(f"\n```{result.anime_tags}```\n")
else:
content.append(f"**📦 Description:** \n>{read_prompt}\n")
content.append(f"\n>{result.anime_tags}\n")
if read_prompt:
content.append(f"**📦 Prompt:** `{read_prompt}`")
if read_model:
content.append(f"**📦 Model:** `{read_model.value}`")
if meta_data.Source:
Expand Down Expand Up @@ -164,10 +167,14 @@ async def tag(message: types.Message):
reply_message_ph = reply_message.photo
reply_message_doc = reply_message.document
if reply_message_ph:
prompt = await self.tagger(file=reply_message_ph[-1])
prompt = await self.tagger(
file=reply_message_ph[-1], hidden_long_text=True
)
return await bot.reply_to(message, text=prompt, parse_mode="MarkdownV2")
if reply_message_doc:
prompt = await self.tagger(file=reply_message_doc)
prompt = await self.tagger(
file=reply_message_doc, hidden_long_text=True
)
return await bot.reply_to(message, text=prompt, parse_mode="MarkdownV2")
return await bot.reply_to(message, text="🥛 Not image")

Expand Down

0 comments on commit ef862c8

Please sign in to comment.