Shelley/let 7218 editor should be compatible with typescript [LET-7218] (#9087)
* fix python icon not showing up * make typescript compatible for updating tools in typescript * Update flags.ts * display tools properly in navigation * add default json schema to newly created tools * add typescript to code editor * make editor typescript compatible * Update ToolsEditor.tsx * typescript ocmpatible editor * sandbox stuff * update breadcrumb icon * pass in source type to tool simulator * undo * Update tool-editor.cy.ts
This commit is contained in:
committed by
Caren Thomas
parent
e0d9238bb6
commit
5dc70e48eb
@@ -14,7 +14,7 @@ services:
|
||||
- ./.persist/pgdata-test:/var/lib/postgresql/data
|
||||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
ports:
|
||||
- "5432:5432"
|
||||
- '5432:5432'
|
||||
letta_server:
|
||||
image: letta/letta:latest
|
||||
hostname: letta
|
||||
@@ -25,8 +25,8 @@ services:
|
||||
depends_on:
|
||||
- letta_db
|
||||
ports:
|
||||
- "8083:8083"
|
||||
- "8283:8283"
|
||||
- '8083:8083'
|
||||
- '8283:8283'
|
||||
environment:
|
||||
- LETTA_PG_DB=${LETTA_PG_DB:-letta}
|
||||
- LETTA_PG_USER=${LETTA_PG_USER:-letta}
|
||||
|
||||
@@ -944,13 +944,28 @@ class ToolManager:
|
||||
# Track if we need to check name uniqueness (check is done inside session with lock)
|
||||
needs_name_conflict_check = new_name != current_tool.name
|
||||
|
||||
# NOTE: EXTREMELEY HACKY, we need to stop making assumptions about the source_code
|
||||
if "source_code" in update_data and f"def {new_name}" not in update_data.get("source_code", ""):
|
||||
raise LettaToolNameSchemaMismatchError(
|
||||
tool_name=new_name,
|
||||
json_schema_name=new_schema.get("name") if new_schema else None,
|
||||
source_code=update_data.get("source_code"),
|
||||
)
|
||||
# Definitive checker for source code type
|
||||
if "source_code" in update_data:
|
||||
source_code = update_data.get("source_code", "")
|
||||
source_type = update_data.get("source_type", current_tool.source_type)
|
||||
|
||||
# Check for function name based on source type
|
||||
if source_type == "typescript":
|
||||
# TypeScript: check for "function name" or "export function name"
|
||||
if f"function {new_name}" not in source_code:
|
||||
raise LettaToolNameSchemaMismatchError(
|
||||
tool_name=new_name,
|
||||
json_schema_name=new_schema.get("name") if new_schema else None,
|
||||
source_code=source_code,
|
||||
)
|
||||
else:
|
||||
# Python: check for "def name"
|
||||
if f"def {new_name}" not in source_code:
|
||||
raise LettaToolNameSchemaMismatchError(
|
||||
tool_name=new_name,
|
||||
json_schema_name=new_schema.get("name") if new_schema else None,
|
||||
source_code=source_code,
|
||||
)
|
||||
|
||||
# Create a preview of the updated tool by merging current tool with updates
|
||||
# This allows us to compute the hash before the database session
|
||||
|
||||
Reference in New Issue
Block a user