-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add field to indicate whether an image is AI generated #940
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Part of NDLA common | ||
| * Copyright (C) 2026 NDLA | ||
| * | ||
| * See LICENSE | ||
| * | ||
| */ | ||
|
|
||
| package no.ndla.common.model.domain | ||
|
|
||
| import enumeratum.* | ||
| import no.ndla.common.errors.ValidationException | ||
| import sttp.tapir.Codec.PlainCodec | ||
| import sttp.tapir.Schema | ||
| import sttp.tapir.codec.enumeratum.* | ||
|
|
||
| import scala.util.{Failure, Success, Try} | ||
|
|
||
| sealed abstract class AiGenerated(override val entryName: String) extends EnumEntry | ||
|
|
||
| object AiGenerated extends Enum[AiGenerated] with CirceEnum[AiGenerated] { | ||
| case object Partial extends AiGenerated("partial") | ||
| case object Yes extends AiGenerated("yes") | ||
| case object No extends AiGenerated("no") | ||
|
|
||
| val values: IndexedSeq[AiGenerated] = findValues | ||
|
|
||
| def all: Seq[String] = AiGenerated.values.map(_.entryName) | ||
| def valueOf(s: String): Option[AiGenerated] = AiGenerated.withNameOption(s) | ||
|
|
||
| def valueOfOrError(s: String): Try[AiGenerated] = valueOf(s) match { | ||
| case Some(p) => Success(p) | ||
| case None => | ||
| val validGeneratedValues = values.map(_.toString).mkString(", ") | ||
| Failure(ValidationException("aiGenerated", s"'$s' is not a valid priority. Must be one of $validGeneratedValues")) | ||
| } | ||
|
|
||
| implicit def schema: Schema[AiGenerated] = schemaForEnumEntry[AiGenerated] | ||
| implicit def codec: PlainCodec[AiGenerated] = plainCodecEnumEntry[AiGenerated] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| update imagemetadata | ||
| set metadata = jsonb_set(metadata, '{aiGenerated}', '"no"'::jsonb) | ||
| where metadata->>'aiGenerated' is null | ||
| and metadata is not null; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ package no.ndla.imageapi.model.api | |
| import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder} | ||
| import io.circe.{Decoder, Encoder} | ||
| import no.ndla.common.model.api.CopyrightDTO | ||
| import no.ndla.common.model.domain.AiGenerated | ||
| import sttp.tapir.Schema.annotations.description | ||
|
|
||
| // format: off | ||
|
|
@@ -22,7 +23,8 @@ case class NewImageMetaInformationV2DTO( | |
| @description("Searchable tags for the image") tags: Seq[String], | ||
| @description("Caption for the image") caption: String, | ||
| @description("ISO 639-1 code that represents the language used in the caption") language: String, | ||
| @description("Describes if the model has released use of the image, allowed values are 'not-set', 'yes', 'no', and 'not-applicable', defaults to 'no'") modelReleased: Option[String] | ||
| @description("Describes if the model has released use of the image, allowed values are 'not-set', 'yes', 'no', and 'not-applicable', defaults to 'no'") modelReleased: Option[String], | ||
| @description("Describes whether the image is AI generated") aiGenerated: AiGenerated, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Her må vi ha ed klar med denne funksjonaliteten ellers vil det ikkje funere å opprette nye bilder siden denne ikkje er optional. Men ser jo at dei ber om det.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tipper dette krever fem minutter med arbeid i ED, så tror ikke det har allverdens å si. |
||
| ) | ||
|
|
||
| object NewImageMetaInformationV2DTO{ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Denne må bytte navn til V27