maximerenou / php-hugging-chat

🚧 Deprecated 🚧 HuggingChat PHP client (OpenAssistant's LLaMA)
MIT License
18 stars 2 forks source link

Fail if you are not using a callback #2

Closed davidkonrad closed 1 year ago

davidkonrad commented 1 year ago

Conversation.php, on line 137 or something like that, should be:

if (isset($callback)) {
  $callback($this->current_text, $tokens);
}                   

You assume there is a callback. No insanity-test, I know it is a blunder, just informing.

davidkonrad commented 1 year ago

BTW, I reduced all your code and classes to about 10 lines. I really dont get your idea with the overkill. But thank you for the inspiration.

maximerenou commented 1 year ago

Hello David,

Thank you for pointing that out. I fixed it by checking that it's not null.

The code may appear overkill, indeed, as you could even reduce it to one class if that's what you seek. However, it was created based on this Bing AI client, which is meant to provide constant backward compatibility and flexibility when implementing new features - as everything tends to move fast and become multimodal.

README.md contains the bare minimum with main examples, which, in my opinion, are not overkill. In contrast, the example file is heavy and here to demonstrate a backward-compatible console implementation.

Feel free to open a PR if you find any bug fixes or improvements that doesn't break compatibility nor modularity!

Best regards

0x004a commented 1 year ago

BTW, I reduced all your code and classes to about 10 lines. I really dont get your idea with the overkill. But thank you for the inspiration.

Could you please gist a copy of your code? Would be nice to use, if it's still working.

Thanks.