CYarros10 opened a new pull request, #40126:
URL: https://github.com/apache/airflow/pull/40126

   Gemini / Multimodal model Airflow Hooks/Operators should mimic typical usage 
as defined in the sample code block below. This provides fine-tuning model 
output via the additional configurations **GenerationConfig** and 
**SafetySettings**
   
   
   **Updated Operator Usage**
   ```
       prompt_multimodal_model_task = PromptMultimodalModelOperator(
           task_id="prompt_multimodal_model_task",
           project_id=PROJECT_ID,
           location=REGION,
           prompt=PROMPT,
           generation_config=GENERATION_CONFIG,
           safety_settings=SAFETY_SETTINGS,
           pretrained_model=MULTIMODAL_MODEL,
       )
   ```
   
   **Sample Code**
   ``` 
   vertexai.init(project=project_id, location="us-central1")
   
   model = 
generative_models.GenerativeModel(model_name="gemini-1.0-pro-vision-001")
   
   # Generation config
   generation_config = generative_models.GenerationConfig(
       max_output_tokens=2048, temperature=0.4, top_p=1, top_k=32
   )
   
   # Safety config
   safety_config = [
       generative_models.SafetySetting(
           
category=generative_models.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
           threshold=generative_models.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
       ),
       generative_models.SafetySetting(
           category=generative_models.HarmCategory.HARM_CATEGORY_HARASSMENT,
           threshold=generative_models.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
       ),
   ]
   
   image_file = Part.from_uri(
       "gs://cloud-samples-data/generative-ai/image/scones.jpg", "image/jpeg"
   )
   
   # Generate content
   responses = model.generate_content(
       [image_file, "What is in this image?"],
       generation_config=generation_config,
       safety_settings=safety_config,
       stream=True,
   )
   ```
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a 
newsfragment file, named `{pr_number}.significant.rst` or 
`{issue_number}.significant.rst`, in 
[newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to