-
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.
Added embeddings endpoint to server (#374)
* added embeddings endpoint * added correct response to server endpoints * removed runBlocking * some refactor * Revert "some refactor" This reverts commit 1ffe687. * adding headers from llm response to ours * add unsafe check when copying headers * update sample * updated movie example * spotless * removed spacecraft local and added comments * configure request timeout for CIO engine of ktor client (#389) --------- Co-authored-by: ron <[email protected]> Co-authored-by: Ron S <[email protected]> Co-authored-by: Raúl Raja Martínez <[email protected]>
- Loading branch information
1 parent
ae7427a
commit 4a8d3d0
Showing
5 changed files
with
114 additions
and
101 deletions.
There are no files selected for viewing
29 changes: 23 additions & 6 deletions
29
examples/kotlin/src/main/kotlin/com/xebia/functional/xef/conversation/serialization/Movie.kt
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,15 +1,32 @@ | ||
package com.xebia.functional.xef.conversation.serialization | ||
|
||
import com.xebia.functional.xef.conversation.Conversation | ||
import com.xebia.functional.xef.conversation.llm.openai.OpenAI | ||
import com.xebia.functional.xef.conversation.llm.openai.prompt | ||
import com.xebia.functional.xef.prompt.Prompt | ||
import com.xebia.functional.xef.store.LocalVectorStore | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable data class Movie(val title: String, val genre: String, val director: String) | ||
|
||
suspend fun main() { | ||
OpenAI.conversation { | ||
val movie: Movie = | ||
prompt("Please provide a movie title, genre and director for the Inception movie") | ||
println("The movie ${movie.title} is a ${movie.genre} film directed by ${movie.director}.") | ||
} | ||
// This example contemplate the case of calling OpenAI directly or | ||
// calling through a local Xef Server instance. | ||
// To run the example with the Xef Server, you can execute the following commands: | ||
// - # docker compose-up server/docker/postgresql | ||
// - # ./gradlew server | ||
val openAI = OpenAI() | ||
// val openAI = OpenAI(host = "http://localhost:8081/") | ||
val model = openAI.DEFAULT_SERIALIZATION | ||
|
||
val scope = Conversation(LocalVectorStore(openAI.DEFAULT_EMBEDDING)) | ||
|
||
model | ||
.prompt( | ||
Prompt("Please provide a movie title, genre and director for the Inception movie"), | ||
scope, | ||
Movie.serializer() | ||
) | ||
.let { movie -> | ||
println("The movie ${movie.title} is a ${movie.genre} film directed by ${movie.director}.") | ||
} | ||
} |
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
37 changes: 0 additions & 37 deletions
37
...kotlin/src/main/kotlin/com/xebia/functional/xef/conversation/streaming/SpaceCraftLocal.kt
This file was deleted.
Oops, something went wrong.
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