I have some Scala code. I want you to use it to create a gpt app in Scala 3, using AkkaHTTP and OpenAI key (use a marker until I get the key).   
// build.sbt
libraryDependencies ++= Seq(
  // Other dependencies…
  “com.typesafe.akka” %% “akka-http” % “10.2.3”,
  “com.typesafe.akka” %% “akka-stream” % “2.6.13”
)



lazy val root = (project in file(“.”))
  .settings(
    name := “GPTApp”,
    scalaVersion := “3.0.1”,
    libraryDependencies += “com.typesafe.akka” %% “akka-http” % “10.2.6”,
    libraryDependencies += “com.typesafe.akka” %% “akka-stream” % “2.6.16”,
    libraryDependencies += “com.google.cloud” % “google-cloud-translate” % “1.109.0”
  )


import scala.concurrent.ExecutionContext

object Main extends App {
  implicit val system: ActorSystem = ActorSystem(“GPTApp”)
  implicit val materializer: ActorMaterializer = ActorMaterializer()
  implicit val executionContext: ExecutionContext = system.dispatcher

  val translate: Translate = TranslateOptions.getDefaultInstance.getService

  val routes =
    path(“translate”) {
      post {
        entity(as[String]) { textToTranslate =>
          complete {
            val translation = translate.translate(textToTranslate, Translate.TranslateOption.targetLanguage(“en”)).getTranslatedText
            s"The translation is: $translation"
          }
        }
      }
    } ~ path(“gpt”) {
      post {
        entity(as[String]) { prompt =>
          complete {
            // Replace YOUR_OPENAI_API_KEY with your actual OpenAI API key
            val apiKey = “YOUR_OPENAI_API_KEY”
            // Implement your GPT functionality here using the OpenAI API key and prompt
            // Example: send a request to OpenAI endpoint and get the GPT response
            s"Generated response for prompt:



import com.google.cloud.translate.Translate
import com.google.cloud.translate.TranslateOptions
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.
import akka.http.scaladsl.server.Directives.
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.stream.ActorMaterializer
import scala.concurrent.ExecutionContextExecutor
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}


class Translator {
  private val translate: Translate = TranslateOptions.getDefaultInstance().getService()

  def translateText(text: String, sourceLang: String, targetLang: String): String = {
    // TODO: Implement translation logic using the Google Translate API
    // For now, you can leave a placeholder or a marker until you obtain an OpenAI key
    “Placeholder translation”
  }
}


object ConversationServer {
  def main(args: Array[String]): Unit = {
    implicit val system: ActorSystem = ActorSystem(“conversation-server”)
    implicit val materializer: ActorMaterializer = ActorMaterializer()
    implicit val executionContext: ExecutionContextExecutor = system.dispatcher

    // Instantiate the Translator object here
    val translator = new Translator()

    val route =
      path(“translate”) {
        post {
          entity(as[String]) { input =>
            // Extract the necessary information from the request, such as sourceLang and targetLang

            // TODO: Implement language detection logic if needed
            val sourceLang = “source language” // Placeholder
            val targetLang = “target language” // Placeholder

            val translatedText = translator.translateText(input, sourceLang, targetLang)

            complete(HttpEntity(ContentTypes.text/plain(UTF-8), translatedText))
          }
        }
      }

    val bindingFuture = Http().bindAndHandle(route, “localhost”, 8080)

    println(s"Server online at http://localhost:8080/")
  }
}


object ConversationLoopApp {
  def main(args: Array[String]): Unit = {
    implicit val system: ActorSystem = ActorSystem(“conversation-loop”)
    implicit val executionContext: ExecutionContext = system.dispatcher

    val route = path(“conversation”) {
      post {
        entity(as[String]) { message =>
          val translatedMessage = translateMessage(message) // Translate message if required
          val response = sendMessageToGpt(translatedMessage) // Send message to OpenAI GPT

          onComplete(response) {
            case Success(gptResponse) =>
              val translatedResponse = translateMessageBack(gptResponse) // Translate response back if needed
              complete(translatedResponse)
            case Failure(ex) =>
              complete(StatusCodes.InternalServerError, s"Failed to communicate with GPT: ${ex.getMessage}“)
          }
        }
      }
    }


    val bindingFuture = Http().newServerAt(“localhost”, 8080).bind(route)
    println(s"Server online at http://localhost:8080/”)

    scala.sys.addShutdownHook {
      bindingFuture
        .flatMap(.unbind()) // Unbind the HTTP server
        .onComplete( => system.terminate()) // Terminate the actor system
    }
  }

  def translateMessage(message: String): String = {
    // Implement your translation logic using the GoogleTranslate API here
    // Return the translated message
    message
  }

  def translateMessageBack(response: String): String = {
    // Implement your translation logic to translate the response back to the user’s language
    // Return the translated response
    response
  }

  def sendMessageToGpt(message: String): Future[String] = {
    val openAiApiKey = “YOUR_OPENAI_API_KEY”
    val gptEndpointUrl = “https://api.openai.com/v1/engines/davinci-codex/completions”

    val request = HttpRequest(
      method = HttpMethods.POST,
      uri = gptEndpointUrl,
      headers = List(
        headers.Authorization(OAuth2BearerToken(openAiApiKey)),
        headers.Accept(MediaTypes.application/json)
      ),
      entity = HttpEntity(ContentTypes.application/json, s"“”{“prompt”: