Skip to content

Commit

Permalink
Add PromptConfiguration ( temperature = 0.0 ) to ReActAgent (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zevleg authored Sep 19, 2023
1 parent e6d7d50 commit 3b0c91f
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.xebia.functional.xef.conversation.Description
import com.xebia.functional.xef.llm.ChatWithFunctions
import com.xebia.functional.xef.llm.models.chat.Message
import com.xebia.functional.xef.prompt.Prompt
import com.xebia.functional.xef.prompt.configuration.PromptConfiguration
import com.xebia.functional.xef.prompt.templates.assistant
import com.xebia.functional.xef.prompt.templates.system
import com.xebia.functional.xef.prompt.templates.user
Expand All @@ -16,6 +17,7 @@ class ReActAgent(
private val scope: Conversation,
private val tools: List<Tool>,
private val maxIterations: Int = 10,
private val configuration: PromptConfiguration = PromptConfiguration ( temperature = 0.0 )
) {

private val logger = KotlinLogging.logger {}
Expand Down Expand Up @@ -47,7 +49,7 @@ class ReActAgent(
+assistant(
"I should create a AgentFinish object with the final answer based on the thoughts and observations"
)
}
}.copy(configuration = configuration)
)

private suspend fun agentAction(input: Prompt, chain: List<ThoughtObservation>): AgentAction =
Expand All @@ -69,7 +71,7 @@ class ReActAgent(
"I will not repeat the `toolInput` if the same one produced no satisfactory results in the observations"
)
+user("Provide the next tool to use and the `toolInput` for the tool")
}
}.copy(configuration = configuration)
)

private fun List<Tool>.toolsToMessages(): List<Message> = flatMap {
Expand All @@ -95,7 +97,7 @@ class ReActAgent(
"`CONTINUE` if the `input` has not been answered by the observations in the `chain`"
)
+assistant("`FINISH` if the `input` has been answered by the observations in the `chain`")
},
}.copy(configuration = configuration),
scope = scope,
serializer = AgentChoice.serializer()
)
Expand All @@ -112,7 +114,7 @@ class ReActAgent(
+tools.toolsToMessages()
+assistant("I should create a Thought object with the next thought based on the `input`")
+user("Provide the next thought based on the `input`")
},
}.copy(configuration = configuration),
scope = scope,
serializer = Thought.serializer()
)
Expand Down

0 comments on commit 3b0c91f

Please sign in to comment.