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 an experimental gemini call to the backend #2974

Merged
merged 6 commits into from
Jun 4, 2024
Merged

Conversation

devoncarew
Copy link
Member

Add an experimental gemini call to the backend:

  • add an experimental gemini call to the backend
  • a GOOGLE_API_KEY will need to be configured in the cloud serving infra
  • the api call uses the gemini-1.5-flash-latest model
  • calls are currently restricted to firebase hosted apps (and local development)
  • no UI is hooked up as yet

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@devoncarew devoncarew requested a review from johnpryan June 3, 2024 17:51
@devoncarew
Copy link
Member Author

Looks like we need to fiddle with the package versions on main: https://github.com/dart-lang/dart-pad/actions/runs/9354896383/job/25748806872?pr=2974

Copy link
Member

@parlough parlough left a comment

Choose a reason for hiding this comment

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

As long as any client calling the API as many times as they'd like is not a concern, looks good to me.

Do wait for John to take a look too :D

pkgs/dartpad_shared/lib/services.dart Outdated Show resolved Hide resolved
pkgs/dart_services/lib/src/common_server.dart Outdated Show resolved Hide resolved
}

// Only allow the call from known clients / endpoints.
const firebaseHostAddress = '199.36.158.100';
Copy link
Member

Choose a reason for hiding this comment

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

Would this be the address used if calling from a Firebase-hosted cloud function or similar?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I don't know.

This IP is often (always?) the address for firebase hosted web apps (though, this may or may not always be true with custom domains).

Fair to say that this check has some room for improvement.

Copy link
Member Author

Choose a reason for hiding this comment

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

An update here - after an in-person discussion w/ @johnpryan, I switched to checking that the request origin is https://dartpad.dev.

pkgs/dart_services/lib/src/common_server.dart Outdated Show resolved Hide resolved
devoncarew and others added 2 commits June 3, 2024 17:31
Co-authored-by: Parker Lougheed <parlough@gmail.com>
Copy link
Member Author

@devoncarew devoncarew left a comment

Choose a reason for hiding this comment

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

As long as any client calling the API as many times as they'd like is not a concern, looks good to me.

We could put some call throttling in perhaps. I'm not committed to this particular impl., but do like the idea of experimenting against a live backend. If we see usage issues (way too much, ...) we can always remove the API / otherwise pivot.

}

// Only allow the call from known clients / endpoints.
const firebaseHostAddress = '199.36.158.100';
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I don't know.

This IP is often (always?) the address for firebase hosted web apps (though, this may or may not always be true with custom domains).

Fair to say that this check has some room for improvement.

pkgs/dartpad_shared/lib/services.dart Outdated Show resolved Hide resolved
pkgs/dart_services/lib/src/common_server.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@johnpryan johnpryan left a comment

Choose a reason for hiding this comment

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

LGTM

@devoncarew devoncarew merged commit b3926a5 into main Jun 4, 2024
8 checks passed
@devoncarew devoncarew deleted the experimental_gemini branch June 4, 2024 18:04
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.

None yet

3 participants