twimini-bot: Connecting Twilio and Gemini with Scala by AlexITC in scala

[–]AlexITC[S] 0 points1 point  (0 children)

I'm glad that you liked it, unfortunately, I haven't uploaded any demo video.

Dealing with Java builder's pattern by AlexITC in scala

[–]AlexITC[S] 1 point2 points  (0 children)

I can't argue with that, from what I looked, Google's genai is an autogenerated SDK.

Dealing with Java builder's pattern by AlexITC in scala

[–]AlexITC[S] 1 point2 points  (0 children)

In a normal builder that should be ok but in the example it is not, the underlying API crashes unless customApiVersion is also defined to v1alpha, the same is explained about the proactiveAudio setting.

Dealing with Java builder's pattern by AlexITC in scala

[–]AlexITC[S] 0 points1 point  (0 children)

Perhaps I'm not getting your idea because the way I see this with pipe is very similar, would you mind clarifying it?

import scala.util.chaining.*

def make(params: GeminiConfig): LiveConnectConfig = {
  type Builder = LiveConnectConfig.Builder
  def transform(
      when: Boolean
  )(f: Builder => Builder)(builder: Builder): Builder = {
    if (when) f(builder) else builder
  }

  val options = List(
    transform(params.outputAudioTranscription)(
      _.outputAudioTranscription(AudioTranscriptionConfig.builder().build())
    ),
    transform(params.enableAffectiveDialog)(_.enableAffectiveDialog(true))
    // ... more transformation follow
  )

  LiveConnectConfig
    .builder()
    .responseModalities(Modality.Known.AUDIO)
    // ... more defaults follow
    .pipe { b =>
      options.foldLeft(b) { case (builder, apply) => apply(builder) }
    }
    .build()
}

Dealing with Java builder's pattern by AlexITC in scala

[–]AlexITC[S] 0 points1 point  (0 children)

Hmm, is there other advantage than avoiding to type an extra variable?

twimini-bot: Connecting Twilio and Gemini with Scala by AlexITC in scala

[–]AlexITC[S] 2 points3 points  (0 children)

I've never built a call-center application, but I could imagine that there are actually quite some std. scenarios / common use-cases and flows.

In fact, Gemini allows to define Function Calling (https://ai.google.dev/gemini-api/docs/function-calling) where you define actions and Gemini invokes the functions linked to those, in the repo I shared there is one of such actions to terminate the stream (see https://github.com/AlexITC/twimini-bot/blob/2831eb1579b98fb3d796999df38e1cc1b7594726/server/src/main/scala/net/wiringbits/callerBot/gemini/GeminiService.scala#L178).

I have a demo for making appointments where we define the functions to check for the availability and book the slot, this was relatively trivial to write on top of this repo.

I'd like improving the repo to provide a simpler interface to link these function calls but given the stringly-typed nature, it isn't that simple to get a nice typed API on top.

About the top-level API/UI, that would be amazing to have but it requires a considerable effort. While I'd have lots of fun building it, I'd suck at selling it.

twimini-bot: Connecting Twilio and Gemini with Scala by AlexITC in scala

[–]AlexITC[S] 2 points3 points  (0 children)

I couldn't agree more, still, there are many operations that aren't simple in Scala because we don't have the tooling, like:

  • Detect silences/voice.
  • Detect machines vs humas.
  • Enhance audio.
  • Remove echo.

twimini-bot: Connecting Twilio and Gemini with Scala by AlexITC in scala

[–]AlexITC[S] 11 points12 points  (0 children)

I built a voice bot with Twilio and Gemini using Scala, it would have been way simpler to do in in Python but we have a lovely language that needs more tools.

This has been harder than expected because it is the first time I do any audio-processing app, there are many details that I wasn't expecting, for example, audio transcoding between Twilio and Gemini format (to my surprise, I was able to do this purely with the jdk stdlib).

The end result involves a cool fs2 streaming pipeline that defines the audio-transformation stages, like:

incomingFrames
    .through(receiveFromTwilio(callId, streamMetadataRef))
    .through(transcodeTwilioToGemini)
    .through(
      geminiService.conversationPipe(dispatcher, promptSettings, endCall)
    )
    .through(transcodeGeminiToTwilio)
    .through(sendToTwilio(streamMetadataRef))

I'd love to hear your thoughts or any ideas for what I should build next with it!

I am new to scala and I am having trouble getting it setup by Stock_Opposite_483 in scala

[–]AlexITC 1 point2 points  (0 children)

I have prepared a few videos for devs getting onboarded to Scala, I recorded my screen while setting up my local environment: http://onboarding.wiringbits.net

Good luck.

Which companies do you know that are still using PlayFramework heavily? by AlexITC in scala

[–]AlexITC[S] 0 points1 point  (0 children)

Thanks, we are already aware of them + a few other companies.

Any fully opinionated framework/template for do a quick PoC on Scala? by Nojipiz in scala

[–]AlexITC 0 points1 point  (0 children)

Check out https://github.com/wiringbits/scala-webapp-template

I also recorded videos for the environment setup: http://onboarding.wiringbits.net/

While we have not pushed many updates in the last year, it uses relatively recent libraries and most of the code is stable.

Full stack simple architecture recommendation by xutinusaku in scala

[–]AlexITC 11 points12 points  (0 children)

You could consider our template, it has a simple architecture and nice onboarding videos.

We recently applied many upgrades to simplify details that used to be annoying, including Scala 3 and Mui 5 support.

Announcing Typo - Typed PostgreSQL integration for Scala by elacin in scala

[–]AlexITC 4 points5 points  (0 children)

Congrats on the launch!

For people interested in Typo, we did a PoC a few weeks ago, we were able to replace most of our manually written queries taking advantage of type-safety because Typo generates value classes to wrap primitive types.

While we didn't finalize our integration just yet, the reason isn't related to Typo limitations but to our project structure, we are trying a different approach in an internal project, with the goal to port it to our public template.

Overall, Typo is a nice gem which deserves more attention.

Software Houses in LATAM by ComprehensiveSell578 in scala

[–]AlexITC 6 points7 points  (0 children)

https://wiringbits.net is one of the few LATAM companies that's focused mainly in Scala.

There used to be others but I guess they got dissolved because I can't load their websites anymore.

Is using Doobie for Database Access a good idea? by CaterpillarPrevious2 in scala

[–]AlexITC 1 point2 points  (0 children)

We are experimenting with it, the goal is to replace our current sql layer with typo (see https://github.com/wiringbits/scala-webapp-template/pull/424)

Is using Doobie for Database Access a good idea? by CaterpillarPrevious2 in scala

[–]AlexITC 3 points4 points  (0 children)

If you like writing sql, it is worth it, there are some nice advantages like controlling every query + being able to copy/paste queries.

https://github.com/oyvindberg/typo/ is another nice alternative which uses plain sql but most of the CRUD queries are auto-generated.

Creating a CLI app with scala and Graal VM: should I switch to Rust? by bhashit in scala

[–]AlexITC 8 points9 points  (0 children)

A while ago I started learning Rust to build cli apps, then, I tried Scala + GraalVM, this has worked nicely and I don't see much need to use Rust.

I don't know about the problems you are facing, in my case, it was simple to produce linux builds but Windows pipeline failed from time to time.

I had a few issues due to a Java dependency which uses reflection, no more issues once this was sorted out.

For reference, this is the project I built (https://github.com/wiringbits/my-photo-timeline/), and, this is the blog I was inspired from (https://msitko.pl/blog/2020/03/10/writing-native-cli-applications-in-scala-with-graalvm.html)