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

feat(vertexai/genai): add SystemInstruction #9736

Merged
merged 4 commits into from Apr 30, 2024
Merged

feat(vertexai/genai): add SystemInstruction #9736

merged 4 commits into from Apr 30, 2024

Conversation

jba
Copy link
Contributor

@jba jba commented Apr 9, 2024

Expose GenerateContentRequest.SystemInstruction.

As usual, put it on the Model, and use the Model field to construct
each request.

@jba jba requested a review from eliben April 9, 2024 21:14
@jba jba requested review from a team as code owners April 9, 2024 21:14
Copy link
Contributor

@eliben eliben left a comment

Choose a reason for hiding this comment

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

It'd be nice to have an example for this too.

Particularly because this is called "system prompt" everywhere else, and this may make it difficult for users to discover. For example, there's an issue on generative-ai-go asking for it: google/generative-ai-go#31

@jba
Copy link
Contributor Author

jba commented Apr 15, 2024

Example forthcoming.

@jba
Copy link
Contributor Author

jba commented Apr 15, 2024

I added a test and an example that shows various config options.
But I'm marking this a draft because the feature doesn't seem to be implemented.

@jba jba marked this pull request as draft April 15, 2024 12:06
@Deleplace
Copy link

Deleplace commented Apr 26, 2024

But I'm marking this a draft because the feature doesn't seem to be implemented.

The Python sample for system instructions with Gemini 1.5 Pro is working for me. I'll see if I can get similar results with the Go sdk.

@Deleplace
Copy link

I'm getting compile errors at example_test.go, @jba can you PTAL?

@eliben
Copy link
Contributor

eliben commented Apr 29, 2024

I'm getting compile errors at example_test.go, @jba can you PTAL?

Is it a vet error? What does it say?

@Deleplace
Copy link

I'm getting compile errors at example_test.go, @jba can you PTAL?

Is it a vet error? What does it say?

% go test     
# cloud.google.com/go/vertexai/genai_test [cloud.google.com/go/vertexai/genai.test]
./example_test.go:58:38: undefined: option
./example_test.go:58:38: not enough arguments in call to genai.NewClient
	have (context.Context, unknown type)
	want (context.Context, string, string, ...option.ClientOption)
./example_test.go:58:56: undefined: os
FAIL	cloud.google.com/go/vertexai/genai [build failed]

And after fixing the imports:

./example_test.go:60:38: not enough arguments in call to genai.NewClient

The errors are trivial but I suspect we don't have jba's latest code.

jba added 4 commits April 29, 2024 19:50
Expose GenerateContentRequest.SystemInstruction.

As usual, put it on the Model, and use the Model field to construct
each request.
@jba
Copy link
Contributor Author

jba commented Apr 29, 2024

Sorry for the wait. I fixed the compilation problem and the feature now works with gemini-1.0-pro. Removing draft status.

@jba jba requested a review from eliben April 29, 2024 23:59
@jba jba marked this pull request as ready for review April 30, 2024 00:00
@jba jba enabled auto-merge (squash) April 30, 2024 00:01
@jba jba merged commit 84e3236 into main Apr 30, 2024
11 checks passed
@jba jba deleted the jba-system-inst branch April 30, 2024 00:03
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