Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
"license": "MIT",
"keywords": [
"wetrocloud",
"RAG",
"Data Extraction",
"php",
"sdk",
"wetrocloud sdk",
"wetrocloud api"

],
"autoload": {
"psr-4": {
Expand Down
29 changes: 26 additions & 3 deletions src/Wetrocloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ public function textGeneration(array $messages, string $model): array
* @throws \RuntimeException
* **/

public function imageToText(string $imageUrl, string $requestQuery): array
{
public function imageToText(string $imageUrl, string $requestQuery): array
{
try {
$payload = [
'image_url' => $imageUrl,
Expand All @@ -370,13 +370,36 @@ public function imageToText(string $imageUrl, string $requestQuery): array
]);

return $this->decodeResponse($response);

} catch (\JsonException $e) {
throw new \RuntimeException("Failed to encode messages: " . $e->getMessage());
} catch (GuzzleException $e) {
throw new \RuntimeException("Failed to extract text: " . $e->getMessage());
}
}

/**
* Convert a resource (file, web, image) to Markdown
*
* @param string $resource The resource URL (file, web page, or image)
* @param string $resourceType The type of resource: "file", "web", or "image"
* @return array<string, mixed> Response from the API containing response, tokens, and success status
* @throws \RuntimeException
*/
public function markdownConverter(string $resource, string $resourceType): array
{
try {
$payload = [
'link' => $resource,
'resource_type' => $resourceType,
];

$response = $this->client->post('/v2/markdown-converter/', [
'json' => $payload,
]);

return $this->decodeResponse($response);
} catch (GuzzleException $e) {
throw new \RuntimeException("Failed to convert resource to Markdown: " . $e->getMessage());
}
}
}
Loading