Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixNicolaeBucsa committed Nov 26, 2024
1 parent 513d77e commit 043698f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/spelling/check_spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
path_pattern = re.compile(r'path:\s*"/[^"]*"')
guidebox_pattern = re.compile(r'<GuideBox[\s\S]*?/>', re.IGNORECASE)

# New patterns to remove content inside <GithubCodeSegment> and <CodeGroup> tags
github_code_segment_pattern = re.compile(r'<GithubCodeSegment[\s\S]*?</GithubCodeSegment>', re.IGNORECASE)
code_group_pattern = re.compile(r'<CodeGroup[\s\S]*?</CodeGroup>', re.IGNORECASE)

# Corrected word pattern to allow apostrophes in valid words
word_pattern = re.compile(r"\b\w+(?:'\w+)?\b")

Expand All @@ -31,6 +35,10 @@ def extract_text_from_mdx(file_path):
with open(file_path, 'r') as file:
content = file.read()

# Remove content inside <GithubCodeSegment> and <CodeGroup> tags
content = github_code_segment_pattern.sub('', content)
content = code_group_pattern.sub('', content)

# Remove import statements
content = import_pattern.sub('', content)

Expand Down
59 changes: 58 additions & 1 deletion pages/guides/agents/intermediate/test.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,60 @@
The overall script would be:

<GithubCodeSegment digest="9ed3a45551f019ad98402e56760de8d7">
<CodeSegment
path="https://github.com/fetchai/uAgent-Examples/blob/main/5-documentation/guides/agent-courses/introductory-course/agent_communication.py"
lineStart={1}
lineEnd={33}
hosted={true}
/>
</GithubCodeSegment>
<CodeGroup dynamic hasCopy isLocalHostedFile digest='9ed3a45551f019ad98402e56760de8d7'>

<DocsCode local={true}>
```py copy filename="agent_communication.py"

from uagents import Agent, Bureau, Context, Model


class Message(Model):
message: str


alice = Agent(name="alice", seed="alice recovery phrase")
bob = Agent(name="bob", seed="bob recovery phrase")


@alice.on_interval(period=3.0)
async def send_message(ctx: Context):
await ctx.send(bob.address, Message(message="hello there bob"))


@bob.on_message(model=Message)
async def bob_message_handler(ctx: Context, sender: str, msg: Message):
ctx.logger.info(f"Received message from {sender}: {msg.message}")
await ctx.send(alice.address, Message(message="hello there alice"))


@alice.on_message(model=Message)
async def alice_message_handler(ctx: Context, sender: str, msg: Message):
ctx.logger.info(f"Received message from {sender}: {msg.message}")

testin cpode snippetss

bureau = Bureau()
bureau.add(alice)
bureau.add(bob)

if __name__ == "__main__":
bureau.run()

```
</DocsCode>

</CodeGroup>



We can now run the script. Just run: `poetry run python agent_communication.py` in your terminal.
holidayyys

Expand All @@ -9,7 +66,7 @@ The output would look as follows:
[alice]: Received message from agent1q0mau8vkmg78xx0sh8cyl4tpl4ktx94pqp2e94cylu6haugt2hd7j9vequ7: hello there alice
[ bob]: Received message from agent1qww3ju3h6kfcuqf54gkghvt2pqe8qp97a7nzm2vp8plfxflc0epzcjsv79t: hello there bob
[alice]: Received message from agent1q0mau8vkmg78xx0sh8cyl4tpl4ktx94pqp2e94cylu6haugt2hd7j9vequ7: hello there alice
[ bob]: Received message from agent1qww3ju3h6kfcuqf54gkghvt2pqe8qp97a7nzm2vp8plfxflc0epzcjsv79t: hello thee bob
[ bob]: Received message from agent1qww3ju3h6kfcuqf54gkghvt2pqe8qp97a7nzm2vp8plfxflc0epzcjsv79t: hello there bob
```

Checkout the following documentation and resources for a better understanding of the above topics:
Expand Down

0 comments on commit 043698f

Please sign in to comment.