Skip to content

Commit

Permalink
Merge pull request #43 from ssoudan/upd
Browse files Browse the repository at this point in the history
GPT 3.5 Turbo 0613
  • Loading branch information
ssoudan authored Jun 14, 2023
2 parents e0ca15e + 2fb4b4e commit c8d2e5a
Show file tree
Hide file tree
Showing 30 changed files with 479 additions and 360 deletions.
313 changes: 144 additions & 169 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ parameters:
```

=============
# Action SandboxedPython result:
# Action SandboxedPython response:
```yaml
stdout: |
The solution to x^2 - 5x + 6 = 0 is [2, 3]
Expand Down Expand Up @@ -235,7 +235,7 @@ parameters:
```

============= 2 messages in the chat history =============
# Action result:
# Action response:
```yaml
stdout: |
The temperature in San Jose, California, USA is 12.78°C and 10 Day Weather-San Jose, CA ; Mon 17 · 59°. 1%. NW 13 mph. Cloudy. High 59F. Winds NW at 10 to 15 mph. ; Tue 18 · 61°. 7%. NW 14 mph. Partly cloudy. High 61F. Winds ...
Expand Down Expand Up @@ -373,7 +373,7 @@ parameters:

WORLD:
<pre><code>
# Action result:
# Action response:
```yaml
status: 0
stdout: |
Expand Down Expand Up @@ -432,7 +432,7 @@ parameters:

WORLD:
<pre><code>
# Action result:
# Action response:
```yaml
rooms: []
```
Expand Down Expand Up @@ -462,7 +462,7 @@ parameters:

WORLD:
<pre><code>
# Action result:
# Action response:
```yaml
rooms:
- name: Living
Expand Down Expand Up @@ -530,7 +530,7 @@ parameters:

WORLD:
<pre><code>
# Action result:
# Action response:
```yaml
lights:
- id: '23'
Expand Down Expand Up @@ -781,7 +781,7 @@ parameters:

WORLD:
<pre><code>
# Action result:
# Action response:
```yaml
rooms:
- name: Kitchen
Expand Down Expand Up @@ -847,7 +847,7 @@ input:

WORLD:
<pre><code>
# Action result:
# Action response:
```yaml
lights:
- id: '26'
Expand Down
13 changes: 4 additions & 9 deletions experiments/analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,11 @@
"metadata": {},
"outputs": [],
"source": [
"weak_prior = BetaPrior(alpha=100, beta=100)\n",
"strong_prior = BetaPrior(alpha=10000, beta=10000)\n",
"trace_weak, trace_strong = run_scenario_twovariant(data, \n",
" weak_prior=BetaPrior(alpha=100, beta=100), \n",
" strong_prior=BetaPrior(alpha=10000, beta=10000))"
" weak_prior=weak_prior,\n",
" strong_prior=strong_prior)"
]
},
{
Expand All @@ -451,13 +453,6 @@
"source": [
"$\\textrm{relative\\_uplift} = (\\textrm{treatment} - \\textrm{control}) / \\textrm{control}$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion sapiens/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ serde_yaml = "0.9.21"

regex = "1.8.4"

clap = { version = "4.3.2", optional = true }
clap = { version = "4.3.4", optional = true }

# OpenAI API - OpenAI and lm-sys/FastChat
tiktoken-rs = { version = "0.4.2", features = ["async-openai"] }
Expand Down
45 changes: 23 additions & 22 deletions sapiens/src/chains/agents/ooda/multistep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use crate::{chains, prompt, SapiensConfig, WeakRuntimeObserver};
const PREFIX: &str = r"You are part of a group of cooperating assistants named Sapiens. Use available tools to answer the question as best as you can.
You will collectively proceed iteratively using an OODA loop. Don't overstep your role.
- Action result will be provided.
- Never produce the result of an Action.
- Action response will be provided.
- Never produce the response of an Action.
- Only use YAML for the Action.
- The loop will repeated until you have the answer to the original question.
- No task is complete until the Conclude Tool is used to provide the answer.
";
Expand Down Expand Up @@ -68,7 +69,7 @@ tool_name: <ToolName>
parameters:
<...>
```
We will take further action based on the result.
We will take further action based on the response.
====================
Notes:
Expand All @@ -87,7 +88,7 @@ const OBSERVER_PROTO_SECOND_INPUT: &str = r#"
## Orientation:
- SandboxedPython can be used to sort the list.
- I need to provide only the `tool_name` and `parameters` fields for the SandboxedPython Tool.
- I expect the result of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I expect the response of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I need to use the Conclude Tool to terminate the task when I have the sorted list in plain text.
## Decision:
- We can use the sorted() function of Python to sort the list.
Expand All @@ -100,8 +101,8 @@ parameters:
sorted_list = sorted(lst)
print(f"The sorted list is {sorted_list}")
```
We will take further action based on the result.
# Action SandboxedPython result:
We will take further action based on the response.
# Action SandboxedPython response:
```yaml
stdout: |
The sorted list is [1, 2, 3, 4, 5]
Expand All @@ -112,15 +113,15 @@ stderr: ''
const OBSERVER_PROTO_SECOND_RESPONSE: &str = r"
## Observations:
- We needed to sort the list in ascending order.
- We have the result of the Action.
- We have the response of the Action.
- We have the sorted list: [1, 2, 3, 4, 5].
";

