Skip to content

Commit

Permalink
Added OMNI model support for moderation endpoint.
Browse files Browse the repository at this point in the history
- Will update playground/tests later today
  • Loading branch information
PapaRascal2020 committed Sep 27, 2024
1 parent 8591298 commit 7ef38ba
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Features/Moderate.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,38 @@ public function text(
'input' => $content
])->json();
}

/**
* Text and Image Moderation
*
* This will accept the text as a string and
* images will accept an array like so:
*
* [
* 'url' => 'https://some.domain/image1.png',
* 'url' => 'https://some.domain/image2.png',
* 'url' => 'https://some.domain/image3.png',
* ]
*
* Accepted url values are either the URL or base64
*
* Base64 Example; "url": "data:image/jpeg;base64,abcdefg..."
*
*
* @param string $text
* @param array $images
* @return array|mixed
* @throws ConnectionException
*/
public function textAndImages (string $text, array $images )
{
return Http::withHeaders($this->headers)
->post($this->url, [
'model' => 'omni-moderation-latest',
'input' => [
['type' => 'text', 'text' => $text],
['image_url' => $images],
]
])->json();
}
}

0 comments on commit 7ef38ba

Please sign in to comment.