Skip to content

Commit 2e1c990

Browse files
Merge pull request #6 from devMuhammad05/dev
feat: Enhance WetrocloudSdkTest with new text generation, image-to-text, and markdown conversion tests
2 parents 83d28bf + 8f46a94 commit 2e1c990

File tree

3 files changed

+242
-72
lines changed

3 files changed

+242
-72
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
"license": "MIT",
66
"keywords": [
77
"wetrocloud",
8+
"RAG",
9+
"Data Extraction",
810
"php",
911
"sdk",
1012
"wetrocloud sdk",
1113
"wetrocloud api"
14+
1215
],
1316
"autoload": {
1417
"psr-4": {

src/Wetrocloud.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ public function textGeneration(array $messages, string $model): array
357357
* @throws \RuntimeException
358358
* **/
359359

360-
public function imageToText(string $imageUrl, string $requestQuery): array
361-
{
360+
public function imageToText(string $imageUrl, string $requestQuery): array
361+
{
362362
try {
363363
$payload = [
364364
'image_url' => $imageUrl,
@@ -370,13 +370,36 @@ public function imageToText(string $imageUrl, string $requestQuery): array
370370
]);
371371

372372
return $this->decodeResponse($response);
373-
374373
} catch (\JsonException $e) {
375374
throw new \RuntimeException("Failed to encode messages: " . $e->getMessage());
376375
} catch (GuzzleException $e) {
377376
throw new \RuntimeException("Failed to extract text: " . $e->getMessage());
378377
}
379378
}
380379

380+
/**
381+
* Convert a resource (file, web, image) to Markdown
382+
*
383+
* @param string $resource The resource URL (file, web page, or image)
384+
* @param string $resourceType The type of resource: "file", "web", or "image"
385+
* @return array<string, mixed> Response from the API containing response, tokens, and success status
386+
* @throws \RuntimeException
387+
*/
388+
public function markdownConverter(string $resource, string $resourceType): array
389+
{
390+
try {
391+
$payload = [
392+
'link' => $resource,
393+
'resource_type' => $resourceType,
394+
];
395+
396+
$response = $this->client->post('/v2/markdown-converter/', [
397+
'json' => $payload,
398+
]);
381399

400+
return $this->decodeResponse($response);
401+
} catch (GuzzleException $e) {
402+
throw new \RuntimeException("Failed to convert resource to Markdown: " . $e->getMessage());
403+
}
404+
}
382405
}

0 commit comments

Comments
 (0)