const ORIENTER_PROTO_INITIAL_RESPONSE: &str = r#"
## Orientation:
- SandboxedPython can be used to sort the list.
- I need to provide only the `tool_name` and `parameters` fields for the SandboxedPython Tool.
- I expect the result of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I expect the response of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I need to use the Conclude Tool to terminate the task when I have the sorted list in plain text.
"#;

Expand All @@ -136,16 +137,16 @@ parameters:
sorted_list = sorted(lst)
print(f"The sorted list is {sorted_list}")
```
We will take further action based on the result.
# Action SandboxedPython result:
We will take further action based on the response.
# Action SandboxedPython response:
```yaml
stdout: |
The sorted list is [1, 2, 3, 4, 5]
stderr: ''
```
## Observations:
- We needed to sort the list in ascending order.
- We have the result of the Action.
- We have the response of the Action.
- We have the sorted list: [1, 2, 3, 4, 5].
"#;

Expand All @@ -170,16 +171,16 @@ parameters:
sorted_list = sorted(lst)
print(f"The sorted list is {sorted_list}")
```
We will take further action based on the result.
# Action SandboxedPython result:
We will take further action based on the response.
# Action SandboxedPython response:
```yaml
stdout: |
The sorted list is [1, 2, 3, 4, 5]
stderr: ''
```
## Observations:
- We needed to sort the list in ascending order.
- We have the result of the Action.
- We have the response of the Action.
- We have the sorted list: [1, 2, 3, 4, 5].
## Orientation:
- I know the answer to the original question.
Expand All @@ -201,19 +202,19 @@ parameters:
sorted_list = sorted(lst)
print(f"The sorted list is {sorted_list}")
```
That's it for now. We will take further action based on the result.
That's it for now. We will take further action based on the response.
"#;

const ACTOR_PROTO_SECOND_INPUT: &str = r#"
# Action SandboxedPython result:
# Action SandboxedPython response:
```yaml
stdout: |
The sorted list is [1, 2, 3, 4, 5]
stderr: ''
```
## Observations:
- We needed to sort the list in ascending order.
- We have the result of the Action.
- We have the response of the Action.
- We have the sorted list: [1, 2, 3, 4, 5].
## Orientation:
- I know the answer to the original question.
Expand Down Expand Up @@ -830,7 +831,7 @@ mod tests {
content: indoc! {r#"
## Observations:
- We needed to sort the list in ascending order.
- We have the result of the Action.
- We have the response of the Action.
- We have the sorted list: [1, 2, 3, 4, 5].
"#
}
Expand Down Expand Up @@ -858,7 +859,7 @@ mod tests {
content: indoc! {r#"
## Observations:
- We needed to sort the list in ascending order.
- We have the result of the Action.
- We have the response of the Action.
- We have the sorted list: [1, 2, 3, 4, 5].
"#
}
Expand Down Expand Up @@ -898,7 +899,7 @@ mod tests {
content: indoc! {r#"
## Observations:
- We needed to sort the list in ascending order.
- We have the result of the Action.
- We have the response of the Action.
- We have the sorted list: [1, 2, 3, 4, 5].
"#
}
Expand Down Expand Up @@ -964,7 +965,7 @@ mod tests {
## Orientation:
- SandboxedPython can be used to sort the list.
- I need to provide only the `tool_name` and `parameters` fields for the SandboxedPython Tool.
- I expect the result of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I expect the response of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I need to use the Conclude Tool to terminate the task when I have the sorted list in plain text."#
}.trim().to_string(),
usage: None,
Expand All @@ -991,7 +992,7 @@ mod tests {
sorted_list = sorted(lst)
print(f"The sorted list is {sorted_list}")
```
That's it for now. We will take further action based on the result.
That's it for now. We will take further action based on the response.
"#
}
.trim()
Expand Down
23 changes: 12 additions & 11 deletions sapiens/src/chains/agents/ooda/one_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ pub struct Agent {
const PREFIX: &str = r"You are Sapiens, a large language model assisting the WORLD. Use available tools to answer the question as best as you can.
You will proceed iteratively using an OODA loop.
- Action result will be provided to you.
- Never produce the result of an Action.
- Action response will be provided to you.
- Never produce the response of an Action.
- Only use YAML for the Action.
- The loop will repeated until you have the answer to the original question.
- No task is complete until the Conclude Tool is used to provide the answer.
- You cannot use jinja2 templating in your response. Be concise.
Expand Down Expand Up @@ -49,13 +50,13 @@ tool_name: <ToolName>
parameters:
<...>
```
We will take further action based on the result.
We will take further action based on the response.
====================
Notes:
- Action has the following fields: `tool_name` and `parameters` ONLY.
- `parameters` uses the format specified for the Tool.
- `result_fields` is the format you can expect of the result of the Action. You can use this to orient yourself but never use it in your response.
- `responses_content` is the format you can expect of the response of the Action. You can use this to orient yourself but never use it in your response.
- One Action at a time. No more. No less.
";

Expand All @@ -66,7 +67,7 @@ const PROTO_EXCHANGE_2: &str = r#"
## Orientation:
- SandboxedPython can be used to sort the list.
- I need to provide only the `tool_name` and `parameters` fields for the SandboxedPython Tool.
- I expect the result of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I expect the response of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I need to use the Conclude Tool to terminate the task when I have the sorted list in plain text.
## Decision:
- We can use the sorted() function of Python to sort the list.
Expand All @@ -79,11 +80,11 @@ parameters:
sorted_list = sorted(lst)
print(f"The sorted list is {sorted_list}")
```
We will take further action based on the result.
We will take further action based on the response.
"#;

const PROTO_EXCHANGE_3: &str = r"
# Action SandboxedPython result:
# Action SandboxedPython response:
```yaml
stdout: |
The sorted list is [1, 2, 3, 4, 5]
Expand All @@ -94,7 +95,7 @@ stderr: ''
const PROTO_EXCHANGE_4: &str = r"
## Observations:
- We needed to sort the list in ascending order.
- We have the result of the Action.
- We have the response of the Action.
- We have the sorted list: [1, 2, 3, 4, 5].
## Orientation:
- I know the answer to the original question.
Expand Down Expand Up @@ -198,7 +199,7 @@ impl Agent {
role: Role::User,
};

// Add the result to the chat history
// Add the response to the chat history
chat_history.add_chitchat(entry).await;
}
_ => {
Expand Down Expand Up @@ -295,7 +296,7 @@ mod tests {
## Orientation:
- SandboxedPython can be used to sort the list.
- I need to provide only the `tool_name` and `parameters` fields for the SandboxedPython Tool.
- I expect the result of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I expect the response of the Action to contains the field `stdout` with the sorted list and `stderr` empty.
- I need to use the Conclude Tool to terminate the task when I have the sorted list in plain text.
## Decision:
- We can use the sorted() function of Python to sort the list.
Expand All @@ -308,7 +309,7 @@ mod tests {
sorted_list = sorted(lst)
print(f"The sorted list is {sorted_list}")
```
We will take further action based on the result.
We will take further action based on the response.
"#
}.to_string(),
usage: None,
Expand Down
Loading

0 comments on commit c8d2e5a

Please sign in to comment.