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

AI DSL From Scala examples #107

Merged
merged 1 commit into from
May 26, 2023
Merged

AI DSL From Scala examples #107

merged 1 commit into from
May 26, 2023

Conversation

Yawolf
Copy link
Contributor

@Yawolf Yawolf commented May 25, 2023

Adding some basic examples that don't require nested case classes for proving AI functionality in Scala.

2023-05-26 update:

  • Animal working without issues
  • Book working without issues
  • ChessAI showing HttpRequestTimeoutException on the 3rd/4th play
  • ASCIIArt removing it for now, will come in a new PR

Ready for review.

@nomisRev
Copy link
Contributor

@Yawolf is this ready for final review?

@Yawolf
Copy link
Contributor Author

Yawolf commented May 25, 2023

@Yawolf is this ready for final review?

The code is done, but the LLM is returning a wrong value in the move field, in ChessMove case class. It always returns <insert move here>, so the chess match never advances. I think there's something wrong with the core prompt? 🤔

@necosta
Copy link
Contributor

necosta commented May 26, 2023

Rebased on top on latest main. Will have a look at open comments, so we can get it ready for review.

@necosta
Copy link
Contributor

necosta commented May 26, 2023

With this latest change 767ef8b , I unblock the game start and get it going.

I start seeing:

Retrying chat completion due to io.ktor.client.plugins.HttpRequestTimeoutException: Request timeout has expired [url=https://api.openai.com/v1/chat/completions, request_timeout=30000 ms] after 0 attempts
Retrying chat completion due to io.ktor.client.plugins.HttpRequestTimeoutException: Request timeout has expired [url=https://api.openai.com/v1/chat/completions, request_timeout=30000 ms] after 1 attempts
Retrying chat completion due to io.ktor.client.plugins.HttpRequestTimeoutException: Request timeout has expired [url=https://api.openai.com/v1/chat/completions, request_timeout=30000 ms] after 2 attempts

Is this a known issue?

Also, does this example work in Kotlin?

@raulraja
Copy link
Contributor

@necosta The Chess example never worked reliably in kotlin. Some of the other simpler examples should be fine for now. In the last 4 days, even simple examples have failed for me due to Open AI server errors like 502 and others—also many timeouts like that.

@necosta necosta changed the title WIP: AI DSL From Scala examples AI DSL From Scala examples May 26, 2023
@necosta necosta requested review from raulraja and nomisRev May 26, 2023 08:26
@necosta
Copy link
Contributor

necosta commented May 26, 2023

How to run (IntelliJ IDEA):

  • Set Java version 19
  • Set VM options: "--enable-preview"
  • Set Env variable: "OPENAI_TOKEN=xxx"

@nomisRev
Copy link
Contributor

@necosta should we put the run instructions somewhere in a README?

@necosta
Copy link
Contributor

necosta commented May 26, 2023

@necosta should we put the run instructions somewhere in a README?

Yes, I'll add them in this new PR I'm creating.

private final case class Story(animal: Animal, invention: Invention, story: String) derives ScalaSerialDescriptor, Decoder

@main def runAnimal: Unit =
AI {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the Kotlin DSL, unless we think this is more idiomatic in Scala, we should have AI be ai and ensure all other functions are named the same in Scala.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Let's tackle this in a separate PR

@@ -1,6 +1,6 @@
package com.xebia.functional.xef.scala.auto

import com.xebia.functional.auto.*
import com.xebia.functional.scala.auto.*
import com.xebia.functional.scala.auto.ScalaSerialDescriptor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are missing xef in the package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fixing this in a separate PR

CC @necosta

@juanpedromoreno juanpedromoreno merged commit c43b396 into main May 26, 2023
@juanpedromoreno juanpedromoreno deleted the scala-ai-test branch May 26, 2023 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants