-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding
pdf
function as part of Scala DSL (#130)
* Adding function as part of Scala DSL * Deleted unneeded import * Update examples/scala/src/main/scala/com/xebia/functional/xef/scala/auto/PDFDocument.scala Co-authored-by: Juan Pedro Moreno <4879373+juanpedromoreno@users.noreply.github.com> --------- Co-authored-by: yago <Yawolf@users.noreply.github.com> Co-authored-by: Juan Pedro Moreno <4879373+juanpedromoreno@users.noreply.github.com>
- Loading branch information
1 parent
84e33b6
commit 51b1d65
Showing
6 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
16 changes: 11 additions & 5 deletions
16
examples/scala/src/main/scala/com/xebia/functional/xef/scala/auto/PDFDocument.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
package com.xebia.functional.xef.scala.auto | ||
|
||
import com.xebia.functional.xef.scala.auto.* | ||
import com.xebia.functional.xef.scala.auto.ScalaSerialDescriptorContext.given | ||
import io.circe.Decoder | ||
import io.circe.parser.decode | ||
|
||
import scala.io.StdIn.readLine | ||
|
||
private final case class AIResponse(answer: String) derives ScalaSerialDescriptor, Decoder | ||
|
||
val pdfUrl = "https://people.cs.ksu.edu/~schmidt/705a/Scala/Programming-in-Scala.pdf" | ||
|
||
@main def runPDFDocument: Unit = | ||
ai { | ||
while (true) { | ||
println("Enter your question: ") | ||
val line = scala.io.StdIn.readLine() | ||
val response = prompt[AIResponse](line) | ||
println(s"${response.answer}\n---\n") | ||
contextScope(pdf(resource = pdfUrl)) { | ||
while (true) { | ||
println("Enter your question: ") | ||
val line = scala.io.StdIn.readLine() | ||
val response = prompt[AIResponse](line) | ||
println(s"${response.answer}\n---\n") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters