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

System Instructions isn't triggering #143

Closed
MikesHorcrux opened this issue Apr 19, 2024 · 1 comment
Closed

System Instructions isn't triggering #143

MikesHorcrux opened this issue Apr 19, 2024 · 1 comment
Assignees
Labels
component:swift sdk Issue/PR related to Swift SDK type:bug Something isn't working

Comments

@MikesHorcrux
Copy link

Description of the bug:

I am initializing the Model to have system instructions, although when I send in the requests it's not regerstring the system instructions and the model is replying as if its not receiving them.

here is how I am initializing in the code

init() { model = GenerativeModel(name: "gemini-1.5-pro-latest", apiKey: APIKey.default, systemInstruction: .init(parts: [.text("Your name is steve a nome")])) chat = model.startChat() }

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

@MikesHorcrux MikesHorcrux added component:swift sdk Issue/PR related to Swift SDK type:bug Something isn't working labels Apr 19, 2024
@andrewheard andrewheard self-assigned this Apr 22, 2024
@andrewheard
Copy link
Collaborator

Hi @MikesHorcrux, system instructions require Gemini 1.5 which is only available v1beta version of the API. To simplify the developer experience we've updated the default from v1 to v1beta in the https://github.com/google-gemini/generative-ai-swift/releases/tag/0.5.0 (just launched this morning). I'd highly recommend upgrading to 0.5.0 (though there is a workaround in #128 (comment) to set v1beta on older versions of the SDK).

I was able to run your code snippet after updating to 0.5.0 and the system instruction altered the response:

let model = GenerativeModel(
  name: "gemini-1.5-pro-latest",
  apiKey: apiKey,
  systemInstruction: .init(parts: [.text("Your name is steve a nome")])
)
let chat = model.startChat()
let response = try await chat.sendMessage("Why is the sky blue?")
guard let text = response.text else { fatalError() }
print(text)

As a gnome named Steve, I can tell you that the sky is blue because of something called Rayleigh scattering. It's a fancy way of saying that sunlight gets bounced around by tiny things in the air, like air molecules and dust. Blue light gets scattered more than other colors, which is why the sky looks blue to our gnome eyes!

Hope this helps! Closing the issue now but feel free to re-open if you're still seeing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:swift sdk Issue/PR related to Swift SDK type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants