Skip to content

Commit

Permalink
Merge pull request #21 from nevermined-io/feat/prepare-ai-api-methods
Browse files Browse the repository at this point in the history
feat: prepare ai api methods for agents
  • Loading branch information
eruizgar91 authored Oct 10, 2024
2 parents 163dc0f + 71507d1 commit 37993cb
Show file tree
Hide file tree
Showing 27 changed files with 3,087 additions and 452 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.4.0-rc0](https://github.com/nevermined-io/payments-py/compare/v0.3.1...v0.4.0-rc0)

> 30 September 2024
- feat: refactor to use nvm backend common methods [`6d1ed7d`](https://github.com/nevermined-io/payments-py/commit/6d1ed7db7a9ff2443ef6903bc64cc743fec6a281)
- feat: start ai api methods implementation [`0b98fda`](https://github.com/nevermined-io/payments-py/commit/0b98fdaa6f6bfeafa3506f77c9e99fa1d2bd8e1e)
- feat: prepare ai api methods for agents [`84a4969`](https://github.com/nevermined-io/payments-py/commit/84a49690fa62d5ac08d71c694acffb658903c4d0)

#### [v0.3.1](https://github.com/nevermined-io/payments-py/compare/v0.3.0...v0.3.1)

> 9 August 2024
Expand Down
12 changes: 12 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,34 @@

## Modules

- [`ai_query_api`](./ai_query_api.md#module-ai_query_api)
- [`data_models`](./data_models.md#module-data_models)
- [`environments`](./environments.md#module-environments)
- [`nvm_backend`](./nvm_backend.md#module-nvm_backend)
- [`payments`](./payments.md#module-payments)
- [`utils`](./utils.md#module-utils)

## Classes

- [`ai_query_api.AIQueryApi`](./ai_query_api.md#class-aiqueryapi): Represents the AI Query API.
- [`data_models.AgentExecutionStatus`](./data_models.md#class-agentexecutionstatus): An enumeration.
- [`data_models.Artifact`](./data_models.md#class-artifact): Represents an artifact with a unique identifier and a URL reference.
- [`data_models.BalanceResultDto`](./data_models.md#class-balanceresultdto)
- [`data_models.BurnResultDto`](./data_models.md#class-burnresultdto)
- [`data_models.CreateAssetResultDto`](./data_models.md#class-createassetresultdto)
- [`data_models.DownloadFileResultDto`](./data_models.md#class-downloadfileresultdto)
- [`data_models.ExecutionInput`](./data_models.md#class-executioninput): Represents the input for a task, such as a query and additional parameters or artifacts.
- [`data_models.ExecutionOptions`](./data_models.md#class-executionoptions): Represents options for executing a task or step, such as input, status, and output.
- [`data_models.ExecutionOutput`](./data_models.md#class-executionoutput): Represents the output of a task or step execution.
- [`data_models.MintResultDto`](./data_models.md#class-mintresultdto)
- [`data_models.OrderSubscriptionResultDto`](./data_models.md#class-ordersubscriptionresultdto)
- [`data_models.ServiceTokenResultDto`](./data_models.md#class-servicetokenresultdto)
- [`data_models.Step`](./data_models.md#class-step): Represents a step in the execution of a task.
- [`data_models.SubscriptionType`](./data_models.md#class-subscriptiontype): An enumeration.
- [`data_models.Task`](./data_models.md#class-task): Represents a task that an agent should execute, composed of multiple steps.
- [`environments.Environment`](./environments.md#class-environment): Enum class to define the different environments
- [`nvm_backend.BackendApiOptions`](./nvm_backend.md#class-backendapioptions)
- [`nvm_backend.NVMBackendApi`](./nvm_backend.md#class-nvmbackendapi)
- [`payments.Payments`](./payments.md#class-payments): A class representing a payment system.

## Functions
Expand Down
277 changes: 277 additions & 0 deletions docs/ai_query_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
<!-- markdownlint-disable -->

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

# <kbd>module</kbd> `ai_query_api`




**Global Variables**
---------------
- **SEARCH_TASKS_ENDPOINT**
- **CREATE_STEPS_ENDPOINT**
- **UPDATE_STEP_ENDPOINT**
- **GET_AGENTS_ENDPOINT**
- **GET_BUILDER_STEPS_ENDPOINT**
- **GET_TASK_STEPS_ENDPOINT**
- **TASK_ENDPOINT**
- **GET_TASK_ENDPOINT**


---

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

## <kbd>class</kbd> `AIQueryApi`
Represents the AI Query API.



**Args:**

- <b>`opts`</b> (BackendApiOptions): The backend API options

Methods:
- <b>`create_task`</b>: Creates a task for an agent to execute
- <b>`create_steps`</b>: Creates steps for a task
- <b>`update_step`</b>: Updates a step
- <b>`search_tasks`</b>: Searches for tasks
- <b>`get_task_with_steps`</b>: Gets a task with its steps
- <b>`get_steps_from_task`</b>: Gets the steps from a task
- <b>`get_steps`</b>: Gets the steps
- <b>`get_tasks_from_agents`</b>: Gets the tasks from the agents
- <b>`get_service_token`</b>: Gets the service token

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

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

```python
__init__(opts: BackendApiOptions)
```








---

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

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

```python
create_steps(did: str, task_id: str, steps: Any)
```

Creates steps for a task.



**Args:**



- <b>`did`</b> (str): The DID of the service.
- <b>`task_id`</b> (str): The task ID.
- <b>`steps`</b> (Any): The steps to create.

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L53"><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)
```

Creates a task for an agent to execute.



**Args:**

- <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.

---

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

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

```python
get_service_token(service_did: str) → ServiceTokenResultDto
```

Gets the service token.



**Args:**

- <b>`service_did`</b> (str): The DID of the service.



**Returns:**

- <b>`ServiceTokenResultDto`</b>: The result of the creation operation.



**Raises:**

- <b>`HTTPError`</b>: If the API call fails.



**Example:**
response = your_instance.get_service_token(service_did="did:nv:xyz789") print(response)

---

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

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

```python
get_steps(
status: AgentExecutionStatus = <AgentExecutionStatus.Pending: 'Pending'>,
dids: List[str] = []
)
```

Gets the steps.



**Args:**

- <b>`status`</b> (AgentExecutionStatus): The status of the steps.
- <b>`dids`</b> (List[str]): The list of DIDs.

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L129"><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`

```python
get_steps_from_task(did: str, task_id: str, status: Optional[str] = None)
```

Gets the steps from a task.



**Args:**

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

---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L117"><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)
```

Gets a task with its steps.



**Args:**

- <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#L160"><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`

```python
get_tasks_from_agents()
```

Gets the tasks from the agents.

---

<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>

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

```python
search_tasks(search_params: Any)
```

Searches for tasks.



**Args:**

- <b>`search_params`</b> (Any): The search parameters.

---

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

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

```python
subscribe(callback: Any, events: Optional[str] = None)
```





---

<a href="https://github.com/nevermined-io/payments-py/blob/main/payments_py/ai_query_api.py#L84"><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
)
```

Updates a step.



**Args:**

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




---

_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._
Loading

0 comments on commit 37993cb

Please sign in to comment.