litellm icon indicating copy to clipboard operation
litellm copied to clipboard

Add txt file type in GCS URIs as accepted file type for gemini 1.5

Open jamesev15 opened this issue 1 year ago • 1 comments

Title

Add txt file type to GCS URIs for Gemini 1.5 models

Relevant issues

Since the version of google-cloud-aiplatform is 1.47.0, the txt file is supported in GCS URIs, this code works with txt Uris.

import vertexai
from vertexai.generative_models import GenerativeModel, Part, SafetySetting

print(vertexai.__version__) # 1.47.0
def generate():
    vertexai.init(project="project-id", location="us-central1")
    model = GenerativeModel(
        "gemini-1.5-pro-002",
    )
    responses = model.generate_content(
        ["""Do a summary of the document""", document1],
        generation_config=generation_config,
        safety_settings=safety_settings,
        stream=True,
    )

    for response in responses:
        print(response.text, end="")

document1 = Part.from_uri(
    mime_type="text/plain",
    uri="gs:.....txt",
)

generation_config = {
    "max_output_tokens": 8192,
    "temperature": 1,
    "top_p": 0.95,
}

safety_settings = [
    SafetySetting(
        category=SafetySetting.HarmCategory.HARM_CATEGORY_HATE_SPEECH,
        threshold=SafetySetting.HarmBlockThreshold.BLOCK_NONE
    ),
    SafetySetting(
        category=SafetySetting.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
        threshold=SafetySetting.HarmBlockThreshold.BLOCK_NONE
    ),
    SafetySetting(
        category=SafetySetting.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
        threshold=SafetySetting.HarmBlockThreshold.BLOCK_NONE
    ),
    SafetySetting(
        category=SafetySetting.HarmCategory.HARM_CATEGORY_HARASSMENT,
        threshold=SafetySetting.HarmBlockThreshold.BLOCK_NONE
    ),
]

generate()

For that reason, I propose to allow process txt for Gemini 1.5 models

Type

🆕 New Feature

Changes

  • The txt file type is added to the set GEMINI_1_5_ACCEPTED_FILE_TYPES

Screenshot 2024-10-26 at 14 09 58

jamesev15 avatar Oct 26 '24 19:10 jamesev15

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 26, 2024 7:17pm

vercel[bot] avatar Oct 26 '24 19:10 vercel[bot]

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Apr 22 '25 22:04 CLAassistant

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar Jul 22 '25 00:07 github-actions[bot]