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

Feature to support "system_instruction" #131

Closed
mobilinked opened this issue Apr 11, 2024 · 3 comments
Closed

Feature to support "system_instruction" #131

mobilinked opened this issue Apr 11, 2024 · 3 comments
Assignees
Labels
component:swift sdk Issue/PR related to Swift SDK status:awaiting user response Awaiting a response from the author type:feature request New feature/request/enhancement

Comments

@mobilinked
Copy link

Description of the feature request:

I'm currently utilizing 'gemini-1.5-pro-latest', and I'm aiming to implement the system instructions as outlined on https://ai.google.dev/docs/system_instructions. However, I've encountered difficulties in locating the section where I can configure the parameters, and I've also been unable to find any corresponding code within the library.

What problem are you trying to solve with this feature?

"system_instruction" is useful for our logic

Any other information you'd like to share?

No response

@mobilinked mobilinked added component:swift sdk Issue/PR related to Swift SDK type:feature request New feature/request/enhancement labels Apr 11, 2024
@mobilinked
Copy link
Author

And:

I am employing the code below to achieve my objectives, assuming that system instruction support is available. It appears to be functioning as expected:

let systemInstruction = try Self.systemInstruction(from: file, for: language)
let history = [
     ModelContent(role: "model", parts: systemInstruction)
]

@andrewheard andrewheard self-assigned this Apr 11, 2024
@andrewheard
Copy link
Collaborator

Hi @mobilinked, support for system instructions just got added in the https://github.com/google/generative-ai-swift/releases/tag/0.4.11 yesterday. Please update to that version if you haven't.

The example in #129 might be helpful. Based on your snippet above, it should be something like:

let systemInstruction = try Self.systemInstruction(from: file, for: language)
let model = GenerativeModel(
  name: "gemini-1.5-pro-latest",
  apiKey: APIKey.default,
  systemInstruction: ModelContent(role: "system", parts: systemInstruction),
  requestOptions: RequestOptions(apiVersion: "v1beta")
)

@andrewheard andrewheard added the status:awaiting user response Awaiting a response from the author label Apr 11, 2024
@mobilinked
Copy link
Author

Thank you much. It works.

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 status:awaiting user response Awaiting a response from the author type:feature request New feature/request/enhancement
Projects
None yet
Development

No branches or pull requests

2 participants