Skip to content

dspy.Image allows gs://image_urls from Google Cloud Platform (GCP) #8267

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

Merged

Conversation

dimroc
Copy link
Contributor

@dimroc dimroc commented May 23, 2025

Allows dspy.Image to have a gs url that gets passed through and correctly ingested by LiteLLM.

Code Pointer to LiteLLM usage: https://github.com/BerriAI/litellm/blob/e9b7059af4d0aa0ad3da418628f34c1bd02251fa/litellm/llms/vertex_ai/gemini/transformation.py#L72

Example usage:

class GsImageUrl(dspy.Signature):
    """Extract the leadership principles."""

    image: dspy.Image = dspy.InputField(desc="image of page")
    leadership_principles: list[str] = dspy.OutputField(desc="list of leadership principles")

module = dspy.Predict(GsImageUrl)
image_url = "gs://some_bucket/AmazonLeadershipPrinciplesPage1.png"
image = dspy.Image.from_url(image_url, False)
response = module(image=image)

print(response.leadership_principles)

Output:

['Customer Obsession', 'Ownership', 'Invent and Simplify', 'Are Right, A Lot', 'Learn and Be Curious', 'Hire and Develop the Best', 'Insist on the Highest Standards']

MLFlow input/output:

image

Copy link
Collaborator

@chenmoneygithub chenmoneygithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! LGTM

@chenmoneygithub chenmoneygithub merged commit 7c68c08 into stanfordnlp:main May 23, 2025
3 checks passed
@dimroc dimroc changed the title dspy.Image allows gs://image_urls dspy.Image allows gs://image_urls from Google Cloud Platform (GCP) May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants