Skip to content

Commit

Permalink
Merge pull request #31 from nevermined-io/fix/jwt-access
Browse files Browse the repository at this point in the history
fix: jwt for subscriber
  • Loading branch information
eruizgar91 authored Oct 21, 2024
2 parents 8140c39 + c780bad commit e054709
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 148 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pip install nevermined/payments-py

```
Payments(nvm_api_key=nvm_api_key, environment=Environment.appStaging, app_id="your_app_id", version="1.0.0")
Payments(nvm_api_key=nvm_api_key, environment=Environment.staging, app_id="your_app_id", version="1.0.0")
```

44 changes: 18 additions & 26 deletions docs/ai_query_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ Methods:
- <b>`get_steps`</b>: Gets the steps
- <b>`get_tasks_from_agents`</b>: Gets the tasks from the agents
- <b>`search_step`</b>: Searches for steps
- <b>`get_step`</b>: Gets the details of a step

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L36"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L37"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -61,7 +62,7 @@ __init__(opts: BackendApiOptions)

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L94"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L89"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `create_steps`

Expand All @@ -83,12 +84,12 @@ It creates the step/s required to complete an AI Task. This method is used by th

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L63"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L64"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `create_task`

```python
create_task(did: str, task: Any, jwt: Optional[str] = None)
create_task(did: str, task: Any)
```

Subscribers can create an AI Task for an Agent. The task must contain the input query that will be used by the AI Agent. This method is used by subscribers of a Payment Plan required to access a specific AI Agent or Service. Users who are not subscribers won't be able to create AI Tasks for that Agent. Because only subscribers can create AI Tasks, the method requires the access token to interact with the AI Agent/Service. This is given using the `queryOpts` object (accessToken attribute).
Expand All @@ -99,7 +100,6 @@ Subscribers can create an AI Task for an Agent. The task must contain the input

- <b>`did`</b> (str): The DID of the service.
- <b>`task`</b> (Any): The task to create.
- <b>`jwt`</b> (Optional[str]): The JWT token.



Expand All @@ -108,15 +108,15 @@ Subscribers can create an AI Task for an Agent. The task must contain the input

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L180"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L171"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_step`

```python
get_step(step_id: str)
```

It retrieves all the steps that the agent needs to execute to complete the different tasks assigned. This method is used by the AI Agent to retrieve information about the steps part of tasks created by users to the agents owned by the user.
Get the details of a step.



Expand All @@ -128,7 +128,7 @@ It retrieves all the steps that the agent needs to execute to complete the diffe

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L193"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L183"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_steps`

Expand All @@ -139,7 +139,7 @@ get_steps(
)
```

Gets the steps.
It retrieves all the steps that the agent needs to execute to complete the different tasks assigned. This method is used by the AI Agent to retrieve information about the steps part of tasks created by users to the agents owned by the user.



Expand All @@ -150,7 +150,7 @@ Gets the steps.

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L155"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L146"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_steps_from_task`

Expand All @@ -170,12 +170,12 @@ It retrieves all the steps that the agent needs to execute to complete a specifi

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L140"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L130"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_task_with_steps`

```python
get_task_with_steps(did: str, task_id: str, jwt: Optional[str] = None)
get_task_with_steps(did: str, task_id: str)
```

It returns the full task and the steps resulted of the execution of the task.
Expand All @@ -190,11 +190,10 @@ This method is used by subscribers of a Payment Plan required to access a specif

- <b>`did`</b> (str): The DID of the service.
- <b>`task_id`</b> (str): The task ID.
- <b>`jwt`</b> (Optional[str]): The JWT token.

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L210"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L201"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_tasks_from_agents`

Expand All @@ -206,7 +205,7 @@ It retrieves all the tasks that the agent needs to execute to complete the diffe

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L170"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L161"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `search_step`

Expand All @@ -224,7 +223,7 @@ It search steps based on the search parameters. The steps belongs to the tasks p

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L131"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L121"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `search_tasks`

