Skip to content

Commit

Permalink
fix #7, fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Jul 26, 2024
1 parent 74abd46 commit 0c73fb0
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ case class AtomicAverage(count: AtomicLong, sum: AtomicLong) {

object BestResponseTime extends LoadBalancing {

private[models] val random = new scala.util.Random
private[models] val responseTimes = new UnboundedTrieMap[String, AtomicAverage]()
private val random = new scala.util.Random
private val responseTimes = new UnboundedTrieMap[String, AtomicAverage]()

def incrementAverage(desc: AiProvider, responseTime: Long): Unit = {
val key = desc.id
Expand Down Expand Up @@ -93,9 +93,10 @@ class LoadBalancerChatClient(provider: AiProvider) extends ChatClient {
provider.getChatClient() match {
case None => Json.obj("error" -> "no client found").leftf
case Some(client) => {
val start = System.console()
val start = System.currentTimeMillis()
client.call(prompt, attrs).map { resp =>
BestResponseTime.incrementAverage(provider, System.currentTimeMillis() - start)
val duration: Long = System.currentTimeMillis() - start
BestResponseTime.incrementAverage(provider, duration)
resp
}
}
Expand Down

0 comments on commit 0c73fb0

Please sign in to comment.