Skip to content

Update anomaly_detection to sync with genai generate_embedding method #468

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

Closed
wants to merge 1 commit into from

Conversation

BichengWang
Copy link

Description of the change

Update anomaly_detection to sync genai generate_embedding method:

  • update method
  • update embedding model

Motivation

The original method deprecated by genai and less runnable

Type of change

Choose one: (Bug fix)

Checklist

  • [x ] I have performed a self-review of my code.
  • [x ] I have added detailed comments to my code where applicable.
  • [x ] I have verified that my change does not break existing code.
  • [x ] My PR is based on the latest changes of the main branch (if unsure, please run git pull --rebase upstream main).
  • [x ] I am familiar with the Google Style Guide for the language I have coded in.
  • [x ] I have read through the Contributing Guide and signed the Contributor License Agreement.

Update anomaly_detection to sync genai generate_embedding method:
- update method
- update embedding model
@BichengWang BichengWang requested a review from a team as a code owner June 22, 2024 08:29
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added status:awaiting review PR awaiting review from a maintainer component:documentation Update docs labels Jun 22, 2024
@markmcd
Copy link
Member

markmcd commented Aug 8, 2024

This change looks like it reverts the Gemini API to use the (deprecated) PaLM API. Is that intentional? Can you provide any more context?

@markmcd markmcd added status:awaiting user response Awaiting a response from the author and removed status:awaiting review PR awaiting review from a maintainer labels Aug 8, 2024
@BichengWang
Copy link
Author

This change looks like it reverts the Gemini API to use the (deprecated) PaLM API. Is that intentional? Can you provide any more context?

Error:
AttributeError: module 'google.generativeai' has no attribute 'embed_content'
Env:
google-generativeai==.07.2, python=3.9.19
Alternative replacement plan as above.

@markmcd

@markmcd
Copy link
Member

markmcd commented Aug 12, 2024

The code in the notebook works as expected. If you can provide a repro case showing how it fails then please do so (in a bug would be appropriate). Any fix should use the Gemini API, not the deprecated PaLM API.

>>> import google.generativeai as genai
>>> genai.__version__
'0.7.2'
>>> r = genai.embed_content(model='models/embedding-001', content='the quick brown fox', task_type='clustering')
>>> len(r['embedding'])
768
>>> r['embedding'][:10]
[0.037379164, -0.042748366, -0.029110689, -0.042224124, 0.037183076, -0.0256457, -0.01939054, 0.015298519, 0.048082795, -0.019906988]

@markmcd markmcd closed this Aug 12, 2024
@github-actions github-actions bot removed the status:awaiting user response Awaiting a response from the author label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants