Skip to content

Commit

Permalink
New readme!
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverearl committed Nov 27, 2024
1 parent 8043bb6 commit 5e32b1b
Showing 1 changed file with 86 additions and 7 deletions.
93 changes: 86 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
[![Tests](https://img.shields.io/github/actions/workflow/status/oliverearl/nomiai-php/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/oliverearl/nomiai-php/actions/workflows/run-tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/oliverearl/nomiai-php.svg?style=flat-square)](https://packagist.org/packages/oliverearl/nomiai-php)

This will be filled in shortly. The package is currently in early development.
This is a lightweight, PHP library for interacting with the Nomi.ai REST API. [Nomi AI](https://www.nomi.ai) is a
companionship application that uses artificial intelligence.

The only prerequisite is at least PHP 8.3 with the JSON extension. You'll need a HTTP client too, preferably Guzzle. If
you're using a popular framework, you should be good to go.

If you're using Laravel, install the [Laravel-specific library](https://github.com/oliverearl/nomiai-php-laravel)
instead.

## Installation

Expand All @@ -16,28 +23,100 @@ composer require oliverearl/nomiai-php

## Usage

### Quickstart

After installing the library, getting started is easy:

```php
$sdk = new \Nomiai\PhpSdk\NomiAI(
token: $yourNomiAiApiKey, // Find it in the Integrations tab of the Nomi.ai app!
// You can also provide a custom endpoint and HTTP Client as additional arguments.
);

$nomis = $sdk->getNomis();
$conversation = $sdk->sendMessageToNomi($nomis[0], 'Hello!');
```

### Retrieving Nomis

A numerically-indexed array of Nomis associated with an account can be returned using the library. If you know your
Nomi's UUID, you can also retrieve their data individually.

```php
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/

// Get all Nomis:
/** @var array<int, \Nomiai\PhpSdk\Resources\Nomi> $nomis **/
$nomis = $sdk->getNomis();

// Grab a specific Nomi:
/** @var \Nomiai\PhpSdk\Resources\Nomi $nomi **/
$nomi = $sdk->getNomi(id: 'Your Nomi UUID here');
```

### Chatting with Nomis

Once you have a Nomi you want to chat with, or if you know their UUID, sending a message is easy. If all goes well, you
will end up with a `MessageSet` object containing both your message and the corresponding reply.

```php
$skeleton = new Nomiai\Nomiai();
echo $skeleton->echoPhrase('Hello, Nomiai!');
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/
/** @var \Nomiai\PhpSdk\Resources\Nomi $nomi **/

// Send a message directly to a Nomi
$conversation = $sdk->sendMessageToNomi($nomi, 'Hello!');

// Or to their UUID!
$conversation = $sdk->sendMessage($nomi->uuid, 'World!');
```

## Functionality

The library is under active development. Complete feature availability is planned for the first major release.

| Nomi.ai API Functionality | Implemented | Release |
|------------------------------------|-------------|:-------------|
| Retrieve and view Nomis | Yes | v0.1.2-alpha |
| Send and receive messages to Nomis | Yes | v0.1.3-alpha |
| Retrieve Nomi avatars | No | |
| Retrieve group chats | No | |
| Create group chats | No | |
| Send messages into group chats | No | |
| Delete group chats | No | |


For more information regarding the Nomi.ai API, please check the documentation available
[here](https://api.nomi.ai/docs/reference).

## Testing

Tests are run using the [Pest](https://pestphp.com/) testing framework. You can run the suite like so:

```bash
composer test
```

## Code Style

Laravel Pint is used to maintain the PER coding style. The linter can be run using:

```bash
composer format
```

There are Pest architecture tests that also attempt to maintain certain conventions, including the use of strict
typing where possible.

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

## Security Vulnerabilities
Your contributions are warmly welcomed! Anything from documentation, to optimisations, and additional tests. Pull
requests must pass the existing test suite and conform to the required code style.

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
For new functionality, adequate tests must be included!

## Credits

Expand Down

0 comments on commit 5e32b1b

Please sign in to comment.