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

Commit 908c17f

Browse files
committed
feat: disable caching
1 parent 300d663 commit 908c17f

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
> For now you need to have access to Bing Chat open beta. Or grab the cookie from someone who has access.
44
5-
This is Composer package for using Bing AI technology.
5+
This is an unofficial Composer package for using Bing AI technology.
66

7-
It comes with no warranty of continuous stability, and has been made using reverse engineering.
7+
It comes with no warranty of continuous stability.
88

99
## Install
1010

@@ -50,6 +50,22 @@ $identifiers = $conversation->getIdentifiers();
5050
$conversation = $ai->createChatConversation($cookie, $identifiers, 1);
5151
```
5252

53+
#### Text generation
54+
55+
Note: to prevent answers like "I have already written \[...]", you can disable cache for your prompt with `withoutCache()`.
56+
57+
```php
58+
$subject = "Internet memes";
59+
$tone = 'funny';
60+
$type = 'blog post';
61+
$length = 'short';
62+
63+
$prompt = new Prompt("Please write a *$length* *$type* in a *$tone* style about `$subject`. Please wrap the $type in a markdown codeblock.");
64+
65+
$conversation->ask($prompt->withoutCache(), ...)
66+
```
67+
5368
---------------------------------------
5469

55-
Bing is a trademark of Microsoft. This repository is not official.
70+
Using Bing AI API outside bing.com may violate Bing AI terms. Use it at your own risk.
71+
Bing is a trademark of Microsoft.

src/Chat/Conversation.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,24 @@ public function handlePacket($raw, $connection, $message, $callback)
176176
]*/
177177
];
178178

179+
$options = [
180+
'nlu_direct_response_filter',
181+
'deepleo',
182+
'enable_debug_commands',
183+
'disable_emoji_spoken_text',
184+
'responsible_ai_policy_235',
185+
'enablemm'
186+
];
187+
188+
if (! $message->cache) {
189+
$options[] = "nocache";
190+
}
191+
179192
$params = [
180193
'arguments' => [
181194
[
182195
'source' => 'cib',
183-
'optionsSets' => [
184-
'nlu_direct_response_filter',
185-
'deepleo',
186-
'enable_debug_commands',
187-
'disable_emoji_spoken_text',
188-
'responsible_ai_policy_235',
189-
'enablemm'
190-
],
196+
'optionsSets' => $options,
191197
'allowedMessageTypes' => [
192198
'Chat',
193199
'InternalSearchQuery',

src/Chat/Prompt.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
class Prompt
66
{
7+
public $cache = true;
8+
79
public $locale;
810

911
public $market;
@@ -21,4 +23,10 @@ public function withPreferences($locale = 'en-US', $market = 'en-US', $region =
2123
$this->region = $region;
2224
return $this;
2325
}
26+
27+
public function withoutCache()
28+
{
29+
$this->cache = false;
30+
return $this;
31+
}
2432
}

0 commit comments

Comments
 (0)