Skip to content

Commit

Permalink
fix(docs): updated code snippets in Guides and Examples (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixNicolaeBucsa authored Dec 13, 2024
1 parent cf13cb5 commit 959a78e
Show file tree
Hide file tree
Showing 47 changed files with 619 additions and 912 deletions.
18 changes: 1 addition & 17 deletions pages/examples/DeltaV/_meta.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
{
"dice-roll": {
"title": "Register a dice roll agent as a Function [intermediate]",
"tags": ["Intermediate", "Python", "Functions", "DeltaV"],
"timestamp": true
},
"coin-toss": {
"title": "Register a coin toss agent as a Function [intermediate]",
"title": "Register a coin toss Agent as a Function [Intermediate]",
"tags": ["Intermediate", "Python", "Functions", "DeltaV"],
"timestamp": true
},

"local-agent-registration": {
"title": "Register a local agent as a Function [intermediate]",
"tags": ["Intermediate", "Python", "Functions", "Agentverse"],
"timestamp": true
},
"local-agent-langchain": {
"title": "Locally Hosted Agent with LangChain Integration [intermediate]",
"tags": ["Intermediate", "Python", "Functions", "LangChain", "Agentverse"],
"timestamp": true
},
"news-reading-system": {
"title": "Using News API to build network of Primary and Secondary functions [Advanced]",
"tags": ["Intermediate", "Python", "Functions", "AI Engine"],
Expand Down
35 changes: 3 additions & 32 deletions pages/examples/DeltaV/coin-toss.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,7 @@ Please check out the example code in our [examples repo ↗️](https://github.c
```
</DocsCode>

<DocsCode local={false}>

```python copy filename="hosted-agent.py"
import random
# third party modules used in this example
from uagents import Field
from ai_engine import UAgentResponse, UAgentResponseType

class CoinToss(Model):
choice: str = Field(description="The choice. Must be heads or tails.")

coin_toss_protocol = Protocol("CoinToss")

@coin_toss_protocol.on_message(model=CoinToss, replies={UAgentResponse})
async def toss_coin(ctx: Context, sender: str, msg: CoinToss):
random_number = random.randint(0, 1)
if random_number == 0:
coin_tossed = "heads"
else:
coin_tossed = "tails"
if coin_tossed == msg.choice:
message = "You won!"
else:
message = "You lost!"
await ctx.send(
sender, UAgentResponse(message=message, type=UAgentResponseType.FINAL)
)

agent.include(coin_toss_protocol, publish_manifest=True)
```
</DocsCode>

</CodeGroup>



Empty file.
Empty file.
Empty file.
Loading

0 comments on commit 959a78e

Please sign in to comment.