Expand All @@ -242,7 +241,7 @@ It searches tasks based on the search parameters associated to the user.

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L40"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L41"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `subscribe`

Expand Down Expand Up @@ -270,18 +269,12 @@ It subscribes to the Nevermined network to retrieve new AI Tasks requested by ot

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L108"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L103"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `update_step`

```python
update_step(
did: str,
task_id: str,
step_id: str,
step: Any,
jwt: Optional[str] = None
)
update_step(did: str, task_id: str, step_id: str, step: Any)
```

It updates the step with the new information. This method is used by the AI Agent to update the status and output of an step. This method can not be called by a subscriber.
Expand All @@ -294,7 +287,6 @@ It updates the step with the new information. This method is used by the AI Agen
- <b>`task_id`</b> (str): The task ID.
- <b>`step_id`</b> (str): The step ID.
- <b>`step`</b> (Any): The step object to update. https://docs.nevermined.io/docs/protocol/query-protocol#steps-attributes
- <b>`jwt`</b> (Optional[str]): The JWT token.



Expand Down
6 changes: 3 additions & 3 deletions docs/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Enum class to define the different environments
**Attributes:**

- <b>`local`</b>: Local environment
- <b>`appStaging`</b>: Staging environment
- <b>`appTesting`</b>: Testing environment
- <b>`appArbitrum`</b>: Arbitrum environment
- <b>`staging`</b>: Staging environment
- <b>`testing`</b>: Testing environment
- <b>`arbitrum`</b>: Arbitrum environment
- <b>`appPeaq`</b>: Peaq network


Expand Down
40 changes: 20 additions & 20 deletions docs/nvm_backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ connect_socket()

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L175"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L182"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `delete`

```python
delete(url: str, data: Any)
delete(url: str, data: Any, headers: Optional[Dict[str, str]] = None)
```


Expand Down Expand Up @@ -128,12 +128,12 @@ disconnect_socket()

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L155"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L156"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get`

```python
get(url: str)
get(url: str, headers: Optional[Dict[str, str]] = None)
```


Expand All @@ -142,7 +142,7 @@ get(url: str)

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L181"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L190"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_service_token`

Expand Down Expand Up @@ -191,12 +191,12 @@ join_room(join_account_room: bool, room_ids: Optional[str, List[str]] = None)

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L148"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L150"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `parse_url_to_backend`
### <kbd>method</kbd> `parse_headers`

```python
parse_url_to_backend(uri: str) → str
parse_headers(additional_headers: dict[str, str]) → dict[str, str]
```


Expand All @@ -205,12 +205,12 @@ parse_url_to_backend(uri: str) → str

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L144"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L147"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `parse_url_to_proxy`
### <kbd>method</kbd> `parse_url_to_backend`

```python
parse_url_to_proxy(uri: str) → str
parse_url_to_backend(uri: str) → str
```


Expand All @@ -219,12 +219,12 @@ parse_url_to_proxy(uri: str) → str

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L162"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L144"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `post`
### <kbd>method</kbd> `parse_url_to_proxy`

```python
post(url: str, data: Any)
parse_url_to_proxy(uri: str) → str
```


Expand All @@ -233,12 +233,12 @@ post(url: str, data: Any)

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L169"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L165"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `put`
### <kbd>method</kbd> `post`

```python
put(url: str, data: Any)
post(url: str, data: Any, headers: Optional[Dict[str, str]] = None)
```


Expand All @@ -247,12 +247,12 @@ put(url: str, data: Any)

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L152"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/nvm_backend.py#L174"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `set_bearer_token`
### <kbd>method</kbd> `put`

```python
set_bearer_token(token: str)
put(url: str, data: Any, headers: Optional[Dict[str, str]] = None)
```


Expand Down
Loading

0 comments on commit e054709

Please sign in to comment.