Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.72 KB

File metadata and controls

49 lines (34 loc) · 1.72 KB

Notes on the code merger - 2025-02-17

Arjun:

The two code bases principally touch in main.py. From there they go their separate ways.

The code for your summaries uses:

  • main.py -> bot.slash_command -> (summary.py) summary(), fromtosummary() or unreadsummary()

The code for webhook summaries uses:

  • main.py -> wires summary_for_webhook() into a Flask controlled by webhook.py -> (history.py) summarize_contents_of_channel_between_dates() uses get_channel_messages() followed by progressive calls to get_summary_from_ai(). To minimize costs, call return values are cached in the LRUCache. webhook.py webhook()receives the POST and will forward the response (and embedded request) usingsend_message_to_webhook()` according to the values in the incoming payload

Refactoring Your code could use summarize_contents_of_channel_between_dates in the sections for collection from history:

 async for message in channel.history(limit=None):
        if first:
            first = False
            continue

        history.append(message)

        if len(history) == messages:
            break

Line #88-96 (summary) Line #168-183 (fromtosummary) Line #205-222 (unreadsummary)

If so, the hardcoded html would need reworking (e.g. line #26 of history.py)

My code has global values for:

  • OPEN API KEY
  • Currently an environment varible
  • I'm thinking this could be passed in the incoming payload (and omitted outbound)
  • context_lookback_days
  • the context window provides background info to aid with interpretation in addition to the period being summarized
  • Set to 5, but already can be provided in the payload
  • Some HTML in response strings (for things like headers)