diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 919c3b8f99..274bbf19ae 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,6 +7,7 @@ import Planner from "./components/Planner"; import CodeEditor from "./components/CodeEditor"; import Browser from "./components/Browser"; import Errors from "./components/Errors"; +import BannerSettings from "./components/BannerSettings"; const TAB_OPTIONS = ["terminal", "planner", "code", "browser"] as const; type TabOption = (typeof TAB_OPTIONS)[number]; @@ -55,7 +56,8 @@ function App(): JSX.Element {
-

OpenDevin's Workspace

+

OpenDevin's Workspace

+
{TAB_OPTIONS.map((tab) => ( diff --git a/frontend/src/components/BannerSettings.css b/frontend/src/components/BannerSettings.css new file mode 100644 index 0000000000..361736e311 --- /dev/null +++ b/frontend/src/components/BannerSettings.css @@ -0,0 +1,12 @@ +.banner { + display: flex; + justify-content: center; + align-items: center; + gap: 1rem; +} + +select { + padding: 0.5rem; + border: 0; + border-radius: 5px; +} diff --git a/frontend/src/components/BannerSettings.tsx b/frontend/src/components/BannerSettings.tsx new file mode 100644 index 0000000000..eb47154a7a --- /dev/null +++ b/frontend/src/components/BannerSettings.tsx @@ -0,0 +1,49 @@ +import React, { ChangeEvent } from "react"; +import { + AGENTS, + MODELS, + changeAgent, + changeModel, +} from "../services/settingsService"; +import "./BannerSettings.css"; + +function ModelSelect(): JSX.Element { + return ( + + ); +} + +function AgentSelect(): JSX.Element { + return ( + + ); +} + +function BannerSettings(): JSX.Element { + return ( +
+ + +
+ ); +} + +export default BannerSettings; diff --git a/frontend/src/services/settingsService.ts b/frontend/src/services/settingsService.ts new file mode 100644 index 0000000000..efd9c6e19c --- /dev/null +++ b/frontend/src/services/settingsService.ts @@ -0,0 +1,36 @@ +import socket from "../socket/socket"; +import { setInitialized } from "../state/taskSlice"; +import store from "../store"; + +export const MODELS = [ + "gpt-3.5-turbo-1106", + "gpt-4-0125-preview", + "claude-3-haiku-20240307", + "claude-3-sonnet-20240229", + "claude-3-sonnet-20240307", +]; + +export type Model = (typeof MODELS)[number]; + +export const AGENTS = ["LangchainsAgent", "CodeActAgent"]; + +export type Agent = (typeof AGENTS)[number]; + +function changeSetting(setting: string, value: string): void { + const event = { action: "initialize", args: { [setting]: value } }; + const eventString = JSON.stringify(event); + socket.send(eventString); + store.dispatch(setInitialized(false)); +} + +export function changeModel(model: Model): void { + changeSetting("model", model); +} + +export function changeAgent(agent: Agent): void { + changeSetting("agent", agent); +} + +export function changeDirectory(directory: string): void { + changeSetting("directory", directory); +} diff --git a/opendevin/server/session.py b/opendevin/server/session.py index 1dd4926ca6..1852f5bd95 100644 --- a/opendevin/server/session.py +++ b/opendevin/server/session.py @@ -115,14 +115,14 @@ class Session: async def create_controller(self, start_event=None): directory = DEFAULT_WORKSPACE_DIR - if start_event and "directory" in start_event.args: - directory = start_event.args["directory"] + if start_event and "directory" in start_event["args"]: + directory = start_event["args"]["directory"] agent_cls = "LangchainsAgent" - if start_event and "agent_cls" in start_event.args: - agent_cls = start_event.args["agent_cls"] + if start_event and "agent_cls" in start_event["args"]: + agent_cls = start_event["args"]["agent_cls"] model = LLM_MODEL - if start_event and "model" in start_event.args: - model = start_event.args["model"] + if start_event and "model" in start_event["args"]: + model = start_event["args"]["model"] if not os.path.exists(directory): print(f"Workspace directory {directory} does not exist. Creating it...") os.makedirs(directory)