1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
import { createSlice } from "@reduxjs/toolkit";
import { FullState } from "../../../../schema/FullState";
const TEST_TIMELINE = [
{
step: {
description: "Hi, please write bubble sort in python",
name: "User Input",
},
},
{
step: {
description: `\`\`\`python
def bubble_sort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
\`\`\``,
name: "Bubble Sort in Python",
},
},
{
step: {
description: "Now write it in Rust",
name: "User Input",
},
},
{
step: {
description: "Hello! This is a test...\n\n1, 2, 3, testing...",
name: "Testing",
},
},
{
step: {
description: `Sure, here's bubble sort written in rust: \n\`\`\`rust
fn bubble_sort<T: Ord>(values: &mut[T]) {
let len = values.len();
for i in 0..len {
for j in 0..(len - i - 1) {
if values[j] > values[j + 1] {
values.swap(j, j + 1);
}
}
}
}
\`\`\`\nIs there anything else I can answer?`,
name: "Rust Bubble Sort",
},
active: true,
},
];
const TEST_SLASH_COMMANDS = [
{
name: "edit",
description: "Edit the code",
},
{
name: "cmd",
description: "Generate a command",
},
{
name: "help",
description: "Get help using Continue",
},
];
const initialState: FullState = {
history: {
timeline: [],
current_index: 3,
} as any,
user_input_queue: [],
active: false,
slash_commands: [],
adding_highlighted_code: false,
selected_context_items: [],
config: {
system_message: "",
temperature: 0.5,
},
};
export const serverStateSlice = createSlice({
name: "serverState",
initialState,
reducers: {
setServerState: (state, action) => {
state.selected_context_items = [];
state.user_input_queue = [];
state.slash_commands = [];
Object.assign(state, action.payload);
},
temporarilyPushToUserInputQueue: (state, action) => {
state.user_input_queue = [...state.user_input_queue, action.payload];
},
temporarilyClearSession: (state) => {
state.history.timeline = [];
state.selected_context_items = [];
state.session_info = {
title: "Loading session...",
session_id: "",
date_created: "",
};
},
},
});
export const {
setServerState,
temporarilyPushToUserInputQueue,
temporarilyClearSession,
} = serverStateSlice.actions;
export default serverStateSlice.reducer;
|