milharal-dev / nemli-nemlerei-bot

Um bot de discord para criar resumos baseado nas últimas mensagens de um canal
9 stars 1 forks source link

Multiple discord message support + .ipynb tests #21

Closed luksquaresma closed 4 months ago

luksquaresma commented 4 months ago

Added support for jupyter notebooks testing and multiple messages on discord.

Addresses:

ryukinix commented 4 months ago

Eu acho que os commits ainda tão bagunçados, o rebase não tá apropriado. Não acho que ele intencionalmente alterou pra 200, acho que é dessincronia. Se tiver dificuldade com o rebase, podemos ajudar.

Em qua., 24 de jul. de 2024 08:44, ⟠ Rodolfo De Nadai < @.***> escreveu:

@.**** requested changes on this pull request.

1 pergunta e 1 sugestão

In nemli/commands/utility/summarize.py https://github.com/milharal-dev/nemli-nemlerei-bot/pull/21#discussion_r1689619763 :

@@ -22,7 +22,7 @@ async def summarize_command( required=False, min_value=20, max_value=1000,

  • default=settings.discord_max_messages,
  • default=200,

Question: Pq removou a settings e fixou em 200? O @ryukinix https://github.com/ryukinix tinha comentado no discord da gente deixar como 100 isso, talvez para diminuir o contexto de conteúdo.

In nemli/commands/utility/summarize.py https://github.com/milharal-dev/nemli-nemlerei-bot/pull/21#discussion_r1689620721 :

@@ -66,9 +66,39 @@ async def summarize_command(

     # Here we are getting the summary from the response and sending it to the user
     summary = response.choices[0].message.content.strip()  # type: ignore
  • await interaction.followup.send(f"## Resumo das últimas {message_count} mensagens:\n{summary[:1900]}")
  • except Exception as err:
  • print(err)
  • response_list = response_to_list(summary, header=f"Resumo das últimas {message_count} mensagens")
  • for resp in response_list:
  • await interaction.followup.send(resp)

Question: Ainda precisamos testar o que o @mattpsvreis https://github.com/mattpsvreis comentou sobre essa chamada aqui correto?

In nemli/commands/utility/summarize.py https://github.com/milharal-dev/nemli-nemlerei-bot/pull/21#discussion_r1689623852 :

+def response_to_list(summary, header, counter=0):

  • counter += 1
  • msg_char_lim = 1900
  • msg_header = header + f", parte {counter}:\n"
  • l_marker = "\n"
  • Small responses

  • if len(summary) < msg_char_lim:
  • return [summary]
  • Line breaks

  • line_positions = [i for i, sub in enumerate(summary[: -len(l_marker)]) if sub == l_marker]
  • line_break = (
  • (
  • max([t for t in line_positions if t < msg_char_lim])
  • if any(map(lambda x: x < msg_char_lim, line_positions))

Suggestion: Mover essa map para fora do if, assim evitamos de percorrer 2 vezes a mesma lista de line_positions. Se eu entendi direito vc checa no any para ver se existe e depois faz o mesmo para pegar o max.

In nemli/config.py https://github.com/milharal-dev/nemli-nemlerei-bot/pull/21#discussion_r1689624607 :

@@ -4,7 +4,6 @@ class NemliSettings(BaseSettings): model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", envprefix="NEMLI")

  • discord_max_messages: int = 100

O mesmo ponto q levantei no primeiro comment aqui ...

— Reply to this email directly, view it on GitHub https://github.com/milharal-dev/nemli-nemlerei-bot/pull/21#pullrequestreview-2196466642, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2J57VH6WBY2CA4HALBG3TZN6HTDAVCNFSM6AAAAABLLRYMMOVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCOJWGQ3DMNRUGI . You are receiving this because you were mentioned.Message ID: @.***>