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 Google AI (Gemini API) Provider for the Title Generation, Excerpt Generation and Content resizing. #700

Merged
merged 10 commits into from
Feb 13, 2024

Conversation

iamdharmesh
Copy link
Member

@iamdharmesh iamdharmesh commented Feb 8, 2024

Description of the Change

PR adds Google AI (Gemini API) provider for the Title Generation, Excerpt Generation, and Content resizing features.

Google provides AI services in multiple ways. Some of those are:

  1. Gemini API (Google AI Studio)
  2. Palm API
  3. Google Cloud Vertex AI.

We are using the first option here(Gemini API). Gemini API (Google AI Studio) a tool to prototype and launch apps quickly with an API key. While Google Cloud Vertex AI is a fully-managed AI platform. Vertex AI allows customization of Gemini with full data control and benefits from additional Google Cloud features for enterprise security, safety, privacy, and data governance and compliance.

You can find more detailed information on difference between both here

We are using Gemini Pro (models/gemini-pro) model here.

Notes for reviewer:

  1. gemini-pro model does not provide a way to get multiple variations as of now (accepts only 1 for the candidateCount config param). Palm API provides multiple variations in response like ChatGPT do.

How to test the Change

Title Generation.

  1. Go to Tools > ClassifAI > Language Processing > Title Generation
  2. Select Google AI (Gemini API) in the provider field.
  3. Enter the API key in the "API Key" field. (You can Get an API key free of cost by login)
  4. Save settings.
  5. Create/Edit a post and click the "Generate Titles" button in the sidebar panel
  6. Verify that you will get the title suggestion in a popup as expected.

Excerpt Generation.

  1. Go to Tools > ClassifAI > Language Processing > Excerpt Generation
  2. Select Google AI (Gemini API) in the provider field.
  3. Enter the API key in the "API Key" field. (You can Get an API key free of cost by login)
  4. Save settings.
  5. Create/Edit a post and click the "Generate excerpt" button in the sidebar panel
  6. Verify that you will get the excerpt generated as expected.

Content Resizing.

  1. Go to Tools > ClassifAI > Language Processing > Content Resizing
  2. Select Google AI (Gemini API) in the provider field.
  3. Enter the API key in the "API Key" field. (You can Get an API key free of cost by login)
  4. Save settings.
  5. Create/Edit a post, add a content paragraph, and click the "Expand/Condense this text" button from the block toolbar
  6. Verify that content gets resized accordingly.

Changelog Entry

Added - Google AI (Gemini API) Provider for the Title Generation, Excerpt Generation, and Content resizing features.

Credits

Props @dkotter @iamdharmesh

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@github-actions github-actions bot added this to the 3.0.0 milestone Feb 8, 2024
@iamdharmesh iamdharmesh changed the title [WIP] Add Google AI (Gemini API) Provider for the Title Generation, Excerpt Generation and Content resizing. Add Google AI (Gemini API) Provider for the Title Generation, Excerpt Generation and Content resizing. Feb 9, 2024
@iamdharmesh iamdharmesh marked this pull request as ready for review February 9, 2024 10:45
@iamdharmesh iamdharmesh requested review from dkotter, jeffpaul and a team as code owners February 9, 2024 10:46
@github-actions github-actions bot added the needs:code-review This requires code review. label Feb 9, 2024
@dkotter dkotter removed request for a team and jeffpaul February 9, 2024 22:11
README.md Outdated Show resolved Hide resolved
includes/Classifai/Providers/OpenAI/ChatGPT.php Outdated Show resolved Hide resolved
includes/Classifai/Providers/OpenAI/ChatGPT.php Outdated Show resolved Hide resolved
includes/Classifai/Providers/OpenAI/ChatGPT.php Outdated Show resolved Hide resolved
@dkotter
Copy link
Collaborator

dkotter commented Feb 12, 2024

@iamdharmesh Left a few minor comments here but overall this looks really good.

That said, I've not been able to test this out fully as I can't figure out how to get an API key.

If I go to https://ai.google.dev/ and log in, I see a button that says Get API Key in Google AI Studio. If I click on that, it takes me to https://makersuite.google.com/ initially and then redirects to https://makersuite.google.com/app/. This then redirects me to https://ai.google.dev/tutorials/workspace_auth_quickstart, which seems to imply an error happened but doesn't really give me a good error message.

It seems that Gemini is only available in an Early Access app which has to be turned on at the account level (and I couldn't figure out how to do that). Are there steps I'm missing here and are there additional details we need in the README on how to get this set up (and maybe calling out it's early access)?

@dkotter dkotter linked an issue Feb 12, 2024 that may be closed by this pull request
1 task
@dkotter dkotter removed the needs:code-review This requires code review. label Feb 13, 2024
@dkotter dkotter merged commit 2a59e42 into develop Feb 13, 2024
13 checks passed
@dkotter dkotter deleted the enhacement/google-ai branch February 13, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add support for the PaLM API from Google
2 participants