Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"protocol/zarathustra/llm_chat_completion/1.0.0": "bafybeifdp2rwfar5vbs33p56dlin76v62p5fdvspwnpasraunp2wa7gxo4",
"connection/eightballer/telegram_wrapper/0.1.0": "bafybeib2sm5p4wtnerutf3y4wzzkk2hhzbl5tf3z5crk3xxyangxngsqjm",
"connection/zarathustra/openai_api/0.1.0": "bafybeihfzkq5mxzf54kgtbrlgrbwd5l2osixnur7e6iszumla3vbgoucue",
"skill/zarathustra/asylum_abci_app/0.1.0": "bafybeibrxsojugb57vcgxqcdnl6h56tl5c5mwfsk42tsyupcfzpz2xne2i",
"skill/zarathustra/asylum_abci_app/0.1.0": "bafybeie44mlapcbl766xd6fc26qgrsemxbhzdy4hs3ric5p5w2dcf75wku",
"agent/eightballer/telegram_bot/0.1.0": "bafybeifwijoua3m4zgd7beyexpzcvq5opyzb5bbnb6e2uhi5rpnugmq2e4",
"agent/zarathustra/asylum_abci_app/0.1.0": "bafybeiefn5zeahzvwg2bv4tafbburpofs4smddu5ihryk2h3ecab6cswci",
"service/zarathustra/asylum_abci_app/0.1.0": "bafybeihot3aklfwflzvsme7g4lhip3d6z3hfhkkehiy4cumy5b2ui54ooa"
"agent/zarathustra/asylum_abci_app/0.1.0": "bafybeiaf7ef624jm5cxhr5vzxh6v7o66zlo7hpaclls7nstq3lappid6wu",
"service/zarathustra/asylum_abci_app/0.1.0": "bafybeidgvm25zbqbbynzcg64dpnmjxxjqca4deofatdgl5f6tifrwezdny"
},
"third_party": {
"protocol/eightballer/default/0.1.0": "bafybeicsdb3bue2xoopc6lue7njtyt22nehrnkevmkuk2i6ac65w722vwy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protocols:
- open_aea/signing:1.0.0:bafybeig2d36zxy65vd7fwhs7scotuktydcarm74aprmrb5nioiymr3yixm
skills:
- eightballer/prometheus:0.1.0:bafybeicl5i7e467aowfarke4bbyixo2dggar276njmvyuwbsby5pxshhtu
- zarathustra/asylum_abci_app:0.1.0:bafybeibrxsojugb57vcgxqcdnl6h56tl5c5mwfsk42tsyupcfzpz2xne2i
- zarathustra/asylum_abci_app:0.1.0:bafybeie44mlapcbl766xd6fc26qgrsemxbhzdy4hs3ric5p5w2dcf75wku
customs: []
default_ledger: ethereum
required_ledgers:
Expand Down
2 changes: 1 addition & 1 deletion packages/zarathustra/services/asylum_abci_app/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fingerprint:
tests/__init__.py: bafybeibkiew5ph62jf7mvavzjtwqozwivuniwpov6oi2hne4xvwa23pmau
tests/test_service.py: bafybeicslmnjnf43pbzmwlqr7p7xw2iktcrnuq6l7klkrc5r4yberg66u4
fingerprint_ignore_patterns: []
agent: zarathustra/asylum_abci_app:0.1.0:bafybeiefn5zeahzvwg2bv4tafbburpofs4smddu5ihryk2h3ecab6cswci
agent: zarathustra/asylum_abci_app:0.1.0:bafybeiaf7ef624jm5cxhr5vzxh6v7o66zlo7hpaclls7nstq3lappid6wu
number_of_agents: 4
deployment:
agent:
Expand Down
24 changes: 23 additions & 1 deletion packages/zarathustra/skills/asylum_abci_app/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""This package contains the behaviours for the AsylumAbciApp."""

import os
import re
import json
import functools
from abc import ABC
Expand Down Expand Up @@ -53,6 +54,7 @@
TELEGRAM_MSG_CHAR_LIMIT = 4_000
MERMAID_DIAGRAMS = Path("specs") / "fsms" / "mermaid"
SPONSOR_BOUNTY_DATA = Path("bounties") / "sponsor_bounties.json"
BOT_PATTERN = re.compile(r"(🤖.*?🤖)")


@functools.lru_cache
Expand Down Expand Up @@ -95,6 +97,21 @@ def clean_str(s: str) -> str:
return f"Sponsor: {target_sponsor}\nBounty: {bounty_key}\nDescription:{description}\n"


def get_chat_history(context) -> tuple[str, set[str]]:
"""Get most recent telegram chat history."""
authors = set()
messages = []
for text in reversed(context.asylum_strategy.chat_history):
if bot_match := BOT_PATTERN.search(text):
authors.add(bot_match.group(1))
messages.append(text)
else:
authors.add("Human")
messages.append(f"Human agent says:\n{text}")
agent_conversation = "\n\n".join(f"{i}. {msg}" for i, msg in enumerate(messages))
return agent_conversation, authors
Comment on lines +100 to +112

@Karrenbelt Karrenbelt Mar 18, 2025 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved this out, as we can use it for both the system prompt (adding most recent telegram history) as well as README.md generation. Tho I have reversed the iteration of the queue, so now most recent is on top instead of bottom.



USER_PERSONA_PROMPT = dedent("""
I have a dataset of GitHub issues and discussions related to {github_repositories}. I want you to analyze and summarize the contributions of the main participants to infer their technical personas.

Expand Down Expand Up @@ -176,6 +193,9 @@ def clean_str(s: str) -> str:
- **Never break character.**
- **All responses must reflect the perspective of your real-world counterpart.**
- Ensure the FSM diagram is under {telegram_msg_char_limit} characters so it fits within Telegram's message limit. If needed, simplify state names or remove unnecessary transitions while keeping the happy path intact.

### Most recent message exchange leading up to this point (latest messages appear at the top):
{chat_history}
""") # noqa: E501


Expand Down Expand Up @@ -307,7 +327,7 @@ def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)
self._state = AsylumAbciAppStates.REQUEST_LLM_RESPONSE_ROUND

def act(self) -> None:
def act(self) -> None: # noqa: PLR0914
"""Act."""
self.sponsor_bounty_info = get_bounty_info(self.context)
self.context.logger.info(f"In state: {self._state}")
Expand Down Expand Up @@ -357,6 +377,7 @@ def act(self) -> None:
model = LLMModel.META_LLAMA_3_3_70B_INSTRUCT
github_username = self.agent_persona.github_username
user_persona = self.context.asylum_strategy.user_persona
chat_history, _ = get_chat_history(self.context)
self.context.logger.info(f"I AM: {user_persona}")
content = [
Message(
Expand All @@ -368,6 +389,7 @@ def act(self) -> None:
telegram_msg_char_limit=TELEGRAM_MSG_CHAR_LIMIT,
sponsor_bounty_info=self.sponsor_bounty_info,
mermaid_diagram_examples=mermaid_diagram_examples,
chat_history=chat_history,
),
),
Message(role=Role.USER, content=text_data, name=username),
Expand Down
18 changes: 6 additions & 12 deletions packages/zarathustra/skills/asylum_abci_app/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@
DefaultDialogues,
)
from packages.zarathustra.connections.openai_api.connection import reconstitute
from packages.zarathustra.skills.asylum_abci_app.behaviours import TELEGRAM_MSG_CHAR_LIMIT, get_bounty_info
from packages.zarathustra.skills.asylum_abci_app.behaviours import (
TELEGRAM_MSG_CHAR_LIMIT,
get_bounty_info,
get_chat_history,
)
from packages.zarathustra.protocols.llm_chat_completion.message import LlmChatCompletionMessage
from packages.zarathustra.protocols.llm_chat_completion.dialogues import (
LlmChatCompletionDialogue,
LlmChatCompletionDialogues,
)


BOT_PATTERN = re.compile(r"(🤖.*?🤖)")
MERMAID_PATTERN = re.compile(r"```mermaid\s*([\s\S]+?)\s*```")


Expand All @@ -66,16 +69,7 @@ def create_readme(context, mermaid: str, fsm_spec, out_path: Path):
content = template_file.read_text()
bounty_info: str = get_bounty_info(context)
sponsor_bounty = bounty_info.split("\nDescription:")[0]
authors = set()
messages = []
for text in context.asylum_strategy.chat_history:
if bot_match := BOT_PATTERN.search(text):
authors.add(bot_match.group(1))
messages.append(text)
else:
authors.add("Human")
messages.append(f"Human agent says:\n{text}")
agent_conversation = "\n\n".join(f"{i}. {msg}" for i, msg in enumerate(messages))
agent_conversation, authors = get_chat_history(context)
formatted_readme = content.format(
project_name=fsm_spec.label,
authors=", ".join(authors),
Expand Down
4 changes: 2 additions & 2 deletions packages/zarathustra/skills/asylum_abci_app/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ aea_version: '>=1.0.0, <2.0.0'
fingerprint:
README.md: bafybeiesl5jlvvu4enydib32bpyfqphlkdulxy3oqid3t32cjxya5qykci
__init__.py: bafybeiarezohbq3skvjb6k5djqpyr2cssmconp3jbhsoisrnmw2pqly47q
behaviours.py: bafybeid4w76zrq5xw4gukyflesg3uknduwht4nzot4vlwag3q635xaelee
behaviours.py: bafybeihclqw6na7trx7t6em2lp56665tnw3tktjmurp56sokssbyakxnzq
dialogues.py: bafybeihumikopwajayxsmbyz4dqhzzchief6qkgcjfjtdtni62wazii6ea
fsm_specification.yaml: bafybeigzazuujebi3vxw4lxghqgss6fsmetm5iixjxkpqafs3ztfc3rxcy
handlers.py: bafybeigrdnhgizxb3uxbmnwyr2o56makdfeaosjxzpund3xiuhc5e33bti
handlers.py: bafybeib5fzcoxjs6pp5hrc4oaa64jpnkt6qnwbddkq4bsa7vpogt5l5zle
mermaid_diagrams/asylum_abci_app.mmd: bafybeigyh7kf7gjnmsyfnpmf4pc5bq4zvzgzi5ehws3y3abbbxikzg55fm
scraper.py: bafybeia7m3ilj5puq7iycx4x62vndee72qakxsa5zv34rq2v5jscniz4nu
strategy.py: bafybeickw6x3vydvdbmtuy2c5ynfgq5c4ezfvu42keaoyie4w4kht2m4h4
Expand Down