Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restructure repository and add integrations #126

Merged
merged 9 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
12 changes: 8 additions & 4 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: CI

on:
push:
branches:
- main

jrriehl marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches:
- main
paths:
- "python/**"
- ".github/**"

jobs:
tests:
name: Tests
defaults:
jrriehl marked this conversation as resolved.
Show resolved Hide resolved
run:
shell: bash
working-directory: ./python
strategy:
matrix:
os: [ubuntu-latest]
Expand Down Expand Up @@ -57,6 +57,10 @@ jobs:

linting:
name: Lint & Formatting
defaults:
run:
shell: bash
working-directory: ./python
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*.py[cgo]
__pycache__
*.json

dist/
*.sqlite3
24 changes: 2 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
The **μAgents** (micro-Agents) project is a fast and lightweight framework that makes it easy to build agents for all kinds of decentralised use cases.

## Installation
## Python Library

Install μAgents for Python 3.8, 3.9, or 3.10:

```bash
poetry install
poetry shell
```

## Documentation

Build and run the docs locally with:

```bash
mkdocs serve
```

Or go to the official docs site: https://docs.fetch.ai/uAgents.

## Examples

The [`examples`](https://github.com/fetchai/uAgents/tree/main/examples) folder contains several examples of how to create and run various types of agents.
Go to the [`python`](https://github.com/fetchai/uAgents/tree/main/python) folder for details on the Python uAgents library.

## Contributing

Expand All @@ -38,4 +19,3 @@ We use [GitHub Issues](https://github.com/fetchai/uAgents/issues) for tracking r
## License

The μAgents project is licensed under [Apache License 2.0](https://github.com/fetchai/uAgents/blob/main/LICENSE).

94 changes: 94 additions & 0 deletions integrations/fetch-holiday/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# uAgent Holiday integrations Examples
### Step 1: Prerequisites
Before starting, you'll need the following:
* Python (3.8+ is recommended)
* Poetry (a packaging and dependency management tool for Python)

### Step 2: Set up .env file
To run the demo, you need API keys from:
* RapidAPI
* OpenAI
* SerpAPI

##### RapidAPI Key
* Visit RapidAPI.
* Sign up or log in.
* Search for the Skyscanner API and subscribe.
* Once subscribed, copy your X-RapidAPI-Key

##### OpenAI API Key
* Visit OpenAI.
* Sign up or log in.
* Navigate to the API section to obtain your API key.

Note that if you’ve run out of OpenAI credits, you will not be able to get results for this example.

##### SerpAPI Key

* Visit SerpAPI.
* Sign up or log in.
* Your API key will be available on the dashboard.

Once you have all three keys, create a .env file in the holiday-integrations/src directory.
```bash
export RAPIDAPI_API_KEY="{GET THE API KEY}"
export OPENAI_API_KEY="{GET THE API KEY}"
export SERPAPI_API_KEY="{GET THE API KEY}"
```
To use the environment variables from .env and install the project:
```bash
cd src
source .env
poetry intall
```
### Step 3: Run the main script
To run the project and its agents:
```bash
poetry run python main.py
```
You need to look for the following output in the logs:
```
Adding top destinations agent to Bureau: {top_dest_address}
```
Copy the {top_dest_address} value and paste it somewhere safe. You will need it in the next step.
### Step 4: Set up the client script
Now that we have set up the integrations, let’s run a client script that will showcase the ‘top destinations’. To do this, create a new Python file in the src folder called top_dest_client.py, and paste the following:
```python
from messages import TopDestinations, UAgentResponse
from uagents import Agent, Context
from uagents.setup import fund_agent_if_low
import os
TOP_DESTINATIONS_CLIENT_SEED = os.getenv("TOP_DESTINATIONS_CLIENT_SEED", "top_destinations_client really secret phrase :)")
top_dest_client = Agent(
name="top_destinations_client",
port=8008,
seed=TOP_DESTINATIONS_CLIENT_SEED,
endpoint=["http://127.0.0.1:8008/submit"],
)
fund_agent_if_low(top_dest_client.wallet.address())
top_dest_request = TopDestinations(preferences="new york")
@top_dest_client.on_interval(period=10.0)
async def send_message(ctx: Context):
await ctx.send("{top_dest_address}", top_dest_request)
@top_dest_client.on_message(model=UAgentResponse)
async def message_handler(ctx: Context, _: str, msg: UAgentResponse):
ctx.logger.info(f"Received top destination options from: {msg.options}")
if __name__ == "__main__":
top_dest_client.run()
```
Remember to replace the address in ctx.send with the value you received in the previous step.

This code sends a request to get the top destinations (in this example, from New York). To do this, it sends a request to the ‘top destinations agent’ every 10 seconds and displays the options in the console.
### Step 5: Run the client script
Open a new terminal (let the previous one be as is), and navigate to the src folder to run the client.
```bash
cd src
poetry run python top_dest_client.py
```
Once you hit enter, a request will be sent to the top destinations agent every 10 seconds, and you will be able to see your results in the console!
Loading
Loading