-
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.
Merge branch 'main' into wikipedia_search
- Loading branch information
Showing
8 changed files
with
381 additions
and
66 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
examples/kotlin/src/main/kotlin/com/xebia/functional/xef/auto/reasoning/ReActExample.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.xebia.functional.xef.auto.reasoning | ||
|
||
import com.xebia.functional.xef.auto.ai | ||
import com.xebia.functional.xef.auto.llm.openai.OpenAI | ||
import com.xebia.functional.xef.auto.llm.openai.getOrThrow | ||
import com.xebia.functional.xef.reasoning.search.Search | ||
import com.xebia.functional.xef.reasoning.tools.LLMTool | ||
import com.xebia.functional.xef.reasoning.tools.ReActAgent | ||
|
||
suspend fun main() { | ||
ai { | ||
val model = OpenAI.DEFAULT_CHAT | ||
val serialization = OpenAI.DEFAULT_SERIALIZATION | ||
val math = LLMTool.create( | ||
name = "Calculator", | ||
description = "Perform math operations and calculations processing them with an LLM model. The tool input is a simple string containing the operation to solve expressed in numbers and math symbols.", | ||
model = model, | ||
scope = this | ||
) | ||
val search = Search(model = model, scope = this) | ||
|
||
val reActAgent = ReActAgent( | ||
model = serialization, | ||
scope = this, | ||
tools = listOf( | ||
math, | ||
search, | ||
), | ||
) | ||
val result = | ||
reActAgent.run("Multiply the number of Leonardo di Caprio's girlfriends by the number of Metallica albums") | ||
println(result) | ||
}.getOrThrow() | ||
} |
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
11 changes: 11 additions & 0 deletions
11
reasoning/src/commonMain/kotlin/com/xebia/functional/xef/reasoning/serpapi/SearchResult.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.xebia.functional.xef.reasoning.serpapi | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SearchResult( | ||
val title: String, | ||
@SerialName("snippet") val document: String? = null, | ||
@SerialName("link") val source: String | ||
) |
7 changes: 7 additions & 0 deletions
7
reasoning/src/commonMain/kotlin/com/xebia/functional/xef/reasoning/serpapi/SearchResults.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.xebia.functional.xef.reasoning.serpapi | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SearchResults(@SerialName("organic_results") val searchResults: List<SearchResult>) |
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
Oops, something went wrong.