Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Streaming Response #21

Closed
ahmadnajmdev opened this issue Dec 30, 2023 · 2 comments · Fixed by #23
Closed

Add Streaming Response #21

ahmadnajmdev opened this issue Dec 30, 2023 · 2 comments · Fixed by #23
Assignees
Labels
enhancement New feature or request

Comments

@ahmadnajmdev
Copy link

Add Streaming Response
Here is Documentation:
https://ai.google.dev/tutorials/rest_quickstart#stream_generate_content

@erdemkose erdemkose added the enhancement New feature or request label Dec 30, 2023
@erdemkose erdemkose self-assigned this Dec 30, 2023
@erdemkose erdemkose changed the title Streaning Response Add Streaming Response Dec 31, 2023
@erdemkose erdemkose added this to the Feature complete milestone Dec 31, 2023
erdemkose added a commit that referenced this issue Jan 5, 2024
erdemkose added a commit that referenced this issue Jan 5, 2024
erdemkose added a commit that referenced this issue Jan 5, 2024
@erdemkose
Copy link
Collaborator

erdemkose commented Jan 5, 2024

@ahmadnajmdev How do you like the proposed streaming response change in #23? It requires curl extension to be enabled in PHP.

You can see the example in the README.md file.

$client = new GeminiAPI\Client('GEMINI_API_KEY');

$callback = function (GenerateContentResponse $response): void {
    static $count = 0;

    print "\nResponse #{$count}\n";
    print $response->text();
    $count++;
};

$client->geminiPro()->generateContentStream(
    $callback,
    new TextPart('PHP in less than 100 chars')
);
// Response #0
// PHP: a versatile, general-purpose scripting language for web development, popular for
// Response #1
//  its simple syntax and rich library of functions.

@ahmadnajmdev
Copy link
Author

ahmadnajmdev commented Jan 5, 2024 via email

erdemkose added a commit that referenced this issue Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants