Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 7df5930

Browse files
committed
feat: delete conversation
1 parent 1cb870d commit 7df5930

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ $conversation->disableSharing(); // off
9191

9292
</details>
9393

94+
<details>
95+
<summary>Delete a conversation</summary>
96+
97+
```php
98+
$conversation->delete();
99+
```
100+
101+
</details>
102+
94103
<details>
95104
<summary>Handle HuggingChat errors</summary>
96105

examples/chat.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@
3131
}
3232
}
3333

34+
$conversation->delete();
35+
3436
exit(0);

src/Conversation.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,17 @@ public function withSettings($settings)
216216

217217
return $this;
218218
}
219+
220+
public function delete()
221+
{
222+
$headers = [
223+
'method: DELETE',
224+
'accept: application/json',
225+
"referer: https://huggingface.co/chat",
226+
'content-type: application/json',
227+
"cookie: hf-chat={$this->cookie}"
228+
];
229+
230+
Tools::request("https://huggingface.co/chat/conversation/{$this->id}", $headers, '');
231+
}
219232
}

0 commit comments

Comments
 (0)