Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
commit
Vasek Mlejnsky27b46c137ec4
diff --git a/api-service/.openapi-generator/FILES b/api-service/.openapi-generator/FILESindex f8f764950..f22cbb2e4 100644--- a/api-service/.openapi-generator/FILES+++ b/api-service/.openapi-generator/FILES@@ -22,7 +22,7 @@ playground_client/docs/ProcessResponse.mdplayground_client/docs/ReadFilesystemFileResponse.mdplayground_client/docs/SessionResponse.mdplayground_client/docs/StartProcessParams.md-playground_client/docs/ToolsHumanResponse.md+playground_client/docs/ToolsLogOutput.mdplayground_client/docs/WriteFilesystemFileRequest.mdplayground_client/docs/WriteProcessStdinRequest.mdplayground_client/exceptions.py@@ -45,7 +45,7 @@ playground_client/models/process_response.pyplayground_client/models/read_filesystem_file_response.pyplayground_client/models/session_response.pyplayground_client/models/start_process_params.py-playground_client/models/tools_human_response.py+playground_client/models/tools_log_output.pyplayground_client/models/write_filesystem_file_request.pyplayground_client/models/write_process_stdin_request.pyplayground_client/rest.py@@ -69,7 +69,7 @@ playground_client/test/test_process_response.pyplayground_client/test/test_read_filesystem_file_response.pyplayground_client/test/test_session_response.pyplayground_client/test/test_start_process_params.py-playground_client/test/test_tools_human_response.py+playground_client/test/test_tools_log_output.pyplayground_client/test/test_write_filesystem_file_request.pyplayground_client/test/test_write_process_stdin_request.pyplayground_client_README.mddiff --git a/api-service/Makefile b/api-service/Makefileindex 6938081de..15c51e3cd 100644--- a/api-service/Makefile+++ b/api-service/Makefile@@ -1,4 +1,5 @@generate-playground-client:+ yarn --cwd ./playground generaterm -rf ./playground_clientnpx @openapitools/openapi-generator-cli generate \-i ./playground/swagger.json \diff --git a/api-service/codegen/agent/base.py b/api-service/codegen/agent/base.pyindex c42d16830..6be188d9d 100644--- a/api-service/codegen/agent/base.py+++ b/api-service/codegen/agent/base.py@@ -9,16 +9,26 @@ from langchain.tools.base import BaseToolfrom codegen.agent.parsing import parse_thoughts_and_actions, ToolLog+# FINAL_ANSWER_TRIGGERS = ["Final Answer:", "FinalAnswer", "Final Answer"]+FINAL_ANSWER_ACTION = "Final Answer:"FINAL_ANSWER_ACTION_NO_WHITESPACE = "FinalAnswer"-ACTIONS_QUEUE = "action_queue"++ACTIONS_QUEUE = "actions_queue"MALFORMED_ANSWER = "malformed_answer"+class CodegenAgent(ChatAgent):def _extract_tool_and_input(self, text: str) -> Optional[Tuple[str, str | None]]:+ # if any(trigger in text for trigger in FINAL_ANSWER_TRIGGERS):if FINAL_ANSWER_ACTION in text:return "Final Answer", text.split(FINAL_ANSWER_ACTION)[-1].strip()try:+ # `ACTIONS_QUEUE` is not a real tool. The original implementation of `extract_tool_and_input` parses LLM's output. Our override doesn't do that.+ # Instead, we parse the LLM's output inside the `_atake_next_step` of the AgentExecutor. We do that because sometimes the LLM malforms+ # the desired format we specified in the prompt and puts <action> tags in the wrong place.+ # We say "the raw LLM's output is an input of ACTIONS_QUEUE tool" and parse the ACTIONS_QUEUE "tool" in the `_atake_next_step` while trying to be more resilient towards+ # malforrmed input and <action> tags in unexpected places.return ACTIONS_QUEUE, textexcept Exception as e:print(traceback.format_exc())@@ -26,7 +36,7 @@ class CodegenAgent(ChatAgent):# Sometimes the agent just completely messed up the output format.# We want to remind it that the last answer was wrong and it should# follow the format.- # TODO: This doesn't work+ # TODO: Improve, it doesn't always need to be malformed answer.return (MALFORMED_ANSWER,f"Wrong format! Follow the format! Reminder to ALWAYS use the exact the action `Final Answer` when you know the final answer. I just tried to parse your last reponse with `xml.etree.ElementTree.fromstring()` and received this error:\n{e}Reminder, that you should follow the format I told you!",@@ -56,7 +66,7 @@ class CodegenAgentExecutor(AgentExecutor):observation_prefix=self.agent.observation_prefix,)else:- observation = await InvalidTool().arun( # type: ignore+ observation = await InvalidTool().arun( # type: ignoretool_name,verbose=self.verbose,color=None,@@ -105,15 +115,16 @@ class CodegenAgentExecutor(AgentExecutor):output, verbose=self.verbose, color="green")- # The `ACTIONS_QUEUE` isn't really a name of a tool.- # It's a way for us to specify that the LLM passed multiple actions in a single response.- # We handle this case by running each action one by one.if output.tool == ACTIONS_QUEUE:+ # TODO: Assign observations to each tool separately. Currently we return observation only from the last tool in the list.observation = ""-# Go through each action and run it.# Collect outputs from each action.- for action in (cast(ToolLog, action) for action in parse_thoughts_and_actions(output.tool_input) if action["type"] == "tool"):+ for action in (+ cast(ToolLog, action)+ for action in parse_thoughts_and_actions(output.tool_input)+ if action["type"] == "tool"+ ):observation = await self._arun_tool(tool_name=action["tool_name"],tool_input=action["tool_input"],@@ -131,12 +142,6 @@ class CodegenAgentExecutor(AgentExecutor):# )# + "==="# )-else:- observation = await self._arun_tool(- tool_name=output.tool,- tool_input=output.tool_input,- name_to_tool_map=name_to_tool_map,- color_mapping=color_mapping,- )+ raise ValueError("Unknown tool:", output.tool)return output, observationdiff --git a/api-service/codegen/prompt.py b/api-service/codegen/prompt.pyindex 0f5dddd92..43179985f 100644--- a/api-service/codegen/prompt.py+++ b/api-service/codegen/prompt.py@@ -1,7 +1,9 @@# - ALWAYS use `import` to import packages.# - Make sure any code you generate is JSON escaped.SYSTEM_PREFIX = """You are an AI JavaScript developer assistant.+- DO NOT BE STUPID- NEVER deploy code before you run it and are sure it is working.+- NEVER perform unsecure operations like disabling SSL certificates and similar.- You are building an Express server that handles REST API.- The `express` package is already installed.- Follow the user's instructions carefully & to the letter.@@ -68,15 +70,17 @@ app.listen(port, async () => {{]HUMAN_INSTRUCTIONS_SUFFIX = [- "Do not forget to use async and await when sending message",- # "Think about it and plan your work first",- "If something is not working and you do not know why, use the tool `AskHuman` to ask for help",- # "If you do not know how to use an NPM package, DO NOT COME UP WITH IMAGINARY CODE, instead use the tool `AskHuman` to ask for help",- "ALWAYS run the code before you submit the answer",- "Generate the full required server code and and make sure it runs without any errors",- "ALWAYS test that the generated server works as required by making mock `curl` requests to the server",- # "Once all works without any bugs and errors, write the code to the file",- # "Deploy the code",- "Once you are done, output the final code as the 'Final answer:'"- # "Thought: Here is the plan of how I will go about solving this based on the instructions I got:\n1.",+ # "Do not forget to use async and await",+ # # "Think about it and plan your work first",+ # "If you think there might be multiple paths forward, use the tool `LetHumanChoose` to choose from them. Do not be confident in picking the right path forward instead of the human",+ # "If something is not working and you do not know why, use the tool `AskHuman` to ask for help",+ # "Do not use third party packages without first asking the human for permission or presenting the human with multiple alternative options",+ # # "If you do not know how to use an NPM package, DO NOT COME UP WITH IMAGINARY CODE, instead use the tool `AskHuman` to ask for help",+ # "ALWAYS run the code before you submit the answer",+ # "Generate the full required server code and and make sure it runs without any errors",+ # "ALWAYS test that the generated server works as required by making mock `curl` requests to the server",+ # # "Once all works without any bugs and errors, write the code to the file",+ # # "Deploy the code",+ # "Once you are done, output the final code as the 'Final answer:'"+ # # "Thought: Here is the plan of how I will go about solving this based on the instructions I got:\n1.",]diff --git a/api-service/codegen/tools/human/tools.py b/api-service/codegen/tools/human/tools.pyindex 330c16405..e2438ef08 100644--- a/api-service/codegen/tools/human/tools.py+++ b/api-service/codegen/tools/human/tools.py@@ -1,8 +1,9 @@from collections.abc import Generatorfrom typing import Any+from time import sleepfrom codegen.tools.async_tool import async_tool-from playground_client.models.tools_human_response import ToolsHumanResponse+from playground_client.models.tools_log_output import ToolsLogOutputfrom session.playground.base import Playground@@ -14,18 +15,38 @@ def create_human_tools(# Ensure that the function is a generator even if no tools are yieldedyield from ()+ @async_tool("LetHumanChoose")+ async def let_human_choose(options: str) -> str:+ """Let a human choose from one of the options. Sometimes there might be multiple viable paths forward. For example, when the human did not specify implementation details like a third party service, library, or an algorithm.+ Instead of you choosing the path forward, use this tool to present up to 5 best options forward for the human to choose from.+ The input should be a question for the human and possible options. Provide a 1-3 sentence long summary for each option. Example usage:+ <action tool="LetHumanChoose">+ <question>A question asking the human for the path forward</question>+ <option>Option A and the reason why it might be a good idea</option>+ <option>Option B and the reason why it might be a good idea</option>+ </action>+ """+ print("+++ OPTIONS")+ print(options)+ print("--- OPTIONS")+ sleep(60)+ return "Spotify API"+ # output = await playground.let_human_choose(extract_code(options))++ yield let_human_choose+@async_tool("AskHuman")async def ask_human(question: str) -> str:"""You can ask a human for guidance when you think you got stuck or you are not sure what to do next. The input should be a question. Example usage:<action tool="AskHuman">I'm not sure what to do, can you specify what should to do next?</action>"""- thread: Any = playground.api.wait_for_human_response(+ thread: Any = playground.api.wait_for_log_output(run_id=run_id,async_req=True,)- response: ToolsHumanResponse = thread.get()+ response: ToolsLogOutput = thread.get()return response.responseyield ask_humandiff --git a/api-service/playground/src/data/humanResponse.ts b/api-service/playground/src/data/logOutput.tssimilarity index 78%rename from api-service/playground/src/data/humanResponse.tsrename to api-service/playground/src/data/logOutput.tsindex 166bf3f74..c5d6bbb18 100644--- a/api-service/playground/src/data/humanResponse.ts+++ b/api-service/playground/src/data/logOutput.ts@@ -17,6 +17,7 @@ export const deploymentsTable = 'deployments'export const routesTable = 'routes'function checkForResponse(payloadList: any[]): string | null {+ // Get the last log from the deployment logs.const payload = payloadList.length > 0 ? payloadList[payloadList.length - 1] : undefinedif (!payload) {@@ -29,7 +30,7 @@ function checkForResponse(payloadList: any[]): string | null {return null}-export async function waitForHumanResponse({ runID }: { runID: string }) {+export async function waitForLogOutput({ runID }: { runID: string }) {const { resolve, promise } = createDeferredPromise<string>()let updateSub: RealtimeChannel | undefined@@ -37,8 +38,9 @@ export async function waitForHumanResponse({ runID }: { runID: string }) {try {setTimeout(() => {resolve('Timeout')- }, 3600000)+ }, 3600000) // 1 hour+ // Subscribe to the changes in the deployment.updateSub = client.channel('any-server').on('postgres_changes',{@@ -48,13 +50,15 @@ export async function waitForHumanResponse({ runID }: { runID: string }) {filter: `id=eq.${runID}`,}, payload => {const response = checkForResponse(payload.new.logs as any)+ console.log('Wait for log output', response)if (response) {resolve(response)}}).subscribe()-+ // We fetch the deployment and check if the response is already there+ // because it may arrive before we subscribed and that would mean the subscribe would never trigger.const deployment = await client.from(deploymentsTable).select('*')@@ -67,10 +71,9 @@ export async function waitForHumanResponse({ runID }: { runID: string }) {resolve(response)}} catch (err) {- resolve('Error retrieving human response')- } finally {+ resolve('Error retrieving log output')}const response = await promiseupdateSub?.unsubscribe()return response-}+}\ No newline at end of filediff --git a/api-service/playground/src/data/toolsController.ts b/api-service/playground/src/data/toolsController.tsindex b6f7280fb..f9d47a13e 100644--- a/api-service/playground/src/data/toolsController.ts+++ b/api-service/playground/src/data/toolsController.ts@@ -4,19 +4,19 @@ import {Route,Query,} from 'tsoa'-import { waitForHumanResponse } from './humanResponse'+import { waitForLogOutput } from './logOutput'-interface ToolsHumanResponse {+interface ToolsLogOutput {response: string}@Route('tools')export class ToolsController extends Controller {- @Get('humanResponse')- public async waitForHumanResponse(+ @Get('logOutput')+ public async waitForLogOutput(@Query() runID: string,- ): Promise<ToolsHumanResponse> {- const response = await waitForHumanResponse({+ ): Promise<ToolsLogOutput> {+ const response = await waitForLogOutput({runID,})diff --git a/api-service/playground/src/generated/routes.ts b/api-service/playground/src/generated/routes.tsindex 694d62599..93fd44579 100644--- a/api-service/playground/src/generated/routes.ts+++ b/api-service/playground/src/generated/routes.ts@@ -36,7 +36,7 @@ const models: TsoaRoute.Models = {"additionalProperties": false,},// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa- "ToolsHumanResponse": {+ "ToolsLogOutput": {"dataType": "refObject","properties": {"response": {"dataType":"string","required":true},@@ -193,11 +193,11 @@ export function RegisterRoutes(app: Router) {}});// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa- app.get('/tools/humanResponse',+ app.get('/tools/logOutput',...(fetchMiddlewares<RequestHandler>(ToolsController)),- ...(fetchMiddlewares<RequestHandler>(ToolsController.prototype.waitForHumanResponse)),+ ...(fetchMiddlewares<RequestHandler>(ToolsController.prototype.waitForLogOutput)),- function ToolsController_waitForHumanResponse(request: any, response: any, next: any) {+ function ToolsController_waitForLogOutput(request: any, response: any, next: any) {const args = {runID: {"in":"query","name":"runID","required":true,"dataType":"string"},};@@ -211,7 +211,7 @@ export function RegisterRoutes(app: Router) {const controller = new ToolsController();- const promise = controller.waitForHumanResponse.apply(controller, validatedArgs as any);+ const promise = controller.waitForLogOutput.apply(controller, validatedArgs as any);promiseHandler(controller, promise, response, undefined, next);} catch (err) {return next(err);diff --git a/api-service/playground/swagger.json b/api-service/playground/swagger.jsonindex b59e648c5..679f64175 100644--- a/api-service/playground/swagger.json+++ b/api-service/playground/swagger.json@@ -34,7 +34,7 @@"type": "object","additionalProperties": false},- "ToolsHumanResponse": {+ "ToolsLogOutput": {"properties": {"response": {"type": "string"@@ -312,16 +312,16 @@}}},- "/tools/humanResponse": {+ "/tools/logOutput": {"get": {- "operationId": "WaitForHumanResponse",+ "operationId": "WaitForLogOutput","responses": {"200": {"description": "Ok","content": {"application/json": {"schema": {- "$ref": "#/components/schemas/ToolsHumanResponse"+ "$ref": "#/components/schemas/ToolsLogOutput"}}}diff --git a/api-service/playground_client/__init__.py b/api-service/playground_client/__init__.pyindex eaf813cf2..e514b7fcc 100644--- a/api-service/playground_client/__init__.py+++ b/api-service/playground_client/__init__.py@@ -47,6 +47,6 @@ from playground_client.models.process_response import ProcessResponsefrom playground_client.models.read_filesystem_file_response import ReadFilesystemFileResponsefrom playground_client.models.session_response import SessionResponsefrom playground_client.models.start_process_params import StartProcessParams-from playground_client.models.tools_human_response import ToolsHumanResponse+from playground_client.models.tools_log_output import ToolsLogOutputfrom playground_client.models.write_filesystem_file_request import WriteFilesystemFileRequestfrom playground_client.models.write_process_stdin_request import WriteProcessStdinRequestdiff --git a/api-service/playground_client/api/default_api.py b/api-service/playground_client/api/default_api.pyindex 8763349d8..3bef233b6 100644--- a/api-service/playground_client/api/default_api.py+++ b/api-service/playground_client/api/default_api.py@@ -31,7 +31,7 @@ from playground_client.models.process_response import ProcessResponsefrom playground_client.models.read_filesystem_file_response import ReadFilesystemFileResponsefrom playground_client.models.session_response import SessionResponsefrom playground_client.models.start_process_params import StartProcessParams-from playground_client.models.tools_human_response import ToolsHumanResponse+from playground_client.models.tools_log_output import ToolsLogOutputfrom playground_client.models.write_filesystem_file_request import WriteFilesystemFileRequestfrom playground_client.models.write_process_stdin_request import WriteProcessStdinRequest@@ -1841,13 +1841,13 @@ class DefaultApi(object):_request_auth=_params.get('_request_auth'))@validate_arguments- def wait_for_human_response(self, run_id : StrictStr, **kwargs) -> ToolsHumanResponse: # noqa: E501- """wait_for_human_response # noqa: E501+ def wait_for_log_output(self, run_id : StrictStr, **kwargs) -> ToolsLogOutput: # noqa: E501+ """wait_for_log_output # noqa: E501This method makes a synchronous HTTP request by default. To make anasynchronous HTTP request, please pass async_req=True- >>> thread = api.wait_for_human_response(run_id, async_req=True)+ >>> thread = api.wait_for_log_output(run_id, async_req=True)>>> result = thread.get():param run_id: (required)@@ -1865,19 +1865,19 @@ class DefaultApi(object)::return: Returns the result object.If the method is called asynchronously,returns the request thread.- :rtype: ToolsHumanResponse+ :rtype: ToolsLogOutput"""kwargs['_return_http_data_only'] = True- return self.wait_for_human_response_with_http_info(run_id, **kwargs) # noqa: E501+ return self.wait_for_log_output_with_http_info(run_id, **kwargs) # noqa: E501@validate_arguments- def wait_for_human_response_with_http_info(self, run_id : StrictStr, **kwargs): # noqa: E501- """wait_for_human_response # noqa: E501+ def wait_for_log_output_with_http_info(self, run_id : StrictStr, **kwargs): # noqa: E501+ """wait_for_log_output # noqa: E501This method makes a synchronous HTTP request by default. To make anasynchronous HTTP request, please pass async_req=True- >>> thread = api.wait_for_human_response_with_http_info(run_id, async_req=True)+ >>> thread = api.wait_for_log_output_with_http_info(run_id, async_req=True)>>> result = thread.get():param run_id: (required)@@ -1903,7 +1903,7 @@ class DefaultApi(object)::return: Returns the result object.If the method is called asynchronously,returns the request thread.- :rtype: tuple(ToolsHumanResponse, status_code(int), headers(HTTPHeaderDict))+ :rtype: tuple(ToolsLogOutput, status_code(int), headers(HTTPHeaderDict))"""_params = locals()@@ -1928,7 +1928,7 @@ class DefaultApi(object):if _key not in _all_params:raise ApiTypeError("Got an unexpected keyword argument '%s'"- " to method wait_for_human_response" % _key+ " to method wait_for_log_output" % _key)_params[_key] = _valdel _params['kwargs']@@ -1961,11 +1961,11 @@ class DefaultApi(object):_auth_settings = [] # noqa: E501_response_types_map = {- '200': "ToolsHumanResponse",+ '200': "ToolsLogOutput",}return self.api_client.call_api(- '/tools/humanResponse', 'GET',+ '/tools/logOutput', 'GET',_path_params,_query_params,_header_params,diff --git a/api-service/playground_client/docs/DefaultApi.md b/api-service/playground_client/docs/DefaultApi.mdindex 5bdb69791..0fcda3ae7 100644--- a/api-service/playground_client/docs/DefaultApi.md+++ b/api-service/playground_client/docs/DefaultApi.md@@ -16,7 +16,7 @@ Method | HTTP request | Description[**read_filesystem_file**](DefaultApi.md#read_filesystem_file) | **GET** /sessions/{sessionID}/filesystem/file |[**start_process**](DefaultApi.md#start_process) | **POST** /sessions/{sessionID}/processes |[**stop_process**](DefaultApi.md#stop_process) | **DELETE** /sessions/{sessionID}/processes/{processID} |-[**wait_for_human_response**](DefaultApi.md#wait_for_human_response) | **GET** /tools/humanResponse |+[**wait_for_log_output**](DefaultApi.md#wait_for_log_output) | **GET** /tools/logOutput |[**write_filesystem_file**](DefaultApi.md#write_filesystem_file) | **PUT** /sessions/{sessionID}/filesystem/file |[**write_process_stdin**](DefaultApi.md#write_process_stdin) | **POST** /sessions/{sessionID}/processes/{processID}/stdin |@@ -771,8 +771,8 @@ No authorization required[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)-# **wait_for_human_response**-> ToolsHumanResponse wait_for_human_response(run_id)+# **wait_for_log_output**+> ToolsLogOutput wait_for_log_output(run_id)@@ -799,11 +799,11 @@ with playground_client.ApiClient(configuration) as api_client:run_id = 'run_id_example' # str |try:- api_response = api_instance.wait_for_human_response(run_id)- print("The response of DefaultApi->wait_for_human_response:\n")+ api_response = api_instance.wait_for_log_output(run_id)+ print("The response of DefaultApi->wait_for_log_output:\n")pprint(api_response)except Exception as e:- print("Exception when calling DefaultApi->wait_for_human_response: %s\n" % e)+ print("Exception when calling DefaultApi->wait_for_log_output: %s\n" % e)```### Parameters@@ -814,7 +814,7 @@ Name | Type | Description | Notes### Return type-[**ToolsHumanResponse**](ToolsHumanResponse.md)+[**ToolsLogOutput**](ToolsLogOutput.md)### Authorizationdiff --git a/api-service/playground_client/docs/ToolsHumanResponse.md b/api-service/playground_client/docs/ToolsHumanResponse.mddeleted file mode 100644index e2da018e4..000000000--- a/api-service/playground_client/docs/ToolsHumanResponse.md+++ /dev/null@@ -1,28 +0,0 @@-# ToolsHumanResponse---## Properties-Name | Type | Description | Notes------------- | ------------- | ------------- | --------------**response** | **str** | |--## Example--```python-from playground_client.models.tools_human_response import ToolsHumanResponse--# TODO update the JSON string below-json = "{}"-# create an instance of ToolsHumanResponse from a JSON string-tools_human_response_instance = ToolsHumanResponse.from_json(json)-# print the JSON string representation of the object-print ToolsHumanResponse.to_json()--# convert the object into a dict-tools_human_response_dict = tools_human_response_instance.to_dict()-# create an instance of ToolsHumanResponse from a dict-tools_human_response_form_dict = tools_human_response.from_dict(tools_human_response_dict)-```-[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)--diff --git a/api-service/playground_client/docs/ToolsLogOutput.md b/api-service/playground_client/docs/ToolsLogOutput.mdnew file mode 100644index 000000000..0b041952c--- /dev/null+++ b/api-service/playground_client/docs/ToolsLogOutput.md@@ -0,0 +1,28 @@+# ToolsLogOutput+++## Properties+Name | Type | Description | Notes+------------ | ------------- | ------------- | -------------+**response** | **str** | |++## Example++```python+from playground_client.models.tools_log_output import ToolsLogOutput++# TODO update the JSON string below+json = "{}"+# create an instance of ToolsLogOutput from a JSON string+tools_log_output_instance = ToolsLogOutput.from_json(json)+# print the JSON string representation of the object+print ToolsLogOutput.to_json()++# convert the object into a dict+tools_log_output_dict = tools_log_output_instance.to_dict()+# create an instance of ToolsLogOutput from a dict+tools_log_output_form_dict = tools_log_output.from_dict(tools_log_output_dict)+```+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)++diff --git a/api-service/playground_client/models/__init__.py b/api-service/playground_client/models/__init__.pyindex 50ee2e6ee..630984c3c 100644--- a/api-service/playground_client/models/__init__.py+++ b/api-service/playground_client/models/__init__.py@@ -32,6 +32,6 @@ from playground_client.models.process_response import ProcessResponsefrom playground_client.models.read_filesystem_file_response import ReadFilesystemFileResponsefrom playground_client.models.session_response import SessionResponsefrom playground_client.models.start_process_params import StartProcessParams-from playground_client.models.tools_human_response import ToolsHumanResponse+from playground_client.models.tools_log_output import ToolsLogOutputfrom playground_client.models.write_filesystem_file_request import WriteFilesystemFileRequestfrom playground_client.models.write_process_stdin_request import WriteProcessStdinRequestdiff --git a/api-service/playground_client/models/tools_human_response.py b/api-service/playground_client/models/tools_log_output.pysimilarity index 79%rename from api-service/playground_client/models/tools_human_response.pyrename to api-service/playground_client/models/tools_log_output.pyindex 6bf9cda62..5204de95a 100644--- a/api-service/playground_client/models/tools_human_response.py+++ b/api-service/playground_client/models/tools_log_output.py@@ -20,7 +20,7 @@ import jsonfrom pydantic import BaseModel, StrictStr-class ToolsHumanResponse(BaseModel):+class ToolsLogOutput(BaseModel):"""NOTE: This class is auto generated by OpenAPI Generator.Ref: https://openapi-generator.tech@@ -42,8 +42,8 @@ class ToolsHumanResponse(BaseModel):return json.dumps(self.to_dict())@classmethod- def from_json(cls, json_str: str) -> ToolsHumanResponse:- """Create an instance of ToolsHumanResponse from a JSON string"""+ def from_json(cls, json_str: str) -> ToolsLogOutput:+ """Create an instance of ToolsLogOutput from a JSON string"""return cls.from_dict(json.loads(json_str))def to_dict(self):@@ -55,20 +55,20 @@ class ToolsHumanResponse(BaseModel):return _dict@classmethod- def from_dict(cls, obj: dict) -> ToolsHumanResponse:- """Create an instance of ToolsHumanResponse from a dict"""+ def from_dict(cls, obj: dict) -> ToolsLogOutput:+ """Create an instance of ToolsLogOutput from a dict"""if obj is None:return Noneif type(obj) is not dict:- return ToolsHumanResponse.parse_obj(obj)+ return ToolsLogOutput.parse_obj(obj)# raise errors for additional fields in the inputfor _key in obj.keys():if _key not in cls.__properties:- raise ValueError("Error due to additional fields (not defined in ToolsHumanResponse) in the input: " + obj)+ raise ValueError("Error due to additional fields (not defined in ToolsLogOutput) in the input: " + obj)- _obj = ToolsHumanResponse.parse_obj({+ _obj = ToolsLogOutput.parse_obj({"response": obj.get("response")})return _objdiff --git a/api-service/playground_client/test/test_default_api.py b/api-service/playground_client/test/test_default_api.pyindex e2001aead..1cbe893bf 100644--- a/api-service/playground_client/test/test_default_api.py+++ b/api-service/playground_client/test/test_default_api.py@@ -100,8 +100,8 @@ class TestDefaultApi(unittest.TestCase):"""pass- def test_wait_for_human_response(self):- """Test case for wait_for_human_response+ def test_wait_for_log_output(self):+ """Test case for wait_for_log_output"""passdiff --git a/api-service/playground_client/test/test_tools_human_response.py b/api-service/playground_client/test/test_tools_log_output.pysimilarity index 65%rename from api-service/playground_client/test/test_tools_human_response.pyrename to api-service/playground_client/test/test_tools_log_output.pyindex 0d59c7473..4115f7b32 100644--- a/api-service/playground_client/test/test_tools_human_response.py+++ b/api-service/playground_client/test/test_tools_log_output.py@@ -16,11 +16,11 @@ import unittestimport datetimeimport playground_client-from playground_client.models.tools_human_response import ToolsHumanResponse # noqa: E501+from playground_client.models.tools_log_output import ToolsLogOutput # noqa: E501from playground_client.rest import ApiException-class TestToolsHumanResponse(unittest.TestCase):- """ToolsHumanResponse unit test stubs"""+class TestToolsLogOutput(unittest.TestCase):+ """ToolsLogOutput unit test stubs"""def setUp(self):pass@@ -29,25 +29,25 @@ class TestToolsHumanResponse(unittest.TestCase):passdef make_instance(self, include_optional):- """Test ToolsHumanResponse+ """Test ToolsLogOutputinclude_option is a boolean, when False only requiredparams are included, when True both required andoptional params are included """- # uncomment below to create an instance of `ToolsHumanResponse`+ # uncomment below to create an instance of `ToolsLogOutput`"""- model = playground_client.models.tools_human_response.ToolsHumanResponse() # noqa: E501+ model = playground_client.models.tools_log_output.ToolsLogOutput() # noqa: E501if include_optional :- return ToolsHumanResponse(+ return ToolsLogOutput(response = '')else :- return ToolsHumanResponse(+ return ToolsLogOutput(response = '',)"""- def testToolsHumanResponse(self):- """Test ToolsHumanResponse"""+ def testToolsLogOutput(self):+ """Test ToolsLogOutput"""# inst_req_only = self.make_instance(include_optional=False)# inst_req_and_optional = self.make_instance(include_optional=True)diff --git a/api-service/playground_client_README.md b/api-service/playground_client_README.mdindex 9b5bd20ca..440db2a36 100644--- a/api-service/playground_client_README.md+++ b/api-service/playground_client_README.md@@ -78,7 +78,7 @@ Class | Method | HTTP request | Description*DefaultApi* | [**read_filesystem_file**](playground_client/docs/DefaultApi.md#read_filesystem_file) | **GET** /sessions/{sessionID}/filesystem/file |*DefaultApi* | [**start_process**](playground_client/docs/DefaultApi.md#start_process) | **POST** /sessions/{sessionID}/processes |*DefaultApi* | [**stop_process**](playground_client/docs/DefaultApi.md#stop_process) | **DELETE** /sessions/{sessionID}/processes/{processID} |-*DefaultApi* | [**wait_for_human_response**](playground_client/docs/DefaultApi.md#wait_for_human_response) | **GET** /tools/humanResponse |+*DefaultApi* | [**wait_for_log_output**](playground_client/docs/DefaultApi.md#wait_for_log_output) | **GET** /tools/logOutput |*DefaultApi* | [**write_filesystem_file**](playground_client/docs/DefaultApi.md#write_filesystem_file) | **PUT** /sessions/{sessionID}/filesystem/file |*DefaultApi* | [**write_process_stdin**](playground_client/docs/DefaultApi.md#write_process_stdin) | **POST** /sessions/{sessionID}/processes/{processID}/stdin |@@ -103,7 +103,7 @@ Class | Method | HTTP request | Description- [ReadFilesystemFileResponse](playground_client/docs/ReadFilesystemFileResponse.md)- [SessionResponse](playground_client/docs/SessionResponse.md)- [StartProcessParams](playground_client/docs/StartProcessParams.md)- - [ToolsHumanResponse](playground_client/docs/ToolsHumanResponse.md)+ - [ToolsLogOutput](playground_client/docs/ToolsLogOutput.md)- [WriteFilesystemFileRequest](playground_client/docs/WriteFilesystemFileRequest.md)- [WriteProcessStdinRequest](playground_client/docs/WriteProcessStdinRequest.md)diff --git a/components/Editor/Sidebar/Logs/Tool/LetHumanChoose.tsx b/components/Editor/Sidebar/Logs/Tool/LetHumanChoose.tsxnew file mode 100644index 000000000..e9cfb7bcd--- /dev/null+++ b/components/Editor/Sidebar/Logs/Tool/LetHumanChoose.tsx@@ -0,0 +1,36 @@+import {+ HelpCircle,+} from 'lucide-react'++// import Text from 'components/Text'+// import Input from 'components/Input'+// import Button from 'components/Button'+import { ToolName, ToolLog } from 'db/types'++import Base from './Base'++export interface Props {+ log: ToolLog+}++function LetHumanChoose({+ log,+}: Props) {+ if (log.tool_name !== ToolName.LetHumanChoose) throw new Error(`'${log.tool_name}': This component supports only logs for '${ToolName.LetHumanChoose}' tool`)++ const body = (+ <div>+ {log.tool_input.trim()}+ </div>+ )++ return (+ <Base+ log={log}+ icon={<HelpCircle size="16px" />}+ body={body}+ />+ )+}++export default LetHumanChoose\ No newline at end of filediff --git a/components/Editor/Sidebar/Logs/Tool/index.tsx b/components/Editor/Sidebar/Logs/Tool/index.tsxindex c6f75d4ef..bb40f9fd3 100644--- a/components/Editor/Sidebar/Logs/Tool/index.tsx+++ b/components/Editor/Sidebar/Logs/Tool/index.tsx@@ -5,6 +5,7 @@ import Curl from './Curl'import InstallNPMDeps from './InstallNPMDeps'import WriteCode from './WriteCode'import RunSavedCode from './RunSavedCode'+import LetHumanChoose from './LetHumanChoose'export interface Props {log: ToolLog@@ -26,6 +27,8 @@ function Tool({return <RunSavedCode log={log} />case ToolName.AskHuman:return <AskHuman log={log} onAnswer={onAnswer} />+ case ToolName.LetHumanChoose:+ return <LetHumanChoose log={log} />default:return <div>Cannot render frontend component - unknown tol {log.tool_name}</div>}diff --git a/components/Editor/Sidebar/Logs/index.tsx b/components/Editor/Sidebar/Logs/index.tsxindex 8e58284ea..b1d27c181 100644--- a/components/Editor/Sidebar/Logs/index.tsx+++ b/components/Editor/Sidebar/Logs/index.tsx@@ -47,14 +47,21 @@ function Logs({const saveAnswer = useCallback(async (logID: string, answer: string) => {+ console.log('BEFORE', { logID, answer })if (!deployment) return+ console.log('SAVE ANSWER', { logID, answer })+const logs = produce(deployment.logs as unknown as Log[], ls => {+ console.log('LOGS', { logs: ls, logID, })const log = ls.find(l => l.id === logID)+ console.log('FOUND LOG', { ...log })if (log && log.type === LogType.Tool && log.tool_name === ToolName.AskHuman) {+ console.log('ANSWER', { log, answer })log.tool_output = answer}})+ console.log('LOGS', logs)await client.from(deploymentsTable).update({ logs: logs as unknown as Json[] }).eq('id', deployment.id).single()}, [deployment, client])diff --git a/db/types.ts b/db/types.tsindex 572792dbf..d531d5f75 100644--- a/db/types.ts+++ b/db/types.ts@@ -8,6 +8,7 @@ export enum ToolName {InstallNPMDependencies = 'InstallNPMDependencies',WriteJavaScriptCode = 'WriteJavaScriptCode',RunSavedCode = 'RunSavedCode',+ LetHumanChoose = 'LetHumanChoose',Curl = 'Curl',}