Skip to content

Commit

Permalink
Projects Endpoints (#439)
Browse files Browse the repository at this point in the history
* Project endpoints

* Get Projects By Organization endpoint

* New Token class

* Postman collection updated
  • Loading branch information
javipacheco authored Sep 19, 2023
1 parent 3b0c91f commit a50b96e
Show file tree
Hide file tree
Showing 14 changed files with 914 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +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 configuration: PromptConfiguration = PromptConfiguration(temperature = 0.0)
) {

private val logger = KotlinLogging.logger {}
Expand All @@ -42,14 +42,15 @@ class ReActAgent(
serializer = AgentFinish.serializer(),
prompt =
Prompt {
+system("You are an expert in providing answers")
+chain.chainToMessages()
+user("Provide the final answer to the `input` in a sentence or paragraph")
+user("input: $input")
+assistant(
"I should create a AgentFinish object with the final answer based on the thoughts and observations"
)
}.copy(configuration = configuration)
+system("You are an expert in providing answers")
+chain.chainToMessages()
+user("Provide the final answer to the `input` in a sentence or paragraph")
+user("input: $input")
+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 @@ -58,20 +59,21 @@ class ReActAgent(
serializer = AgentAction.serializer(),
prompt =
Prompt {
+system(
"You are an expert in tool selection. You are given a `input` and a `chain` of thoughts and observations."
)
+user("input:")
+input
+assistant("chain:")
+chain.chainToMessages()
+assistant("I can only use this tools:")
+tools.toolsToMessages()
+assistant(
"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)
+system(
"You are an expert in tool selection. You are given a `input` and a `chain` of thoughts and observations."
)
+user("input:")
+input
+assistant("chain:")
+chain.chainToMessages()
+assistant("I can only use this tools:")
+tools.toolsToMessages()
+assistant(
"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 @@ -90,14 +92,17 @@ class ReActAgent(
model.prompt(
prompt =
Prompt {
+input
+assistant("chain:")
+chain.chainToMessages()
+assistant(
"`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),
+input
+assistant("chain:")
+chain.chainToMessages()
+assistant(
"`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 @@ -106,15 +111,18 @@ class ReActAgent(
return model.prompt(
prompt =
Prompt {
+system("You are an expert in providing next steps to solve a problem")
+system("You are given a `input` provided by the user")
+user("input:")
+input
+assistant("I have access to tools:")
+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),
+system("You are an expert in providing next steps to solve a problem")
+system("You are given a `input` provided by the user")
+user("input:")
+input
+assistant("I have access to tools:")
+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
Loading

0 comments on commit a50b96e

Please sign in to comment.