Skip to content

Commit

Permalink
update php readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
GarfieldDai committed Nov 16, 2023
1 parent 446e49f commit 5d393de
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions sdks/php-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is the PHP SDK for the Dify API, which allows you to easily integrate Dify

After installing the SDK, you can use it in your project like this:

```
```php
<?php

require 'vendor/autoload.php';
Expand All @@ -26,17 +26,39 @@ $difyClient = new DifyClient($apiKey);

// Create a completion client
$completionClient = new CompletionClient($apiKey);
$response = $completionClient->create_completion_message($inputs, $response_mode, $user, $files);
$response = $completionClient->create_completion_message(array("query" => "Who are you?"), "blocking", "user_id");

// Create a chat client
$chatClient = new ChatClient($apiKey);
$response = $chatClient->create_chat_message($inputs, $query, $user, $response_mode, $conversation_id, $files);
$response = $chatClient->create_chat_message(array(), "Who are you?", "user_id", "blocking", $conversation_id);

$fileForVision = [
[
"type" => "image",
"transfer_method" => "remote_url",
"url" => "your_image_url"
]
];

// $fileForVision = [
// [
// "type" => "image",
// "transfer_method" => "local_file",
// "url" => "your_file_id"
// ]
// ];

// Create a completion client with vision model like gpt-4-vision
$response = $completionClient->create_completion_message(array("query" => "Describe this image."), "blocking", "user_id", $fileForVision);

// Create a chat client with vision model like gpt-4-vision
$response = $chatClient->create_chat_message(array(), "Describe this image.", "user_id", "blocking", $conversation_id, $fileForVision);

// Fetch application parameters
$response = $difyClient->get_application_parameters($user);
$response = $difyClient->get_application_parameters("user_id");

// Provide feedback for a message
$response = $difyClient->message_feedback($message_id, $rating, $user);
$response = $difyClient->message_feedback($message_id, $rating, "user_id");

// Other available methods:
// - get_conversation_messages()
Expand Down

0 comments on commit 5d393de

Please sign in to comment.