letta-client 0.1.226__py3-none-any.whl → 1.7.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- letta_client/__init__.py +91 -672
- letta_client/_base_client.py +2125 -0
- letta_client/_client.py +1136 -0
- letta_client/_compat.py +219 -0
- letta_client/_constants.py +14 -0
- letta_client/_exceptions.py +108 -0
- letta_client/_files.py +123 -0
- letta_client/_models.py +872 -0
- letta_client/_qs.py +150 -0
- letta_client/_resource.py +43 -0
- letta_client/_response.py +832 -0
- letta_client/_streaming.py +371 -0
- letta_client/_types.py +270 -0
- letta_client/_utils/__init__.py +64 -0
- letta_client/_utils/_compat.py +45 -0
- letta_client/_utils/_datetime_parse.py +136 -0
- letta_client/_utils/_logs.py +25 -0
- letta_client/_utils/_proxy.py +65 -0
- letta_client/_utils/_reflection.py +42 -0
- letta_client/_utils/_resources_proxy.py +24 -0
- letta_client/_utils/_streams.py +12 -0
- letta_client/_utils/_sync.py +58 -0
- letta_client/_utils/_transform.py +457 -0
- letta_client/_utils/_typing.py +156 -0
- letta_client/_utils/_utils.py +421 -0
- letta_client/_version.py +4 -0
- letta_client/lib/.keep +4 -0
- letta_client/pagination.py +280 -0
- letta_client/resources/__init__.py +215 -0
- letta_client/resources/access_tokens.py +396 -0
- letta_client/resources/agents/__init__.py +131 -0
- letta_client/resources/agents/agents.py +2148 -0
- letta_client/resources/agents/archives.py +260 -0
- letta_client/resources/agents/blocks.py +736 -0
- letta_client/resources/agents/files.py +541 -0
- letta_client/resources/agents/folders.py +422 -0
- letta_client/resources/agents/identities.py +260 -0
- letta_client/resources/agents/messages.py +1800 -0
- letta_client/resources/agents/passages.py +638 -0
- letta_client/resources/agents/tools.py +651 -0
- letta_client/resources/archives/__init__.py +33 -0
- letta_client/resources/archives/archives.py +650 -0
- letta_client/resources/archives/passages.py +309 -0
- letta_client/resources/blocks/__init__.py +33 -0
- letta_client/resources/blocks/agents.py +289 -0
- letta_client/resources/blocks/blocks.py +977 -0
- letta_client/resources/conversations/__init__.py +33 -0
- letta_client/resources/conversations/conversations.py +611 -0
- letta_client/resources/conversations/messages.py +650 -0
- letta_client/resources/folders/__init__.py +47 -0
- letta_client/resources/folders/agents.py +234 -0
- letta_client/resources/folders/files.py +581 -0
- letta_client/resources/folders/folders.py +734 -0
- letta_client/resources/mcp_servers/__init__.py +33 -0
- letta_client/resources/mcp_servers/mcp_servers.py +670 -0
- letta_client/resources/mcp_servers/tools.py +351 -0
- letta_client/resources/messages.py +455 -0
- letta_client/resources/models/__init__.py +33 -0
- letta_client/resources/models/embeddings.py +149 -0
- letta_client/resources/models/models.py +233 -0
- letta_client/resources/passages.py +259 -0
- letta_client/resources/runs/__init__.py +75 -0
- letta_client/resources/runs/messages.py +363 -0
- letta_client/resources/runs/runs.py +502 -0
- letta_client/resources/runs/steps.py +229 -0
- letta_client/resources/runs/trace.py +197 -0
- letta_client/resources/runs/usage.py +163 -0
- letta_client/resources/steps/__init__.py +75 -0
- letta_client/resources/steps/feedback.py +198 -0
- letta_client/resources/steps/messages.py +237 -0
- letta_client/resources/steps/metrics.py +167 -0
- letta_client/resources/steps/steps.py +505 -0
- letta_client/resources/steps/trace.py +169 -0
- letta_client/resources/tags.py +240 -0
- letta_client/resources/templates/__init__.py +33 -0
- letta_client/resources/templates/agents.py +229 -0
- letta_client/resources/templates/templates.py +540 -0
- letta_client/resources/tools.py +1721 -0
- letta_client/types/__init__.py +148 -530
- letta_client/types/access_token_create_params.py +32 -0
- letta_client/types/access_token_create_response.py +34 -0
- letta_client/types/access_token_delete_params.py +11 -0
- letta_client/types/access_token_list_params.py +23 -0
- letta_client/types/access_token_list_response.py +40 -0
- letta_client/types/agent_create_params.py +444 -0
- letta_client/types/agent_environment_variable.py +40 -63
- letta_client/types/agent_export_file_params.py +26 -0
- letta_client/types/agent_export_file_response.py +7 -0
- letta_client/types/agent_import_file_params.py +57 -0
- letta_client/types/agent_import_file_response.py +14 -0
- letta_client/types/agent_list_params.py +100 -0
- letta_client/types/agent_retrieve_params.py +37 -0
- letta_client/types/agent_state.py +651 -138
- letta_client/types/agent_type.py +14 -14
- letta_client/types/agent_update_params.py +386 -0
- letta_client/types/agents/__init__.py +76 -0
- letta_client/types/agents/approval_create_param.py +35 -0
- letta_client/types/agents/approval_request_message.py +57 -0
- letta_client/types/agents/approval_response_message.py +61 -0
- letta_client/types/agents/approval_return.py +22 -0
- letta_client/types/agents/approval_return_param.py +22 -0
- letta_client/types/agents/assistant_message.py +48 -0
- letta_client/types/agents/block.py +68 -0
- letta_client/types/agents/block_list_params.py +34 -0
- letta_client/types/agents/block_update_params.py +63 -0
- letta_client/types/agents/event_message.py +40 -0
- letta_client/types/agents/file_close_all_response.py +8 -0
- letta_client/types/agents/file_list_params.py +40 -0
- letta_client/types/agents/file_list_response.py +42 -0
- letta_client/types/agents/file_open_response.py +8 -0
- letta_client/types/agents/folder_list_params.py +34 -0
- letta_client/types/agents/folder_list_response.py +49 -0
- letta_client/types/agents/hidden_reasoning_message.py +49 -0
- letta_client/types/agents/image_content.py +67 -0
- letta_client/types/agents/image_content_param.py +64 -0
- letta_client/types/agents/internal_message.py +271 -0
- letta_client/types/agents/job_status.py +7 -0
- letta_client/types/agents/job_type.py +7 -0
- letta_client/types/agents/letta_assistant_message_content_union.py +19 -0
- letta_client/types/agents/letta_response.py +76 -0
- letta_client/types/agents/letta_streaming_response.py +155 -0
- letta_client/types/agents/letta_user_message_content_union.py +14 -0
- letta_client/types/agents/message.py +36 -0
- letta_client/types/agents/message_cancel_params.py +15 -0
- letta_client/types/agents/message_cancel_response.py +8 -0
- letta_client/types/agents/message_compact_params.py +145 -0
- letta_client/types/agents/message_compact_response.py +13 -0
- letta_client/types/agents/message_create_async_params.py +145 -0
- letta_client/types/agents/message_create_params.py +181 -0
- letta_client/types/agents/message_list_params.py +55 -0
- letta_client/types/agents/message_reset_params.py +12 -0
- letta_client/types/agents/message_role.py +7 -0
- letta_client/types/agents/message_stream_params.py +166 -0
- letta_client/types/agents/message_type.py +17 -0
- letta_client/types/agents/omitted_reasoning_content.py +20 -0
- letta_client/types/agents/omitted_reasoning_content_param.py +20 -0
- letta_client/types/agents/passage_create_params.py +23 -0
- letta_client/types/agents/passage_create_response.py +10 -0
- letta_client/types/agents/passage_list_params.py +28 -0
- letta_client/types/agents/passage_list_response.py +10 -0
- letta_client/types/agents/passage_search_params.py +35 -0
- letta_client/types/agents/passage_search_response.py +29 -0
- letta_client/types/agents/reasoning_content.py +27 -0
- letta_client/types/agents/reasoning_content_param.py +27 -0
- letta_client/types/agents/reasoning_message.py +50 -0
- letta_client/types/agents/redacted_reasoning_content.py +18 -0
- letta_client/types/agents/redacted_reasoning_content_param.py +17 -0
- letta_client/types/agents/run.py +91 -0
- letta_client/types/agents/summary_message.py +38 -0
- letta_client/types/agents/system_message.py +46 -0
- letta_client/types/agents/text_content.py +19 -0
- letta_client/types/agents/text_content_param.py +19 -0
- letta_client/types/agents/tool_call.py +13 -0
- letta_client/types/agents/tool_call_content.py +28 -0
- letta_client/types/agents/tool_call_content_param.py +28 -0
- letta_client/types/agents/tool_call_delta.py +15 -0
- letta_client/types/agents/tool_call_message.py +52 -0
- letta_client/types/agents/tool_execution_result.py +33 -0
- letta_client/types/agents/tool_list_params.py +34 -0
- letta_client/types/agents/tool_return.py +29 -0
- letta_client/types/agents/tool_return_content.py +22 -0
- letta_client/types/agents/tool_return_content_param.py +21 -0
- letta_client/types/agents/tool_return_param.py +30 -0
- letta_client/types/agents/tool_run_params.py +16 -0
- letta_client/types/agents/tool_update_approval_params.py +21 -0
- letta_client/types/agents/user_message.py +50 -0
- letta_client/types/anthropic_model_settings.py +62 -0
- letta_client/types/anthropic_model_settings_param.py +59 -0
- letta_client/types/archive.py +46 -0
- letta_client/types/archive_create_params.py +22 -0
- letta_client/types/archive_list_params.py +40 -0
- letta_client/types/archive_update_params.py +14 -0
- letta_client/types/archives/__init__.py +5 -0
- letta_client/types/archives/passage_create_params.py +21 -0
- letta_client/types/azure_model_settings.py +36 -0
- letta_client/types/azure_model_settings_param.py +33 -0
- letta_client/types/bedrock_model_settings.py +36 -0
- letta_client/types/bedrock_model_settings_param.py +33 -0
- letta_client/types/block_create_params.py +59 -0
- letta_client/types/block_list_params.py +102 -0
- letta_client/types/block_response.py +66 -0
- letta_client/types/block_update_params.py +60 -0
- letta_client/types/blocks/__init__.py +5 -0
- letta_client/types/blocks/agent_list_params.py +61 -0
- letta_client/types/child_tool_rule.py +37 -26
- letta_client/types/child_tool_rule_param.py +50 -0
- letta_client/types/conditional_tool_rule.py +19 -35
- letta_client/types/conditional_tool_rule_param.py +31 -0
- letta_client/types/continue_tool_rule.py +13 -23
- letta_client/types/continue_tool_rule_param.py +22 -0
- letta_client/types/conversation.py +42 -0
- letta_client/types/conversation_cancel_response.py +8 -0
- letta_client/types/conversation_create_params.py +25 -0
- letta_client/types/conversation_list_params.py +19 -0
- letta_client/types/conversation_list_response.py +10 -0
- letta_client/types/conversation_update_params.py +13 -0
- letta_client/types/conversations/__init__.py +7 -0
- letta_client/types/conversations/message_create_params.py +166 -0
- letta_client/types/conversations/message_list_params.py +43 -0
- letta_client/types/conversations/message_stream_params.py +28 -0
- letta_client/types/create_block_param.py +61 -0
- letta_client/types/create_sse_mcp_server_param.py +26 -0
- letta_client/types/create_stdio_mcp_server_param.py +25 -0
- letta_client/types/create_streamable_http_mcp_server_param.py +26 -0
- letta_client/types/deepseek_model_settings.py +36 -0
- letta_client/types/deepseek_model_settings_param.py +33 -0
- letta_client/types/embedding_config.py +47 -67
- letta_client/types/embedding_config_param.py +64 -0
- letta_client/types/embedding_model.py +81 -0
- letta_client/types/folder.py +28 -66
- letta_client/types/folder_create_params.py +33 -0
- letta_client/types/folder_list_params.py +37 -0
- letta_client/types/folder_update_params.py +27 -0
- letta_client/types/folders/__init__.py +12 -0
- letta_client/types/folders/agent_list_params.py +34 -0
- letta_client/types/folders/agent_list_response.py +8 -0
- letta_client/types/folders/file_list_params.py +37 -0
- letta_client/types/folders/file_list_response.py +70 -0
- letta_client/types/folders/file_retrieve_params.py +15 -0
- letta_client/types/folders/file_retrieve_response.py +70 -0
- letta_client/types/folders/file_upload_params.py +20 -0
- letta_client/types/folders/file_upload_response.py +70 -0
- letta_client/types/google_ai_model_settings.py +47 -0
- letta_client/types/google_ai_model_settings_param.py +44 -0
- letta_client/types/google_vertex_model_settings.py +47 -0
- letta_client/types/google_vertex_model_settings_param.py +44 -0
- letta_client/types/groq_model_settings.py +36 -0
- letta_client/types/groq_model_settings_param.py +33 -0
- letta_client/types/health_response.py +13 -0
- letta_client/types/init_tool_rule.py +24 -24
- letta_client/types/init_tool_rule_param.py +32 -0
- letta_client/types/json_object_response_format.py +9 -17
- letta_client/types/json_object_response_format_param.py +14 -0
- letta_client/types/json_schema_response_format.py +12 -21
- letta_client/types/json_schema_response_format_param.py +18 -0
- letta_client/types/letta_message_content_union_param.py +26 -0
- letta_client/types/llm_config.py +124 -75
- letta_client/types/llm_config_param.py +155 -0
- letta_client/types/max_count_per_step_tool_rule.py +16 -25
- letta_client/types/max_count_per_step_tool_rule_param.py +28 -0
- letta_client/types/mcp_server_create_params.py +23 -0
- letta_client/types/mcp_server_create_response.py +12 -0
- letta_client/types/mcp_server_list_response.py +14 -0
- letta_client/types/mcp_server_refresh_params.py +12 -0
- letta_client/types/mcp_server_retrieve_response.py +12 -0
- letta_client/types/mcp_server_update_params.py +23 -0
- letta_client/types/mcp_server_update_response.py +12 -0
- letta_client/types/mcp_servers/__init__.py +6 -0
- letta_client/types/mcp_servers/tool_list_response.py +10 -0
- letta_client/types/mcp_servers/tool_run_params.py +15 -0
- letta_client/types/message_create_param.py +38 -0
- letta_client/types/message_list_params.py +34 -0
- letta_client/types/message_list_response.py +10 -0
- letta_client/types/message_retrieve_response.py +10 -0
- letta_client/types/message_search_params.py +34 -0
- letta_client/types/message_search_response.py +124 -0
- letta_client/types/model.py +148 -0
- letta_client/types/model_list_params.py +19 -0
- letta_client/types/model_list_response.py +10 -0
- letta_client/types/models/__init__.py +5 -0
- letta_client/types/models/embedding_list_response.py +10 -0
- letta_client/types/npm_requirement.py +15 -0
- letta_client/types/npm_requirement_param.py +16 -0
- letta_client/types/openai_model_settings.py +51 -0
- letta_client/types/openai_model_settings_param.py +48 -0
- letta_client/types/parent_tool_rule.py +15 -27
- letta_client/types/parent_tool_rule_param.py +27 -0
- letta_client/types/passage.py +56 -101
- letta_client/types/passage_search_params.py +41 -0
- letta_client/types/passage_search_response.py +25 -0
- letta_client/types/pip_requirement.py +9 -21
- letta_client/types/pip_requirement_param.py +16 -0
- letta_client/types/provider_category.py +5 -3
- letta_client/types/provider_trace.py +43 -48
- letta_client/types/provider_type.py +25 -23
- letta_client/types/required_before_exit_tool_rule.py +13 -23
- letta_client/types/required_before_exit_tool_rule_param.py +22 -0
- letta_client/types/requires_approval_tool_rule.py +25 -0
- letta_client/types/requires_approval_tool_rule_param.py +25 -0
- letta_client/types/run_list_params.py +67 -0
- letta_client/types/runs/__init__.py +10 -0
- letta_client/types/runs/message_list_params.py +34 -0
- letta_client/types/runs/message_stream_params.py +28 -0
- letta_client/types/runs/step_list_params.py +28 -0
- letta_client/types/runs/trace_retrieve_params.py +12 -0
- letta_client/types/runs/trace_retrieve_response.py +8 -0
- letta_client/types/runs/usage_retrieve_response.py +31 -0
- letta_client/types/sse_mcp_server.py +32 -0
- letta_client/types/stdio_mcp_server.py +29 -0
- letta_client/types/step.py +71 -97
- letta_client/types/step_list_params.py +57 -0
- letta_client/types/steps/__init__.py +8 -0
- letta_client/types/steps/feedback_create_params.py +18 -0
- letta_client/types/steps/message_list_params.py +34 -0
- letta_client/types/steps/message_list_response.py +36 -0
- letta_client/types/steps/metric_retrieve_response.py +45 -0
- letta_client/types/stop_reason_type.py +17 -5
- letta_client/types/streamable_http_mcp_server.py +32 -0
- letta_client/types/tag_list_params.py +40 -0
- letta_client/types/tag_list_response.py +8 -0
- letta_client/types/template_create_params.py +46 -0
- letta_client/types/template_create_response.py +29 -0
- letta_client/types/template_delete_response.py +9 -0
- letta_client/types/template_update_params.py +25 -0
- letta_client/types/template_update_response.py +13 -0
- letta_client/types/templates/__init__.py +6 -0
- letta_client/types/templates/agent_create_params.py +50 -0
- letta_client/types/templates/agent_create_response.py +20 -0
- letta_client/types/terminal_tool_rule.py +13 -23
- letta_client/types/terminal_tool_rule_param.py +22 -0
- letta_client/types/text_response_format.py +9 -17
- letta_client/types/text_response_format_param.py +14 -0
- letta_client/types/together_model_settings.py +36 -0
- letta_client/types/together_model_settings_param.py +33 -0
- letta_client/types/tool.py +154 -81
- letta_client/types/tool_create_params.py +53 -0
- letta_client/types/tool_list_params.py +57 -0
- letta_client/types/tool_return_message.py +44 -31
- letta_client/types/tool_search_params.py +27 -0
- letta_client/types/tool_search_response.py +10 -0
- letta_client/types/tool_search_result.py +27 -0
- letta_client/types/tool_type.py +16 -17
- letta_client/types/tool_update_params.py +57 -0
- letta_client/types/tool_upsert_params.py +53 -0
- letta_client/types/update_sse_mcp_server_param.py +26 -0
- letta_client/types/update_stdio_mcp_server_param.py +25 -0
- letta_client/types/update_streamable_http_mcp_server_param.py +26 -0
- letta_client/types/vector_db_provider.py +7 -0
- letta_client/types/xai_model_settings.py +36 -0
- letta_client/types/xai_model_settings_param.py +33 -0
- letta_client-1.7.2.dist-info/METADATA +436 -0
- letta_client-1.7.2.dist-info/RECORD +335 -0
- {letta_client-0.1.226.dist-info → letta_client-1.7.2.dist-info}/WHEEL +1 -1
- letta_client-1.7.2.dist-info/licenses/LICENSE +201 -0
- letta_client/agents/__init__.py +0 -77
- letta_client/agents/blocks/__init__.py +0 -2
- letta_client/agents/blocks/client.py +0 -793
- letta_client/agents/client.py +0 -2371
- letta_client/agents/context/__init__.py +0 -2
- letta_client/agents/context/client.py +0 -149
- letta_client/agents/core_memory/__init__.py +0 -2
- letta_client/agents/core_memory/client.py +0 -147
- letta_client/agents/files/__init__.py +0 -2
- letta_client/agents/files/client.py +0 -430
- letta_client/agents/folders/__init__.py +0 -2
- letta_client/agents/folders/client.py +0 -412
- letta_client/agents/groups/__init__.py +0 -2
- letta_client/agents/groups/client.py +0 -169
- letta_client/agents/memory_variables/__init__.py +0 -5
- letta_client/agents/memory_variables/client.py +0 -152
- letta_client/agents/memory_variables/types/__init__.py +0 -5
- letta_client/agents/memory_variables/types/memory_variables_list_response.py +0 -19
- letta_client/agents/messages/__init__.py +0 -15
- letta_client/agents/messages/client.py +0 -1638
- letta_client/agents/messages/types/__init__.py +0 -13
- letta_client/agents/messages/types/letta_streaming_response.py +0 -22
- letta_client/agents/messages/types/messages_modify_request.py +0 -11
- letta_client/agents/messages/types/messages_modify_response.py +0 -20
- letta_client/agents/messages/types/messages_preview_raw_payload_request.py +0 -7
- letta_client/agents/passages/__init__.py +0 -2
- letta_client/agents/passages/client.py +0 -793
- letta_client/agents/sources/__init__.py +0 -2
- letta_client/agents/sources/client.py +0 -412
- letta_client/agents/templates/__init__.py +0 -5
- letta_client/agents/templates/client.py +0 -588
- letta_client/agents/templates/types/__init__.py +0 -7
- letta_client/agents/templates/types/templates_create_response.py +0 -22
- letta_client/agents/templates/types/templates_create_version_request_return_agent_state.py +0 -5
- letta_client/agents/templates/types/templates_migrate_response.py +0 -19
- letta_client/agents/tools/__init__.py +0 -2
- letta_client/agents/tools/client.py +0 -412
- letta_client/agents/types/__init__.py +0 -33
- letta_client/agents/types/agents_search_request_search_item.py +0 -16
- letta_client/agents/types/agents_search_request_search_item_field.py +0 -22
- letta_client/agents/types/agents_search_request_search_item_field_operator.py +0 -5
- letta_client/agents/types/agents_search_request_search_item_one.py +0 -22
- letta_client/agents/types/agents_search_request_search_item_one_operator.py +0 -5
- letta_client/agents/types/agents_search_request_search_item_three.py +0 -21
- letta_client/agents/types/agents_search_request_search_item_two.py +0 -21
- letta_client/agents/types/agents_search_request_search_item_zero.py +0 -20
- letta_client/agents/types/agents_search_request_sort_by.py +0 -5
- letta_client/agents/types/agents_search_response.py +0 -23
- letta_client/agents/types/create_agent_request_response_format.py +0 -8
- letta_client/agents/types/create_agent_request_tool_rules_item.py +0 -22
- letta_client/agents/types/update_agent_response_format.py +0 -8
- letta_client/agents/types/update_agent_tool_rules_item.py +0 -22
- letta_client/base_client.py +0 -232
- letta_client/batches/__init__.py +0 -2
- letta_client/batches/client.py +0 -587
- letta_client/blocks/__init__.py +0 -5
- letta_client/blocks/agents/__init__.py +0 -2
- letta_client/blocks/agents/client.py +0 -171
- letta_client/blocks/client.py +0 -1038
- letta_client/client.py +0 -661
- letta_client/client_side_access_tokens/__init__.py +0 -29
- letta_client/client_side_access_tokens/client.py +0 -524
- letta_client/client_side_access_tokens/types/__init__.py +0 -43
- letta_client/client_side_access_tokens/types/client_side_access_tokens_create_request_policy_item.py +0 -24
- letta_client/client_side_access_tokens/types/client_side_access_tokens_create_request_policy_item_access_item.py +0 -7
- letta_client/client_side_access_tokens/types/client_side_access_tokens_create_response.py +0 -25
- letta_client/client_side_access_tokens/types/client_side_access_tokens_create_response_policy.py +0 -23
- letta_client/client_side_access_tokens/types/client_side_access_tokens_create_response_policy_data_item.py +0 -24
- letta_client/client_side_access_tokens/types/client_side_access_tokens_create_response_policy_data_item_access_item.py +0 -7
- letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response.py +0 -25
- letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response_tokens_item.py +0 -27
- letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response_tokens_item_policy.py +0 -23
- letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response_tokens_item_policy_data_item.py +0 -24
- letta_client/client_side_access_tokens/types/client_side_access_tokens_list_client_side_access_tokens_response_tokens_item_policy_data_item_access_item.py +0 -7
- letta_client/core/__init__.py +0 -51
- letta_client/core/api_error.py +0 -15
- letta_client/core/client_wrapper.py +0 -77
- letta_client/core/datetime_utils.py +0 -28
- letta_client/core/file.py +0 -67
- letta_client/core/http_client.py +0 -499
- letta_client/core/jsonable_encoder.py +0 -101
- letta_client/core/pydantic_utilities.py +0 -296
- letta_client/core/query_encoder.py +0 -58
- letta_client/core/remove_none_from_dict.py +0 -11
- letta_client/core/request_options.py +0 -35
- letta_client/core/serialization.py +0 -272
- letta_client/core/unchecked_base_model.py +0 -305
- letta_client/embedding_models/__init__.py +0 -2
- letta_client/embedding_models/client.py +0 -136
- letta_client/environment.py +0 -8
- letta_client/errors/__init__.py +0 -17
- letta_client/errors/bad_request_error.py +0 -9
- letta_client/errors/conflict_error.py +0 -9
- letta_client/errors/internal_server_error.py +0 -9
- letta_client/errors/not_found_error.py +0 -9
- letta_client/errors/payment_required_error.py +0 -9
- letta_client/errors/unprocessable_entity_error.py +0 -9
- letta_client/folders/__init__.py +0 -5
- letta_client/folders/client.py +0 -1307
- letta_client/folders/files/__init__.py +0 -2
- letta_client/folders/files/client.py +0 -474
- letta_client/folders/passages/__init__.py +0 -2
- letta_client/folders/passages/client.py +0 -189
- letta_client/groups/__init__.py +0 -14
- letta_client/groups/client.py +0 -964
- letta_client/groups/messages/__init__.py +0 -5
- letta_client/groups/messages/client.py +0 -1015
- letta_client/groups/messages/types/__init__.py +0 -7
- letta_client/groups/messages/types/letta_streaming_response.py +0 -20
- letta_client/groups/messages/types/messages_modify_request.py +0 -11
- letta_client/groups/messages/types/messages_modify_response.py +0 -20
- letta_client/groups/types/__init__.py +0 -6
- letta_client/groups/types/group_create_manager_config.py +0 -12
- letta_client/groups/types/group_update_manager_config.py +0 -16
- letta_client/health/__init__.py +0 -2
- letta_client/health/client.py +0 -110
- letta_client/identities/__init__.py +0 -5
- letta_client/identities/client.py +0 -1201
- letta_client/identities/properties/__init__.py +0 -2
- letta_client/identities/properties/client.py +0 -183
- letta_client/jobs/__init__.py +0 -2
- letta_client/jobs/client.py +0 -749
- letta_client/messages/__init__.py +0 -2
- letta_client/messages/client.py +0 -213
- letta_client/models/__init__.py +0 -2
- letta_client/models/client.py +0 -174
- letta_client/projects/__init__.py +0 -5
- letta_client/projects/client.py +0 -150
- letta_client/projects/types/__init__.py +0 -6
- letta_client/projects/types/projects_list_response.py +0 -23
- letta_client/projects/types/projects_list_response_projects_item.py +0 -21
- letta_client/providers/__init__.py +0 -2
- letta_client/providers/client.py +0 -789
- letta_client/runs/__init__.py +0 -5
- letta_client/runs/client.py +0 -551
- letta_client/runs/messages/__init__.py +0 -2
- letta_client/runs/messages/client.py +0 -236
- letta_client/runs/steps/__init__.py +0 -2
- letta_client/runs/steps/client.py +0 -219
- letta_client/runs/usage/__init__.py +0 -2
- letta_client/runs/usage/client.py +0 -147
- letta_client/sources/__init__.py +0 -5
- letta_client/sources/client.py +0 -1462
- letta_client/sources/files/__init__.py +0 -2
- letta_client/sources/files/client.py +0 -474
- letta_client/sources/passages/__init__.py +0 -2
- letta_client/sources/passages/client.py +0 -189
- letta_client/steps/__init__.py +0 -6
- letta_client/steps/client.py +0 -408
- letta_client/steps/feedback/__init__.py +0 -2
- letta_client/steps/feedback/client.py +0 -168
- letta_client/steps/types/__init__.py +0 -5
- letta_client/steps/types/steps_list_request_feedback.py +0 -5
- letta_client/tags/__init__.py +0 -2
- letta_client/tags/client.py +0 -171
- letta_client/telemetry/__init__.py +0 -2
- letta_client/telemetry/client.py +0 -145
- letta_client/templates/__init__.py +0 -18
- letta_client/templates/agents/__init__.py +0 -13
- letta_client/templates/agents/client.py +0 -256
- letta_client/templates/agents/types/__init__.py +0 -11
- letta_client/templates/agents/types/agents_create_request_initial_message_sequence_item.py +0 -26
- letta_client/templates/agents/types/agents_create_request_initial_message_sequence_item_role.py +0 -7
- letta_client/templates/agents/types/agents_create_response.py +0 -20
- letta_client/templates/client.py +0 -162
- letta_client/templates/types/__init__.py +0 -6
- letta_client/templates/types/templates_list_response.py +0 -23
- letta_client/templates/types/templates_list_response_templates_item.py +0 -20
- letta_client/tools/__init__.py +0 -27
- letta_client/tools/client.py +0 -3063
- letta_client/tools/types/__init__.py +0 -25
- letta_client/tools/types/add_mcp_server_request.py +0 -8
- letta_client/tools/types/add_mcp_server_response_item.py +0 -8
- letta_client/tools/types/connect_mcp_server_request.py +0 -8
- letta_client/tools/types/connect_mcp_server_response_event.py +0 -8
- letta_client/tools/types/delete_mcp_server_response_item.py +0 -8
- letta_client/tools/types/list_mcp_servers_response_value.py +0 -8
- letta_client/tools/types/streaming_response.py +0 -23
- letta_client/tools/types/test_mcp_server_request.py +0 -8
- letta_client/tools/types/update_mcp_server_request.py +0 -8
- letta_client/tools/types/update_mcp_server_response.py +0 -8
- letta_client/types/action_model.py +0 -38
- letta_client/types/action_parameters_model.py +0 -27
- letta_client/types/action_response_model.py +0 -27
- letta_client/types/agent_schema.py +0 -49
- letta_client/types/agent_schema_tool_rules_item.py +0 -11
- letta_client/types/agent_state_response_format.py +0 -8
- letta_client/types/agent_state_tool_rules_item.py +0 -22
- letta_client/types/app_auth_scheme.py +0 -34
- letta_client/types/app_auth_scheme_auth_mode.py +0 -19
- letta_client/types/app_model.py +0 -44
- letta_client/types/assistant_message.py +0 -42
- letta_client/types/assistant_message_content.py +0 -6
- letta_client/types/audio.py +0 -19
- letta_client/types/auth_request.py +0 -22
- letta_client/types/auth_response.py +0 -29
- letta_client/types/auth_scheme_field.py +0 -30
- letta_client/types/bad_request_error_body.py +0 -19
- letta_client/types/base_64_image.py +0 -33
- letta_client/types/base_tool_rule_schema.py +0 -20
- letta_client/types/batch_job.py +0 -81
- letta_client/types/block.py +0 -97
- letta_client/types/block_update.py +0 -71
- letta_client/types/chat_completion_assistant_message_param.py +0 -29
- letta_client/types/chat_completion_assistant_message_param_content.py +0 -8
- letta_client/types/chat_completion_assistant_message_param_content_item.py +0 -9
- letta_client/types/chat_completion_audio_param.py +0 -22
- letta_client/types/chat_completion_audio_param_format.py +0 -5
- letta_client/types/chat_completion_audio_param_voice.py +0 -18
- letta_client/types/chat_completion_content_part_image_param.py +0 -21
- letta_client/types/chat_completion_content_part_input_audio_param.py +0 -21
- letta_client/types/chat_completion_content_part_refusal_param.py +0 -20
- letta_client/types/chat_completion_content_part_text_param.py +0 -20
- letta_client/types/chat_completion_developer_message_param.py +0 -22
- letta_client/types/chat_completion_developer_message_param_content.py +0 -6
- letta_client/types/chat_completion_function_call_option_param.py +0 -19
- letta_client/types/chat_completion_function_message_param.py +0 -21
- letta_client/types/chat_completion_message_tool_call.py +0 -22
- letta_client/types/chat_completion_message_tool_call_param.py +0 -24
- letta_client/types/chat_completion_named_tool_choice_param.py +0 -23
- letta_client/types/chat_completion_prediction_content_param.py +0 -21
- letta_client/types/chat_completion_prediction_content_param_content.py +0 -6
- letta_client/types/chat_completion_stream_options_param.py +0 -19
- letta_client/types/chat_completion_system_message_param.py +0 -22
- letta_client/types/chat_completion_system_message_param_content.py +0 -6
- letta_client/types/chat_completion_tool_message_param.py +0 -22
- letta_client/types/chat_completion_tool_message_param_content.py +0 -6
- letta_client/types/chat_completion_tool_param.py +0 -21
- letta_client/types/chat_completion_user_message_param.py +0 -22
- letta_client/types/chat_completion_user_message_param_content.py +0 -6
- letta_client/types/chat_completion_user_message_param_content_item.py +0 -14
- letta_client/types/child_tool_rule_schema.py +0 -21
- letta_client/types/code_input.py +0 -22
- letta_client/types/completion_create_params_non_streaming.py +0 -64
- letta_client/types/completion_create_params_non_streaming_function_call.py +0 -8
- letta_client/types/completion_create_params_non_streaming_messages_item.py +0 -18
- letta_client/types/completion_create_params_non_streaming_modalities_item.py +0 -5
- letta_client/types/completion_create_params_non_streaming_model.py +0 -62
- letta_client/types/completion_create_params_non_streaming_reasoning_effort.py +0 -5
- letta_client/types/completion_create_params_non_streaming_response_format.py +0 -10
- letta_client/types/completion_create_params_non_streaming_service_tier.py +0 -7
- letta_client/types/completion_create_params_non_streaming_stop.py +0 -5
- letta_client/types/completion_create_params_non_streaming_tool_choice.py +0 -8
- letta_client/types/completion_create_params_streaming.py +0 -64
- letta_client/types/completion_create_params_streaming_function_call.py +0 -8
- letta_client/types/completion_create_params_streaming_messages_item.py +0 -18
- letta_client/types/completion_create_params_streaming_modalities_item.py +0 -5
- letta_client/types/completion_create_params_streaming_model.py +0 -62
- letta_client/types/completion_create_params_streaming_reasoning_effort.py +0 -5
- letta_client/types/completion_create_params_streaming_response_format.py +0 -10
- letta_client/types/completion_create_params_streaming_service_tier.py +0 -7
- letta_client/types/completion_create_params_streaming_stop.py +0 -5
- letta_client/types/completion_create_params_streaming_tool_choice.py +0 -8
- letta_client/types/components_schemas_text_content.py +0 -5
- letta_client/types/conditional_tool_rule_schema.py +0 -23
- letta_client/types/conflict_error_body.py +0 -21
- letta_client/types/context_window_overview.py +0 -108
- letta_client/types/core_memory_block_schema.py +0 -31
- letta_client/types/create_block.py +0 -67
- letta_client/types/duplicate_file_handling.py +0 -5
- letta_client/types/dynamic_manager.py +0 -33
- letta_client/types/dynamic_manager_update.py +0 -33
- letta_client/types/e_2_b_sandbox_config.py +0 -32
- letta_client/types/embedding_config_embedding_endpoint_type.py +0 -29
- letta_client/types/feedback_type.py +0 -5
- letta_client/types/file.py +0 -21
- letta_client/types/file_block.py +0 -103
- letta_client/types/file_file.py +0 -21
- letta_client/types/file_metadata.py +0 -108
- letta_client/types/file_processing_status.py +0 -5
- letta_client/types/file_stats.py +0 -36
- letta_client/types/function_call.py +0 -20
- letta_client/types/function_definition_input.py +0 -22
- letta_client/types/function_definition_output.py +0 -22
- letta_client/types/function_output.py +0 -20
- letta_client/types/function_tool.py +0 -21
- letta_client/types/generate_tool_input.py +0 -42
- letta_client/types/generate_tool_output.py +0 -33
- letta_client/types/group.py +0 -88
- letta_client/types/health.py +0 -24
- letta_client/types/hidden_reasoning_message.py +0 -43
- letta_client/types/hidden_reasoning_message_state.py +0 -5
- letta_client/types/http_validation_error.py +0 -20
- letta_client/types/identity.py +0 -59
- letta_client/types/identity_property.py +0 -38
- letta_client/types/identity_property_type.py +0 -5
- letta_client/types/identity_property_value.py +0 -5
- letta_client/types/identity_type.py +0 -5
- letta_client/types/image_content.py +0 -24
- letta_client/types/image_content_source.py +0 -8
- letta_client/types/image_url.py +0 -21
- letta_client/types/image_url_detail.py +0 -5
- letta_client/types/input_audio.py +0 -21
- letta_client/types/input_audio_format.py +0 -5
- letta_client/types/internal_server_error_body.py +0 -19
- letta_client/types/job.py +0 -96
- letta_client/types/job_status.py +0 -7
- letta_client/types/job_type.py +0 -5
- letta_client/types/json_schema.py +0 -26
- letta_client/types/letta_batch_messages.py +0 -20
- letta_client/types/letta_batch_request.py +0 -59
- letta_client/types/letta_image.py +0 -38
- letta_client/types/letta_message_content_union.py +0 -13
- letta_client/types/letta_message_union.py +0 -20
- letta_client/types/letta_request.py +0 -54
- letta_client/types/letta_request_config.py +0 -38
- letta_client/types/letta_response.py +0 -40
- letta_client/types/letta_stop_reason.py +0 -32
- letta_client/types/letta_streaming_request.py +0 -59
- letta_client/types/letta_usage_statistics.py +0 -59
- letta_client/types/letta_user_message_content_union.py +0 -7
- letta_client/types/llm_config_model_endpoint_type.py +0 -31
- letta_client/types/llm_config_reasoning_effort.py +0 -5
- letta_client/types/local_sandbox_config.py +0 -38
- letta_client/types/manager_type.py +0 -7
- letta_client/types/max_count_per_step_tool_rule_schema.py +0 -21
- letta_client/types/mcp_server_type.py +0 -5
- letta_client/types/mcp_tool.py +0 -38
- letta_client/types/memory.py +0 -38
- letta_client/types/message.py +0 -139
- letta_client/types/message_content_item.py +0 -20
- letta_client/types/message_create.py +0 -58
- letta_client/types/message_create_content.py +0 -6
- letta_client/types/message_create_role.py +0 -5
- letta_client/types/message_role.py +0 -5
- letta_client/types/message_schema.py +0 -29
- letta_client/types/message_type.py +0 -16
- letta_client/types/not_found_error_body.py +0 -19
- letta_client/types/not_found_error_body_message.py +0 -11
- letta_client/types/omitted_reasoning_content.py +0 -19
- letta_client/types/openai_types_chat_chat_completion_message_tool_call_param_function.py +0 -20
- letta_client/types/openai_types_chat_chat_completion_named_tool_choice_param_function.py +0 -19
- letta_client/types/openai_types_chat_completion_create_params_function.py +0 -21
- letta_client/types/organization.py +0 -38
- letta_client/types/organization_create.py +0 -27
- letta_client/types/organization_sources_stats.py +0 -42
- letta_client/types/organization_update.py +0 -27
- letta_client/types/parameter_properties.py +0 -20
- letta_client/types/parameters_schema.py +0 -22
- letta_client/types/payment_required_error_body.py +0 -20
- letta_client/types/provider.py +0 -65
- letta_client/types/provider_check.py +0 -38
- letta_client/types/reasoning_content.py +0 -33
- letta_client/types/reasoning_message.py +0 -44
- letta_client/types/reasoning_message_source.py +0 -5
- letta_client/types/redacted_reasoning_content.py +0 -23
- letta_client/types/response_format_json_object.py +0 -19
- letta_client/types/response_format_json_schema.py +0 -21
- letta_client/types/response_format_text.py +0 -19
- letta_client/types/round_robin_manager.py +0 -23
- letta_client/types/round_robin_manager_update.py +0 -23
- letta_client/types/run.py +0 -99
- letta_client/types/sandbox_config.py +0 -54
- letta_client/types/sandbox_config_create.py +0 -23
- letta_client/types/sandbox_config_create_config.py +0 -7
- letta_client/types/sandbox_config_update.py +0 -27
- letta_client/types/sandbox_config_update_config.py +0 -7
- letta_client/types/sandbox_environment_variable.py +0 -63
- letta_client/types/sandbox_environment_variable_create.py +0 -32
- letta_client/types/sandbox_environment_variable_update.py +0 -32
- letta_client/types/sandbox_type.py +0 -5
- letta_client/types/sleeptime_manager.py +0 -28
- letta_client/types/sleeptime_manager_update.py +0 -28
- letta_client/types/source.py +0 -81
- letta_client/types/source_create.py +0 -57
- letta_client/types/source_stats.py +0 -47
- letta_client/types/source_update.py +0 -47
- letta_client/types/sse_server_config.py +0 -55
- letta_client/types/stdio_server_config.py +0 -39
- letta_client/types/step_feedback.py +0 -5
- letta_client/types/streamable_http_server_config.py +0 -55
- letta_client/types/supervisor_manager.py +0 -23
- letta_client/types/supervisor_manager_update.py +0 -23
- letta_client/types/system_message.py +0 -41
- letta_client/types/tag_schema.py +0 -19
- letta_client/types/text_content.py +0 -23
- letta_client/types/tool_annotations.py +0 -36
- letta_client/types/tool_call.py +0 -21
- letta_client/types/tool_call_content.py +0 -33
- letta_client/types/tool_call_delta.py +0 -21
- letta_client/types/tool_call_message.py +0 -39
- letta_client/types/tool_call_message_tool_call.py +0 -7
- letta_client/types/tool_create.py +0 -58
- letta_client/types/tool_env_var_schema.py +0 -23
- letta_client/types/tool_json_schema.py +0 -24
- letta_client/types/tool_return.py +0 -33
- letta_client/types/tool_return_content.py +0 -33
- letta_client/types/tool_return_message_status.py +0 -5
- letta_client/types/tool_return_status.py +0 -5
- letta_client/types/tool_schema.py +0 -35
- letta_client/types/update_assistant_message.py +0 -24
- letta_client/types/update_assistant_message_content.py +0 -6
- letta_client/types/update_reasoning_message.py +0 -20
- letta_client/types/update_ssemcp_server.py +0 -41
- letta_client/types/update_stdio_mcp_server.py +0 -32
- letta_client/types/update_streamable_httpmcp_server.py +0 -46
- letta_client/types/update_system_message.py +0 -23
- letta_client/types/update_user_message.py +0 -24
- letta_client/types/update_user_message_content.py +0 -6
- letta_client/types/url_image.py +0 -23
- letta_client/types/usage_statistics.py +0 -25
- letta_client/types/usage_statistics_completion_token_details.py +0 -19
- letta_client/types/usage_statistics_prompt_token_details.py +0 -19
- letta_client/types/user.py +0 -52
- letta_client/types/user_create.py +0 -22
- letta_client/types/user_message.py +0 -42
- letta_client/types/user_message_content.py +0 -6
- letta_client/types/user_update.py +0 -27
- letta_client/types/validation_error.py +0 -22
- letta_client/types/validation_error_loc_item.py +0 -5
- letta_client/types/voice_sleeptime_manager.py +0 -33
- letta_client/types/voice_sleeptime_manager_update.py +0 -33
- letta_client/types/web_search_options.py +0 -22
- letta_client/types/web_search_options_search_context_size.py +0 -5
- letta_client/types/web_search_options_user_location.py +0 -21
- letta_client/types/web_search_options_user_location_approximate.py +0 -22
- letta_client/version.py +0 -3
- letta_client/voice/__init__.py +0 -2
- letta_client/voice/client.py +0 -177
- letta_client-0.1.226.dist-info/METADATA +0 -190
- letta_client-0.1.226.dist-info/RECORD +0 -452
|
@@ -0,0 +1,1721 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
import inspect
|
|
7
|
+
from typing import Dict, Iterable, Optional
|
|
8
|
+
from textwrap import dedent
|
|
9
|
+
from typing_extensions import Literal
|
|
10
|
+
|
|
11
|
+
import httpx
|
|
12
|
+
from pydantic import BaseModel
|
|
13
|
+
|
|
14
|
+
from ..types import tool_list_params, tool_create_params, tool_search_params, tool_update_params, tool_upsert_params
|
|
15
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
|
|
16
|
+
from .._utils import maybe_transform, async_maybe_transform
|
|
17
|
+
from .._compat import cached_property
|
|
18
|
+
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
19
|
+
from .._response import (
|
|
20
|
+
to_raw_response_wrapper,
|
|
21
|
+
to_streamed_response_wrapper,
|
|
22
|
+
async_to_raw_response_wrapper,
|
|
23
|
+
async_to_streamed_response_wrapper,
|
|
24
|
+
)
|
|
25
|
+
from ..pagination import SyncArrayPage, AsyncArrayPage
|
|
26
|
+
from ..types.tool import Tool, BaseTool
|
|
27
|
+
from .._base_client import AsyncPaginator, make_request_options
|
|
28
|
+
from ..types.tool_search_response import ToolSearchResponse
|
|
29
|
+
from ..types.npm_requirement_param import NpmRequirementParam
|
|
30
|
+
from ..types.pip_requirement_param import PipRequirementParam
|
|
31
|
+
|
|
32
|
+
__all__ = ["ToolsResource", "AsyncToolsResource"]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ToolsResource(SyncAPIResource):
|
|
36
|
+
@cached_property
|
|
37
|
+
def with_raw_response(self) -> ToolsResourceWithRawResponse:
|
|
38
|
+
"""
|
|
39
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
40
|
+
the raw response object instead of the parsed content.
|
|
41
|
+
|
|
42
|
+
For more information, see https://www.github.com/letta-ai/letta-python#accessing-raw-response-data-eg-headers
|
|
43
|
+
"""
|
|
44
|
+
return ToolsResourceWithRawResponse(self)
|
|
45
|
+
|
|
46
|
+
@cached_property
|
|
47
|
+
def with_streaming_response(self) -> ToolsResourceWithStreamingResponse:
|
|
48
|
+
"""
|
|
49
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
50
|
+
|
|
51
|
+
For more information, see https://www.github.com/letta-ai/letta-python#with_streaming_response
|
|
52
|
+
"""
|
|
53
|
+
return ToolsResourceWithStreamingResponse(self)
|
|
54
|
+
|
|
55
|
+
def create(
|
|
56
|
+
self,
|
|
57
|
+
*,
|
|
58
|
+
source_code: str,
|
|
59
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
60
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
61
|
+
description: Optional[str] | Omit = omit,
|
|
62
|
+
enable_parallel_execution: Optional[bool] | Omit = omit,
|
|
63
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
64
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
65
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
66
|
+
return_char_limit: int | Omit = omit,
|
|
67
|
+
source_type: str | Omit = omit,
|
|
68
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
69
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
70
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
71
|
+
extra_headers: Headers | None = None,
|
|
72
|
+
extra_query: Query | None = None,
|
|
73
|
+
extra_body: Body | None = None,
|
|
74
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
75
|
+
) -> Tool:
|
|
76
|
+
"""
|
|
77
|
+
Create a new tool
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
source_code: The source code of the function.
|
|
81
|
+
|
|
82
|
+
args_json_schema: The args JSON schema of the function.
|
|
83
|
+
|
|
84
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
85
|
+
|
|
86
|
+
description: The description of the tool.
|
|
87
|
+
|
|
88
|
+
enable_parallel_execution: If set to True, then this tool will potentially be executed concurrently with
|
|
89
|
+
other tools. Default False.
|
|
90
|
+
|
|
91
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
92
|
+
provided)
|
|
93
|
+
|
|
94
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
95
|
+
|
|
96
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
97
|
+
|
|
98
|
+
return_char_limit: The maximum number of characters in the response.
|
|
99
|
+
|
|
100
|
+
source_type: The source type of the function.
|
|
101
|
+
|
|
102
|
+
tags: Metadata tags.
|
|
103
|
+
|
|
104
|
+
extra_headers: Send extra headers
|
|
105
|
+
|
|
106
|
+
extra_query: Add additional query parameters to the request
|
|
107
|
+
|
|
108
|
+
extra_body: Add additional JSON properties to the request
|
|
109
|
+
|
|
110
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
111
|
+
"""
|
|
112
|
+
return self._post(
|
|
113
|
+
"/v1/tools/",
|
|
114
|
+
body=maybe_transform(
|
|
115
|
+
{
|
|
116
|
+
"source_code": source_code,
|
|
117
|
+
"args_json_schema": args_json_schema,
|
|
118
|
+
"default_requires_approval": default_requires_approval,
|
|
119
|
+
"description": description,
|
|
120
|
+
"enable_parallel_execution": enable_parallel_execution,
|
|
121
|
+
"json_schema": json_schema,
|
|
122
|
+
"npm_requirements": npm_requirements,
|
|
123
|
+
"pip_requirements": pip_requirements,
|
|
124
|
+
"return_char_limit": return_char_limit,
|
|
125
|
+
"source_type": source_type,
|
|
126
|
+
"tags": tags,
|
|
127
|
+
},
|
|
128
|
+
tool_create_params.ToolCreateParams,
|
|
129
|
+
),
|
|
130
|
+
options=make_request_options(
|
|
131
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
132
|
+
),
|
|
133
|
+
cast_to=Tool,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
def retrieve(
|
|
137
|
+
self,
|
|
138
|
+
tool_id: str,
|
|
139
|
+
*,
|
|
140
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
141
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
142
|
+
extra_headers: Headers | None = None,
|
|
143
|
+
extra_query: Query | None = None,
|
|
144
|
+
extra_body: Body | None = None,
|
|
145
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
146
|
+
) -> Tool:
|
|
147
|
+
"""
|
|
148
|
+
Get a tool by ID
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
tool_id: The ID of the tool in the format 'tool-<uuid4>'
|
|
152
|
+
|
|
153
|
+
extra_headers: Send extra headers
|
|
154
|
+
|
|
155
|
+
extra_query: Add additional query parameters to the request
|
|
156
|
+
|
|
157
|
+
extra_body: Add additional JSON properties to the request
|
|
158
|
+
|
|
159
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
160
|
+
"""
|
|
161
|
+
if not tool_id:
|
|
162
|
+
raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}")
|
|
163
|
+
return self._get(
|
|
164
|
+
f"/v1/tools/{tool_id}",
|
|
165
|
+
options=make_request_options(
|
|
166
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
167
|
+
),
|
|
168
|
+
cast_to=Tool,
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
def update(
|
|
172
|
+
self,
|
|
173
|
+
tool_id: str,
|
|
174
|
+
*,
|
|
175
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
176
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
177
|
+
description: Optional[str] | Omit = omit,
|
|
178
|
+
enable_parallel_execution: Optional[bool] | Omit = omit,
|
|
179
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
180
|
+
metadata: Optional[Dict[str, object]] | Omit = omit,
|
|
181
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
182
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
183
|
+
return_char_limit: Optional[int] | Omit = omit,
|
|
184
|
+
source_code: Optional[str] | Omit = omit,
|
|
185
|
+
source_type: Optional[str] | Omit = omit,
|
|
186
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
187
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
188
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
189
|
+
extra_headers: Headers | None = None,
|
|
190
|
+
extra_query: Query | None = None,
|
|
191
|
+
extra_body: Body | None = None,
|
|
192
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
193
|
+
) -> Tool:
|
|
194
|
+
"""
|
|
195
|
+
Update an existing tool
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
tool_id: The ID of the tool in the format 'tool-<uuid4>'
|
|
199
|
+
|
|
200
|
+
args_json_schema: The args JSON schema of the function.
|
|
201
|
+
|
|
202
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
203
|
+
|
|
204
|
+
description: The description of the tool.
|
|
205
|
+
|
|
206
|
+
enable_parallel_execution: If set to True, then this tool will potentially be executed concurrently with
|
|
207
|
+
other tools. Default False.
|
|
208
|
+
|
|
209
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
210
|
+
provided)
|
|
211
|
+
|
|
212
|
+
metadata: A dictionary of additional metadata for the tool.
|
|
213
|
+
|
|
214
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
215
|
+
|
|
216
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
217
|
+
|
|
218
|
+
return_char_limit: The maximum number of characters in the response.
|
|
219
|
+
|
|
220
|
+
source_code: The source code of the function.
|
|
221
|
+
|
|
222
|
+
source_type: The type of the source code.
|
|
223
|
+
|
|
224
|
+
tags: Metadata tags.
|
|
225
|
+
|
|
226
|
+
extra_headers: Send extra headers
|
|
227
|
+
|
|
228
|
+
extra_query: Add additional query parameters to the request
|
|
229
|
+
|
|
230
|
+
extra_body: Add additional JSON properties to the request
|
|
231
|
+
|
|
232
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
233
|
+
"""
|
|
234
|
+
if not tool_id:
|
|
235
|
+
raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}")
|
|
236
|
+
return self._patch(
|
|
237
|
+
f"/v1/tools/{tool_id}",
|
|
238
|
+
body=maybe_transform(
|
|
239
|
+
{
|
|
240
|
+
"args_json_schema": args_json_schema,
|
|
241
|
+
"default_requires_approval": default_requires_approval,
|
|
242
|
+
"description": description,
|
|
243
|
+
"enable_parallel_execution": enable_parallel_execution,
|
|
244
|
+
"json_schema": json_schema,
|
|
245
|
+
"metadata": metadata,
|
|
246
|
+
"npm_requirements": npm_requirements,
|
|
247
|
+
"pip_requirements": pip_requirements,
|
|
248
|
+
"return_char_limit": return_char_limit,
|
|
249
|
+
"source_code": source_code,
|
|
250
|
+
"source_type": source_type,
|
|
251
|
+
"tags": tags,
|
|
252
|
+
},
|
|
253
|
+
tool_update_params.ToolUpdateParams,
|
|
254
|
+
),
|
|
255
|
+
options=make_request_options(
|
|
256
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
257
|
+
),
|
|
258
|
+
cast_to=Tool,
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
def list(
|
|
262
|
+
self,
|
|
263
|
+
*,
|
|
264
|
+
after: Optional[str] | Omit = omit,
|
|
265
|
+
before: Optional[str] | Omit = omit,
|
|
266
|
+
exclude_tool_types: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
267
|
+
limit: Optional[int] | Omit = omit,
|
|
268
|
+
name: Optional[str] | Omit = omit,
|
|
269
|
+
names: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
270
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
271
|
+
order_by: Literal["created_at"] | Omit = omit,
|
|
272
|
+
return_only_letta_tools: Optional[bool] | Omit = omit,
|
|
273
|
+
search: Optional[str] | Omit = omit,
|
|
274
|
+
tool_ids: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
275
|
+
tool_types: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
276
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
277
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
278
|
+
extra_headers: Headers | None = None,
|
|
279
|
+
extra_query: Query | None = None,
|
|
280
|
+
extra_body: Body | None = None,
|
|
281
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
282
|
+
) -> SyncArrayPage[Tool]:
|
|
283
|
+
"""
|
|
284
|
+
Get a list of all tools available to agents.
|
|
285
|
+
|
|
286
|
+
Args:
|
|
287
|
+
after: Tool ID cursor for pagination. Returns tools that come after this tool ID in the
|
|
288
|
+
specified sort order
|
|
289
|
+
|
|
290
|
+
before: Tool ID cursor for pagination. Returns tools that come before this tool ID in
|
|
291
|
+
the specified sort order
|
|
292
|
+
|
|
293
|
+
exclude_tool_types: Tool type(s) to exclude - accepts repeated params or comma-separated values
|
|
294
|
+
|
|
295
|
+
limit: Maximum number of tools to return
|
|
296
|
+
|
|
297
|
+
name: Filter by single tool name
|
|
298
|
+
|
|
299
|
+
names: Filter by specific tool names
|
|
300
|
+
|
|
301
|
+
order: Sort order for tools by creation time. 'asc' for oldest first, 'desc' for newest
|
|
302
|
+
first
|
|
303
|
+
|
|
304
|
+
order_by: Field to sort by
|
|
305
|
+
|
|
306
|
+
return_only_letta_tools: Return only tools with tool*type starting with 'letta*'
|
|
307
|
+
|
|
308
|
+
search: Search tool names (case-insensitive partial match)
|
|
309
|
+
|
|
310
|
+
tool_ids: Filter by specific tool IDs - accepts repeated params or comma-separated values
|
|
311
|
+
|
|
312
|
+
tool_types: Filter by tool type(s) - accepts repeated params or comma-separated values
|
|
313
|
+
|
|
314
|
+
extra_headers: Send extra headers
|
|
315
|
+
|
|
316
|
+
extra_query: Add additional query parameters to the request
|
|
317
|
+
|
|
318
|
+
extra_body: Add additional JSON properties to the request
|
|
319
|
+
|
|
320
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
321
|
+
"""
|
|
322
|
+
return self._get_api_list(
|
|
323
|
+
"/v1/tools/",
|
|
324
|
+
page=SyncArrayPage[Tool],
|
|
325
|
+
options=make_request_options(
|
|
326
|
+
extra_headers=extra_headers,
|
|
327
|
+
extra_query=extra_query,
|
|
328
|
+
extra_body=extra_body,
|
|
329
|
+
timeout=timeout,
|
|
330
|
+
query=maybe_transform(
|
|
331
|
+
{
|
|
332
|
+
"after": after,
|
|
333
|
+
"before": before,
|
|
334
|
+
"exclude_tool_types": exclude_tool_types,
|
|
335
|
+
"limit": limit,
|
|
336
|
+
"name": name,
|
|
337
|
+
"names": names,
|
|
338
|
+
"order": order,
|
|
339
|
+
"order_by": order_by,
|
|
340
|
+
"return_only_letta_tools": return_only_letta_tools,
|
|
341
|
+
"search": search,
|
|
342
|
+
"tool_ids": tool_ids,
|
|
343
|
+
"tool_types": tool_types,
|
|
344
|
+
},
|
|
345
|
+
tool_list_params.ToolListParams,
|
|
346
|
+
),
|
|
347
|
+
),
|
|
348
|
+
model=Tool,
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
def delete(
|
|
352
|
+
self,
|
|
353
|
+
tool_id: str,
|
|
354
|
+
*,
|
|
355
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
356
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
357
|
+
extra_headers: Headers | None = None,
|
|
358
|
+
extra_query: Query | None = None,
|
|
359
|
+
extra_body: Body | None = None,
|
|
360
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
361
|
+
) -> object:
|
|
362
|
+
"""
|
|
363
|
+
Delete a tool by name
|
|
364
|
+
|
|
365
|
+
Args:
|
|
366
|
+
tool_id: The ID of the tool in the format 'tool-<uuid4>'
|
|
367
|
+
|
|
368
|
+
extra_headers: Send extra headers
|
|
369
|
+
|
|
370
|
+
extra_query: Add additional query parameters to the request
|
|
371
|
+
|
|
372
|
+
extra_body: Add additional JSON properties to the request
|
|
373
|
+
|
|
374
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
375
|
+
"""
|
|
376
|
+
if not tool_id:
|
|
377
|
+
raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}")
|
|
378
|
+
return self._delete(
|
|
379
|
+
f"/v1/tools/{tool_id}",
|
|
380
|
+
options=make_request_options(
|
|
381
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
382
|
+
),
|
|
383
|
+
cast_to=object,
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
def search(
|
|
387
|
+
self,
|
|
388
|
+
*,
|
|
389
|
+
limit: int | Omit = omit,
|
|
390
|
+
query: Optional[str] | Omit = omit,
|
|
391
|
+
search_mode: Literal["vector", "fts", "hybrid"] | Omit = omit,
|
|
392
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
393
|
+
tool_types: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
394
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
395
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
396
|
+
extra_headers: Headers | None = None,
|
|
397
|
+
extra_query: Query | None = None,
|
|
398
|
+
extra_body: Body | None = None,
|
|
399
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
400
|
+
) -> ToolSearchResponse:
|
|
401
|
+
"""
|
|
402
|
+
Search tools using semantic search.
|
|
403
|
+
|
|
404
|
+
Requires tool embedding to be enabled (embed_tools=True). Uses vector search,
|
|
405
|
+
full-text search, or hybrid mode to find tools matching the query.
|
|
406
|
+
|
|
407
|
+
Returns tools ranked by relevance with their search scores.
|
|
408
|
+
|
|
409
|
+
Args:
|
|
410
|
+
limit: Maximum number of results to return.
|
|
411
|
+
|
|
412
|
+
query: Text query for semantic search.
|
|
413
|
+
|
|
414
|
+
search_mode: Search mode: vector, fts, or hybrid.
|
|
415
|
+
|
|
416
|
+
tags: Filter by tags (match any).
|
|
417
|
+
|
|
418
|
+
tool_types: Filter by tool types (e.g., 'custom', 'letta_core').
|
|
419
|
+
|
|
420
|
+
extra_headers: Send extra headers
|
|
421
|
+
|
|
422
|
+
extra_query: Add additional query parameters to the request
|
|
423
|
+
|
|
424
|
+
extra_body: Add additional JSON properties to the request
|
|
425
|
+
|
|
426
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
427
|
+
"""
|
|
428
|
+
return self._post(
|
|
429
|
+
"/v1/tools/search",
|
|
430
|
+
body=maybe_transform(
|
|
431
|
+
{
|
|
432
|
+
"limit": limit,
|
|
433
|
+
"query": query,
|
|
434
|
+
"search_mode": search_mode,
|
|
435
|
+
"tags": tags,
|
|
436
|
+
"tool_types": tool_types,
|
|
437
|
+
},
|
|
438
|
+
tool_search_params.ToolSearchParams,
|
|
439
|
+
),
|
|
440
|
+
options=make_request_options(
|
|
441
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
442
|
+
),
|
|
443
|
+
cast_to=ToolSearchResponse,
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
def upsert(
|
|
447
|
+
self,
|
|
448
|
+
*,
|
|
449
|
+
source_code: str,
|
|
450
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
451
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
452
|
+
description: Optional[str] | Omit = omit,
|
|
453
|
+
enable_parallel_execution: Optional[bool] | Omit = omit,
|
|
454
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
455
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
456
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
457
|
+
return_char_limit: int | Omit = omit,
|
|
458
|
+
source_type: str | Omit = omit,
|
|
459
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
460
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
461
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
462
|
+
extra_headers: Headers | None = None,
|
|
463
|
+
extra_query: Query | None = None,
|
|
464
|
+
extra_body: Body | None = None,
|
|
465
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
466
|
+
) -> Tool:
|
|
467
|
+
"""
|
|
468
|
+
Create or update a tool
|
|
469
|
+
|
|
470
|
+
Args:
|
|
471
|
+
source_code: The source code of the function.
|
|
472
|
+
|
|
473
|
+
args_json_schema: The args JSON schema of the function.
|
|
474
|
+
|
|
475
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
476
|
+
|
|
477
|
+
description: The description of the tool.
|
|
478
|
+
|
|
479
|
+
enable_parallel_execution: If set to True, then this tool will potentially be executed concurrently with
|
|
480
|
+
other tools. Default False.
|
|
481
|
+
|
|
482
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
483
|
+
provided)
|
|
484
|
+
|
|
485
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
486
|
+
|
|
487
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
488
|
+
|
|
489
|
+
return_char_limit: The maximum number of characters in the response.
|
|
490
|
+
|
|
491
|
+
source_type: The source type of the function.
|
|
492
|
+
|
|
493
|
+
tags: Metadata tags.
|
|
494
|
+
|
|
495
|
+
extra_headers: Send extra headers
|
|
496
|
+
|
|
497
|
+
extra_query: Add additional query parameters to the request
|
|
498
|
+
|
|
499
|
+
extra_body: Add additional JSON properties to the request
|
|
500
|
+
|
|
501
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
502
|
+
"""
|
|
503
|
+
return self._put(
|
|
504
|
+
"/v1/tools/",
|
|
505
|
+
body=maybe_transform(
|
|
506
|
+
{
|
|
507
|
+
"source_code": source_code,
|
|
508
|
+
"args_json_schema": args_json_schema,
|
|
509
|
+
"default_requires_approval": default_requires_approval,
|
|
510
|
+
"description": description,
|
|
511
|
+
"enable_parallel_execution": enable_parallel_execution,
|
|
512
|
+
"json_schema": json_schema,
|
|
513
|
+
"npm_requirements": npm_requirements,
|
|
514
|
+
"pip_requirements": pip_requirements,
|
|
515
|
+
"return_char_limit": return_char_limit,
|
|
516
|
+
"source_type": source_type,
|
|
517
|
+
"tags": tags,
|
|
518
|
+
},
|
|
519
|
+
tool_upsert_params.ToolUpsertParams,
|
|
520
|
+
),
|
|
521
|
+
options=make_request_options(
|
|
522
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
523
|
+
),
|
|
524
|
+
cast_to=Tool,
|
|
525
|
+
)
|
|
526
|
+
|
|
527
|
+
def create_from_function(
|
|
528
|
+
self,
|
|
529
|
+
*,
|
|
530
|
+
func: typing.Callable[..., typing.Any],
|
|
531
|
+
args_schema: typing.Optional[typing.Type[BaseModel]] | Omit = omit,
|
|
532
|
+
description: Optional[str] | Omit = omit,
|
|
533
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
534
|
+
source_type: str | Omit = omit,
|
|
535
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
536
|
+
return_char_limit: int | Omit = omit,
|
|
537
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
538
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
539
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
540
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
541
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
542
|
+
extra_headers: Headers | None = None,
|
|
543
|
+
extra_query: Query | None = None,
|
|
544
|
+
extra_body: Body | None = None,
|
|
545
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
546
|
+
) -> Tool:
|
|
547
|
+
"""
|
|
548
|
+
Create a new tool from a callable
|
|
549
|
+
|
|
550
|
+
Args:
|
|
551
|
+
func: The callable to create the tool from.
|
|
552
|
+
|
|
553
|
+
args_schema: The arguments schema of the function, as a Pydantic model.
|
|
554
|
+
|
|
555
|
+
description: The description of the tool.
|
|
556
|
+
|
|
557
|
+
tags: Metadata tags.
|
|
558
|
+
|
|
559
|
+
source_type: The source type of the function.
|
|
560
|
+
|
|
561
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
562
|
+
provided)
|
|
563
|
+
|
|
564
|
+
return_char_limit: The maximum number of characters in the response.
|
|
565
|
+
|
|
566
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
567
|
+
|
|
568
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
569
|
+
|
|
570
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
571
|
+
|
|
572
|
+
extra_headers: Send extra headers
|
|
573
|
+
|
|
574
|
+
extra_query: Add additional query parameters to the request
|
|
575
|
+
|
|
576
|
+
extra_body: Add additional JSON properties to the request
|
|
577
|
+
|
|
578
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
579
|
+
|
|
580
|
+
Examples:
|
|
581
|
+
from letta_client import Letta
|
|
582
|
+
|
|
583
|
+
client = Letta(
|
|
584
|
+
token="YOUR_TOKEN",
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
def add_two_numbers(a: int, b: int) -> int:
|
|
588
|
+
return a + b
|
|
589
|
+
|
|
590
|
+
client.tools.create_from_function(
|
|
591
|
+
func=add_two_numbers,
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
class InventoryEntryData(BaseModel):
|
|
595
|
+
data: InventoryEntry
|
|
596
|
+
quantity_change: int
|
|
597
|
+
|
|
598
|
+
def manage_inventory(data: InventoryEntry, quantity_change: int) -> bool:
|
|
599
|
+
pass
|
|
600
|
+
|
|
601
|
+
client.tools.create_from_function(
|
|
602
|
+
func=manage_inventory,
|
|
603
|
+
args_schema=InventoryEntryData,
|
|
604
|
+
)
|
|
605
|
+
"""
|
|
606
|
+
source_code = dedent(inspect.getsource(func))
|
|
607
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit
|
|
608
|
+
if not isinstance(args_schema, Omit) and args_schema is not None:
|
|
609
|
+
args_json_schema = args_schema.model_json_schema()
|
|
610
|
+
|
|
611
|
+
return self.create(
|
|
612
|
+
source_code=source_code,
|
|
613
|
+
args_json_schema=args_json_schema,
|
|
614
|
+
description=description,
|
|
615
|
+
tags=tags,
|
|
616
|
+
source_type=source_type,
|
|
617
|
+
json_schema=json_schema,
|
|
618
|
+
return_char_limit=return_char_limit,
|
|
619
|
+
pip_requirements=pip_requirements,
|
|
620
|
+
npm_requirements=npm_requirements,
|
|
621
|
+
default_requires_approval=default_requires_approval,
|
|
622
|
+
extra_headers=extra_headers,
|
|
623
|
+
extra_query=extra_query,
|
|
624
|
+
extra_body=extra_body,
|
|
625
|
+
timeout=timeout,
|
|
626
|
+
)
|
|
627
|
+
|
|
628
|
+
def upsert_from_function(
|
|
629
|
+
self,
|
|
630
|
+
*,
|
|
631
|
+
func: typing.Callable[..., typing.Any],
|
|
632
|
+
args_schema: typing.Optional[typing.Type[BaseModel]] | Omit = omit,
|
|
633
|
+
description: Optional[str] | Omit = omit,
|
|
634
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
635
|
+
source_type: str | Omit = omit,
|
|
636
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
637
|
+
return_char_limit: int | Omit = omit,
|
|
638
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
639
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
640
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
641
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
642
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
643
|
+
extra_headers: Headers | None = None,
|
|
644
|
+
extra_query: Query | None = None,
|
|
645
|
+
extra_body: Body | None = None,
|
|
646
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
647
|
+
) -> Tool:
|
|
648
|
+
"""
|
|
649
|
+
Create or update a tool from a callable
|
|
650
|
+
|
|
651
|
+
Args:
|
|
652
|
+
func: The callable to create or update the tool from.
|
|
653
|
+
|
|
654
|
+
args_schema: The arguments schema of the function, as a Pydantic model.
|
|
655
|
+
|
|
656
|
+
description: The description of the tool.
|
|
657
|
+
|
|
658
|
+
tags: Metadata tags.
|
|
659
|
+
|
|
660
|
+
source_type: The source type of the function.
|
|
661
|
+
|
|
662
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
663
|
+
provided)
|
|
664
|
+
|
|
665
|
+
return_char_limit: The maximum number of characters in the response.
|
|
666
|
+
|
|
667
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
668
|
+
|
|
669
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
670
|
+
|
|
671
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
672
|
+
|
|
673
|
+
extra_headers: Send extra headers
|
|
674
|
+
|
|
675
|
+
extra_query: Add additional query parameters to the request
|
|
676
|
+
|
|
677
|
+
extra_body: Add additional JSON properties to the request
|
|
678
|
+
|
|
679
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
680
|
+
|
|
681
|
+
Examples:
|
|
682
|
+
from letta_client import Letta
|
|
683
|
+
|
|
684
|
+
client = Letta(
|
|
685
|
+
token="YOUR_TOKEN",
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
def add_two_numbers(a: int, b: int) -> int:
|
|
689
|
+
return a + b
|
|
690
|
+
|
|
691
|
+
client.tools.upsert_from_function(
|
|
692
|
+
func=add_two_numbers,
|
|
693
|
+
)
|
|
694
|
+
|
|
695
|
+
class InventoryEntryData(BaseModel):
|
|
696
|
+
data: InventoryEntry
|
|
697
|
+
quantity_change: int
|
|
698
|
+
|
|
699
|
+
def manage_inventory(data: InventoryEntry, quantity_change: int) -> bool:
|
|
700
|
+
pass
|
|
701
|
+
|
|
702
|
+
client.tools.upsert_from_function(
|
|
703
|
+
func=manage_inventory,
|
|
704
|
+
args_schema=InventoryEntryData,
|
|
705
|
+
)
|
|
706
|
+
"""
|
|
707
|
+
source_code = dedent(inspect.getsource(func))
|
|
708
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit
|
|
709
|
+
if not isinstance(args_schema, Omit) and args_schema is not None:
|
|
710
|
+
args_json_schema = args_schema.model_json_schema()
|
|
711
|
+
|
|
712
|
+
return self.upsert(
|
|
713
|
+
source_code=source_code,
|
|
714
|
+
args_json_schema=args_json_schema,
|
|
715
|
+
description=description,
|
|
716
|
+
tags=tags,
|
|
717
|
+
source_type=source_type,
|
|
718
|
+
json_schema=json_schema,
|
|
719
|
+
return_char_limit=return_char_limit,
|
|
720
|
+
pip_requirements=pip_requirements,
|
|
721
|
+
npm_requirements=npm_requirements,
|
|
722
|
+
default_requires_approval=default_requires_approval,
|
|
723
|
+
extra_headers=extra_headers,
|
|
724
|
+
extra_query=extra_query,
|
|
725
|
+
extra_body=extra_body,
|
|
726
|
+
timeout=timeout,
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
def add(
|
|
730
|
+
self,
|
|
731
|
+
*,
|
|
732
|
+
tool: BaseTool,
|
|
733
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
734
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
735
|
+
extra_headers: Headers | None = None,
|
|
736
|
+
extra_query: Query | None = None,
|
|
737
|
+
extra_body: Body | None = None,
|
|
738
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
739
|
+
) -> Tool:
|
|
740
|
+
"""
|
|
741
|
+
Add a tool to Letta from a custom Tool class
|
|
742
|
+
|
|
743
|
+
Args:
|
|
744
|
+
tool: The tool object to be added.
|
|
745
|
+
|
|
746
|
+
extra_headers: Send extra headers
|
|
747
|
+
|
|
748
|
+
extra_query: Add additional query parameters to the request
|
|
749
|
+
|
|
750
|
+
extra_body: Add additional JSON properties to the request
|
|
751
|
+
|
|
752
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
753
|
+
|
|
754
|
+
Examples:
|
|
755
|
+
from letta_client import Letta
|
|
756
|
+
|
|
757
|
+
client = Letta(
|
|
758
|
+
token="YOUR_TOKEN",
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
class InventoryItem(BaseModel):
|
|
762
|
+
sku: str # Unique product identifier
|
|
763
|
+
name: str # Product name
|
|
764
|
+
price: float # Current price
|
|
765
|
+
category: str # Product category (e.g., "Electronics", "Clothing")
|
|
766
|
+
|
|
767
|
+
class InventoryEntry(BaseModel):
|
|
768
|
+
timestamp: int # Unix timestamp of the transaction
|
|
769
|
+
item: InventoryItem # The product being updated
|
|
770
|
+
transaction_id: str # Unique identifier for this inventory update
|
|
771
|
+
|
|
772
|
+
class InventoryEntryData(BaseModel):
|
|
773
|
+
data: InventoryEntry
|
|
774
|
+
quantity_change: int # Change in quantity (positive for additions, negative for removals)
|
|
775
|
+
|
|
776
|
+
class ManageInventoryTool(BaseTool):
|
|
777
|
+
name: str = "manage_inventory"
|
|
778
|
+
args_schema: Type[BaseModel] = InventoryEntryData
|
|
779
|
+
description: str = "Update inventory catalogue with a new data entry"
|
|
780
|
+
tags: List[str] = ["inventory", "shop"]
|
|
781
|
+
|
|
782
|
+
def run(self, data: InventoryEntry, quantity_change: int) -> bool:
|
|
783
|
+
'''
|
|
784
|
+
Implementation of the manage_inventory tool
|
|
785
|
+
'''
|
|
786
|
+
print(f"Updated inventory for {data.item.name} with a quantity change of {quantity_change}")
|
|
787
|
+
return True
|
|
788
|
+
|
|
789
|
+
client.tools.add(
|
|
790
|
+
tool=ManageInventoryTool()
|
|
791
|
+
)
|
|
792
|
+
"""
|
|
793
|
+
source_code = tool.get_source_code()
|
|
794
|
+
args_json_schema = tool.args_schema.model_json_schema() if tool.args_schema else None
|
|
795
|
+
|
|
796
|
+
# Convert PipRequirement/NpmRequirement models to Param dicts
|
|
797
|
+
pip_requirements_param = (
|
|
798
|
+
[typing.cast(PipRequirementParam, req.model_dump()) for req in tool.pip_requirements]
|
|
799
|
+
if tool.pip_requirements
|
|
800
|
+
else omit
|
|
801
|
+
)
|
|
802
|
+
npm_requirements_param = (
|
|
803
|
+
[typing.cast(NpmRequirementParam, req.model_dump()) for req in tool.npm_requirements]
|
|
804
|
+
if tool.npm_requirements
|
|
805
|
+
else omit
|
|
806
|
+
)
|
|
807
|
+
|
|
808
|
+
return self.upsert(
|
|
809
|
+
source_code=source_code,
|
|
810
|
+
args_json_schema=args_json_schema or omit,
|
|
811
|
+
description=tool.description or omit,
|
|
812
|
+
tags=tool.tags or omit,
|
|
813
|
+
source_type=tool.source_type or omit,
|
|
814
|
+
json_schema=tool.json_schema or omit,
|
|
815
|
+
return_char_limit=tool.return_char_limit or omit,
|
|
816
|
+
pip_requirements=pip_requirements_param,
|
|
817
|
+
npm_requirements=npm_requirements_param,
|
|
818
|
+
default_requires_approval=tool.default_requires_approval or omit,
|
|
819
|
+
extra_headers=extra_headers,
|
|
820
|
+
extra_query=extra_query,
|
|
821
|
+
extra_body=extra_body,
|
|
822
|
+
timeout=timeout,
|
|
823
|
+
)
|
|
824
|
+
|
|
825
|
+
class AsyncToolsResource(AsyncAPIResource):
|
|
826
|
+
@cached_property
|
|
827
|
+
def with_raw_response(self) -> AsyncToolsResourceWithRawResponse:
|
|
828
|
+
"""
|
|
829
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
830
|
+
the raw response object instead of the parsed content.
|
|
831
|
+
|
|
832
|
+
For more information, see https://www.github.com/letta-ai/letta-python#accessing-raw-response-data-eg-headers
|
|
833
|
+
"""
|
|
834
|
+
return AsyncToolsResourceWithRawResponse(self)
|
|
835
|
+
|
|
836
|
+
@cached_property
|
|
837
|
+
def with_streaming_response(self) -> AsyncToolsResourceWithStreamingResponse:
|
|
838
|
+
"""
|
|
839
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
840
|
+
|
|
841
|
+
For more information, see https://www.github.com/letta-ai/letta-python#with_streaming_response
|
|
842
|
+
"""
|
|
843
|
+
return AsyncToolsResourceWithStreamingResponse(self)
|
|
844
|
+
|
|
845
|
+
async def create(
|
|
846
|
+
self,
|
|
847
|
+
*,
|
|
848
|
+
source_code: str,
|
|
849
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
850
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
851
|
+
description: Optional[str] | Omit = omit,
|
|
852
|
+
enable_parallel_execution: Optional[bool] | Omit = omit,
|
|
853
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
854
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
855
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
856
|
+
return_char_limit: int | Omit = omit,
|
|
857
|
+
source_type: str | Omit = omit,
|
|
858
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
859
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
860
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
861
|
+
extra_headers: Headers | None = None,
|
|
862
|
+
extra_query: Query | None = None,
|
|
863
|
+
extra_body: Body | None = None,
|
|
864
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
865
|
+
) -> Tool:
|
|
866
|
+
"""
|
|
867
|
+
Create a new tool
|
|
868
|
+
|
|
869
|
+
Args:
|
|
870
|
+
source_code: The source code of the function.
|
|
871
|
+
|
|
872
|
+
args_json_schema: The args JSON schema of the function.
|
|
873
|
+
|
|
874
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
875
|
+
|
|
876
|
+
description: The description of the tool.
|
|
877
|
+
|
|
878
|
+
enable_parallel_execution: If set to True, then this tool will potentially be executed concurrently with
|
|
879
|
+
other tools. Default False.
|
|
880
|
+
|
|
881
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
882
|
+
provided)
|
|
883
|
+
|
|
884
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
885
|
+
|
|
886
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
887
|
+
|
|
888
|
+
return_char_limit: The maximum number of characters in the response.
|
|
889
|
+
|
|
890
|
+
source_type: The source type of the function.
|
|
891
|
+
|
|
892
|
+
tags: Metadata tags.
|
|
893
|
+
|
|
894
|
+
extra_headers: Send extra headers
|
|
895
|
+
|
|
896
|
+
extra_query: Add additional query parameters to the request
|
|
897
|
+
|
|
898
|
+
extra_body: Add additional JSON properties to the request
|
|
899
|
+
|
|
900
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
901
|
+
"""
|
|
902
|
+
return await self._post(
|
|
903
|
+
"/v1/tools/",
|
|
904
|
+
body=await async_maybe_transform(
|
|
905
|
+
{
|
|
906
|
+
"source_code": source_code,
|
|
907
|
+
"args_json_schema": args_json_schema,
|
|
908
|
+
"default_requires_approval": default_requires_approval,
|
|
909
|
+
"description": description,
|
|
910
|
+
"enable_parallel_execution": enable_parallel_execution,
|
|
911
|
+
"json_schema": json_schema,
|
|
912
|
+
"npm_requirements": npm_requirements,
|
|
913
|
+
"pip_requirements": pip_requirements,
|
|
914
|
+
"return_char_limit": return_char_limit,
|
|
915
|
+
"source_type": source_type,
|
|
916
|
+
"tags": tags,
|
|
917
|
+
},
|
|
918
|
+
tool_create_params.ToolCreateParams,
|
|
919
|
+
),
|
|
920
|
+
options=make_request_options(
|
|
921
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
922
|
+
),
|
|
923
|
+
cast_to=Tool,
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
async def retrieve(
|
|
927
|
+
self,
|
|
928
|
+
tool_id: str,
|
|
929
|
+
*,
|
|
930
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
931
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
932
|
+
extra_headers: Headers | None = None,
|
|
933
|
+
extra_query: Query | None = None,
|
|
934
|
+
extra_body: Body | None = None,
|
|
935
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
936
|
+
) -> Tool:
|
|
937
|
+
"""
|
|
938
|
+
Get a tool by ID
|
|
939
|
+
|
|
940
|
+
Args:
|
|
941
|
+
tool_id: The ID of the tool in the format 'tool-<uuid4>'
|
|
942
|
+
|
|
943
|
+
extra_headers: Send extra headers
|
|
944
|
+
|
|
945
|
+
extra_query: Add additional query parameters to the request
|
|
946
|
+
|
|
947
|
+
extra_body: Add additional JSON properties to the request
|
|
948
|
+
|
|
949
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
950
|
+
"""
|
|
951
|
+
if not tool_id:
|
|
952
|
+
raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}")
|
|
953
|
+
return await self._get(
|
|
954
|
+
f"/v1/tools/{tool_id}",
|
|
955
|
+
options=make_request_options(
|
|
956
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
957
|
+
),
|
|
958
|
+
cast_to=Tool,
|
|
959
|
+
)
|
|
960
|
+
|
|
961
|
+
async def update(
|
|
962
|
+
self,
|
|
963
|
+
tool_id: str,
|
|
964
|
+
*,
|
|
965
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
966
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
967
|
+
description: Optional[str] | Omit = omit,
|
|
968
|
+
enable_parallel_execution: Optional[bool] | Omit = omit,
|
|
969
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
970
|
+
metadata: Optional[Dict[str, object]] | Omit = omit,
|
|
971
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
972
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
973
|
+
return_char_limit: Optional[int] | Omit = omit,
|
|
974
|
+
source_code: Optional[str] | Omit = omit,
|
|
975
|
+
source_type: Optional[str] | Omit = omit,
|
|
976
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
977
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
978
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
979
|
+
extra_headers: Headers | None = None,
|
|
980
|
+
extra_query: Query | None = None,
|
|
981
|
+
extra_body: Body | None = None,
|
|
982
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
983
|
+
) -> Tool:
|
|
984
|
+
"""
|
|
985
|
+
Update an existing tool
|
|
986
|
+
|
|
987
|
+
Args:
|
|
988
|
+
tool_id: The ID of the tool in the format 'tool-<uuid4>'
|
|
989
|
+
|
|
990
|
+
args_json_schema: The args JSON schema of the function.
|
|
991
|
+
|
|
992
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
993
|
+
|
|
994
|
+
description: The description of the tool.
|
|
995
|
+
|
|
996
|
+
enable_parallel_execution: If set to True, then this tool will potentially be executed concurrently with
|
|
997
|
+
other tools. Default False.
|
|
998
|
+
|
|
999
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
1000
|
+
provided)
|
|
1001
|
+
|
|
1002
|
+
metadata: A dictionary of additional metadata for the tool.
|
|
1003
|
+
|
|
1004
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
1005
|
+
|
|
1006
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
1007
|
+
|
|
1008
|
+
return_char_limit: The maximum number of characters in the response.
|
|
1009
|
+
|
|
1010
|
+
source_code: The source code of the function.
|
|
1011
|
+
|
|
1012
|
+
source_type: The type of the source code.
|
|
1013
|
+
|
|
1014
|
+
tags: Metadata tags.
|
|
1015
|
+
|
|
1016
|
+
extra_headers: Send extra headers
|
|
1017
|
+
|
|
1018
|
+
extra_query: Add additional query parameters to the request
|
|
1019
|
+
|
|
1020
|
+
extra_body: Add additional JSON properties to the request
|
|
1021
|
+
|
|
1022
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1023
|
+
"""
|
|
1024
|
+
if not tool_id:
|
|
1025
|
+
raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}")
|
|
1026
|
+
return await self._patch(
|
|
1027
|
+
f"/v1/tools/{tool_id}",
|
|
1028
|
+
body=await async_maybe_transform(
|
|
1029
|
+
{
|
|
1030
|
+
"args_json_schema": args_json_schema,
|
|
1031
|
+
"default_requires_approval": default_requires_approval,
|
|
1032
|
+
"description": description,
|
|
1033
|
+
"enable_parallel_execution": enable_parallel_execution,
|
|
1034
|
+
"json_schema": json_schema,
|
|
1035
|
+
"metadata": metadata,
|
|
1036
|
+
"npm_requirements": npm_requirements,
|
|
1037
|
+
"pip_requirements": pip_requirements,
|
|
1038
|
+
"return_char_limit": return_char_limit,
|
|
1039
|
+
"source_code": source_code,
|
|
1040
|
+
"source_type": source_type,
|
|
1041
|
+
"tags": tags,
|
|
1042
|
+
},
|
|
1043
|
+
tool_update_params.ToolUpdateParams,
|
|
1044
|
+
),
|
|
1045
|
+
options=make_request_options(
|
|
1046
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1047
|
+
),
|
|
1048
|
+
cast_to=Tool,
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
def list(
|
|
1052
|
+
self,
|
|
1053
|
+
*,
|
|
1054
|
+
after: Optional[str] | Omit = omit,
|
|
1055
|
+
before: Optional[str] | Omit = omit,
|
|
1056
|
+
exclude_tool_types: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1057
|
+
limit: Optional[int] | Omit = omit,
|
|
1058
|
+
name: Optional[str] | Omit = omit,
|
|
1059
|
+
names: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1060
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
1061
|
+
order_by: Literal["created_at"] | Omit = omit,
|
|
1062
|
+
return_only_letta_tools: Optional[bool] | Omit = omit,
|
|
1063
|
+
search: Optional[str] | Omit = omit,
|
|
1064
|
+
tool_ids: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1065
|
+
tool_types: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1066
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1067
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1068
|
+
extra_headers: Headers | None = None,
|
|
1069
|
+
extra_query: Query | None = None,
|
|
1070
|
+
extra_body: Body | None = None,
|
|
1071
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1072
|
+
) -> AsyncPaginator[Tool, AsyncArrayPage[Tool]]:
|
|
1073
|
+
"""
|
|
1074
|
+
Get a list of all tools available to agents.
|
|
1075
|
+
|
|
1076
|
+
Args:
|
|
1077
|
+
after: Tool ID cursor for pagination. Returns tools that come after this tool ID in the
|
|
1078
|
+
specified sort order
|
|
1079
|
+
|
|
1080
|
+
before: Tool ID cursor for pagination. Returns tools that come before this tool ID in
|
|
1081
|
+
the specified sort order
|
|
1082
|
+
|
|
1083
|
+
exclude_tool_types: Tool type(s) to exclude - accepts repeated params or comma-separated values
|
|
1084
|
+
|
|
1085
|
+
limit: Maximum number of tools to return
|
|
1086
|
+
|
|
1087
|
+
name: Filter by single tool name
|
|
1088
|
+
|
|
1089
|
+
names: Filter by specific tool names
|
|
1090
|
+
|
|
1091
|
+
order: Sort order for tools by creation time. 'asc' for oldest first, 'desc' for newest
|
|
1092
|
+
first
|
|
1093
|
+
|
|
1094
|
+
order_by: Field to sort by
|
|
1095
|
+
|
|
1096
|
+
return_only_letta_tools: Return only tools with tool*type starting with 'letta*'
|
|
1097
|
+
|
|
1098
|
+
search: Search tool names (case-insensitive partial match)
|
|
1099
|
+
|
|
1100
|
+
tool_ids: Filter by specific tool IDs - accepts repeated params or comma-separated values
|
|
1101
|
+
|
|
1102
|
+
tool_types: Filter by tool type(s) - accepts repeated params or comma-separated values
|
|
1103
|
+
|
|
1104
|
+
extra_headers: Send extra headers
|
|
1105
|
+
|
|
1106
|
+
extra_query: Add additional query parameters to the request
|
|
1107
|
+
|
|
1108
|
+
extra_body: Add additional JSON properties to the request
|
|
1109
|
+
|
|
1110
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1111
|
+
"""
|
|
1112
|
+
return self._get_api_list(
|
|
1113
|
+
"/v1/tools/",
|
|
1114
|
+
page=AsyncArrayPage[Tool],
|
|
1115
|
+
options=make_request_options(
|
|
1116
|
+
extra_headers=extra_headers,
|
|
1117
|
+
extra_query=extra_query,
|
|
1118
|
+
extra_body=extra_body,
|
|
1119
|
+
timeout=timeout,
|
|
1120
|
+
query=maybe_transform(
|
|
1121
|
+
{
|
|
1122
|
+
"after": after,
|
|
1123
|
+
"before": before,
|
|
1124
|
+
"exclude_tool_types": exclude_tool_types,
|
|
1125
|
+
"limit": limit,
|
|
1126
|
+
"name": name,
|
|
1127
|
+
"names": names,
|
|
1128
|
+
"order": order,
|
|
1129
|
+
"order_by": order_by,
|
|
1130
|
+
"return_only_letta_tools": return_only_letta_tools,
|
|
1131
|
+
"search": search,
|
|
1132
|
+
"tool_ids": tool_ids,
|
|
1133
|
+
"tool_types": tool_types,
|
|
1134
|
+
},
|
|
1135
|
+
tool_list_params.ToolListParams,
|
|
1136
|
+
),
|
|
1137
|
+
),
|
|
1138
|
+
model=Tool,
|
|
1139
|
+
)
|
|
1140
|
+
|
|
1141
|
+
async def delete(
|
|
1142
|
+
self,
|
|
1143
|
+
tool_id: str,
|
|
1144
|
+
*,
|
|
1145
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1146
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1147
|
+
extra_headers: Headers | None = None,
|
|
1148
|
+
extra_query: Query | None = None,
|
|
1149
|
+
extra_body: Body | None = None,
|
|
1150
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1151
|
+
) -> object:
|
|
1152
|
+
"""
|
|
1153
|
+
Delete a tool by name
|
|
1154
|
+
|
|
1155
|
+
Args:
|
|
1156
|
+
tool_id: The ID of the tool in the format 'tool-<uuid4>'
|
|
1157
|
+
|
|
1158
|
+
extra_headers: Send extra headers
|
|
1159
|
+
|
|
1160
|
+
extra_query: Add additional query parameters to the request
|
|
1161
|
+
|
|
1162
|
+
extra_body: Add additional JSON properties to the request
|
|
1163
|
+
|
|
1164
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1165
|
+
"""
|
|
1166
|
+
if not tool_id:
|
|
1167
|
+
raise ValueError(f"Expected a non-empty value for `tool_id` but received {tool_id!r}")
|
|
1168
|
+
return await self._delete(
|
|
1169
|
+
f"/v1/tools/{tool_id}",
|
|
1170
|
+
options=make_request_options(
|
|
1171
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1172
|
+
),
|
|
1173
|
+
cast_to=object,
|
|
1174
|
+
)
|
|
1175
|
+
|
|
1176
|
+
async def search(
|
|
1177
|
+
self,
|
|
1178
|
+
*,
|
|
1179
|
+
limit: int | Omit = omit,
|
|
1180
|
+
query: Optional[str] | Omit = omit,
|
|
1181
|
+
search_mode: Literal["vector", "fts", "hybrid"] | Omit = omit,
|
|
1182
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1183
|
+
tool_types: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1184
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1185
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1186
|
+
extra_headers: Headers | None = None,
|
|
1187
|
+
extra_query: Query | None = None,
|
|
1188
|
+
extra_body: Body | None = None,
|
|
1189
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1190
|
+
) -> ToolSearchResponse:
|
|
1191
|
+
"""
|
|
1192
|
+
Search tools using semantic search.
|
|
1193
|
+
|
|
1194
|
+
Requires tool embedding to be enabled (embed_tools=True). Uses vector search,
|
|
1195
|
+
full-text search, or hybrid mode to find tools matching the query.
|
|
1196
|
+
|
|
1197
|
+
Returns tools ranked by relevance with their search scores.
|
|
1198
|
+
|
|
1199
|
+
Args:
|
|
1200
|
+
limit: Maximum number of results to return.
|
|
1201
|
+
|
|
1202
|
+
query: Text query for semantic search.
|
|
1203
|
+
|
|
1204
|
+
search_mode: Search mode: vector, fts, or hybrid.
|
|
1205
|
+
|
|
1206
|
+
tags: Filter by tags (match any).
|
|
1207
|
+
|
|
1208
|
+
tool_types: Filter by tool types (e.g., 'custom', 'letta_core').
|
|
1209
|
+
|
|
1210
|
+
extra_headers: Send extra headers
|
|
1211
|
+
|
|
1212
|
+
extra_query: Add additional query parameters to the request
|
|
1213
|
+
|
|
1214
|
+
extra_body: Add additional JSON properties to the request
|
|
1215
|
+
|
|
1216
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1217
|
+
"""
|
|
1218
|
+
return await self._post(
|
|
1219
|
+
"/v1/tools/search",
|
|
1220
|
+
body=await async_maybe_transform(
|
|
1221
|
+
{
|
|
1222
|
+
"limit": limit,
|
|
1223
|
+
"query": query,
|
|
1224
|
+
"search_mode": search_mode,
|
|
1225
|
+
"tags": tags,
|
|
1226
|
+
"tool_types": tool_types,
|
|
1227
|
+
},
|
|
1228
|
+
tool_search_params.ToolSearchParams,
|
|
1229
|
+
),
|
|
1230
|
+
options=make_request_options(
|
|
1231
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1232
|
+
),
|
|
1233
|
+
cast_to=ToolSearchResponse,
|
|
1234
|
+
)
|
|
1235
|
+
|
|
1236
|
+
async def upsert(
|
|
1237
|
+
self,
|
|
1238
|
+
*,
|
|
1239
|
+
source_code: str,
|
|
1240
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
1241
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
1242
|
+
description: Optional[str] | Omit = omit,
|
|
1243
|
+
enable_parallel_execution: Optional[bool] | Omit = omit,
|
|
1244
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
1245
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
1246
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
1247
|
+
return_char_limit: int | Omit = omit,
|
|
1248
|
+
source_type: str | Omit = omit,
|
|
1249
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1250
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1251
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1252
|
+
extra_headers: Headers | None = None,
|
|
1253
|
+
extra_query: Query | None = None,
|
|
1254
|
+
extra_body: Body | None = None,
|
|
1255
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1256
|
+
) -> Tool:
|
|
1257
|
+
"""
|
|
1258
|
+
Create or update a tool
|
|
1259
|
+
|
|
1260
|
+
Args:
|
|
1261
|
+
source_code: The source code of the function.
|
|
1262
|
+
|
|
1263
|
+
args_json_schema: The args JSON schema of the function.
|
|
1264
|
+
|
|
1265
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
1266
|
+
|
|
1267
|
+
description: The description of the tool.
|
|
1268
|
+
|
|
1269
|
+
enable_parallel_execution: If set to True, then this tool will potentially be executed concurrently with
|
|
1270
|
+
other tools. Default False.
|
|
1271
|
+
|
|
1272
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
1273
|
+
provided)
|
|
1274
|
+
|
|
1275
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
1276
|
+
|
|
1277
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
1278
|
+
|
|
1279
|
+
return_char_limit: The maximum number of characters in the response.
|
|
1280
|
+
|
|
1281
|
+
source_type: The source type of the function.
|
|
1282
|
+
|
|
1283
|
+
tags: Metadata tags.
|
|
1284
|
+
|
|
1285
|
+
extra_headers: Send extra headers
|
|
1286
|
+
|
|
1287
|
+
extra_query: Add additional query parameters to the request
|
|
1288
|
+
|
|
1289
|
+
extra_body: Add additional JSON properties to the request
|
|
1290
|
+
|
|
1291
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1292
|
+
"""
|
|
1293
|
+
return await self._put(
|
|
1294
|
+
"/v1/tools/",
|
|
1295
|
+
body=await async_maybe_transform(
|
|
1296
|
+
{
|
|
1297
|
+
"source_code": source_code,
|
|
1298
|
+
"args_json_schema": args_json_schema,
|
|
1299
|
+
"default_requires_approval": default_requires_approval,
|
|
1300
|
+
"description": description,
|
|
1301
|
+
"enable_parallel_execution": enable_parallel_execution,
|
|
1302
|
+
"json_schema": json_schema,
|
|
1303
|
+
"npm_requirements": npm_requirements,
|
|
1304
|
+
"pip_requirements": pip_requirements,
|
|
1305
|
+
"return_char_limit": return_char_limit,
|
|
1306
|
+
"source_type": source_type,
|
|
1307
|
+
"tags": tags,
|
|
1308
|
+
},
|
|
1309
|
+
tool_upsert_params.ToolUpsertParams,
|
|
1310
|
+
),
|
|
1311
|
+
options=make_request_options(
|
|
1312
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1313
|
+
),
|
|
1314
|
+
cast_to=Tool,
|
|
1315
|
+
)
|
|
1316
|
+
|
|
1317
|
+
async def create_from_function(
|
|
1318
|
+
self,
|
|
1319
|
+
*,
|
|
1320
|
+
func: typing.Callable[..., typing.Any],
|
|
1321
|
+
args_schema: typing.Optional[typing.Type[BaseModel]] | Omit = omit,
|
|
1322
|
+
description: Optional[str] | Omit = omit,
|
|
1323
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1324
|
+
source_type: str | Omit = omit,
|
|
1325
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
1326
|
+
return_char_limit: int | Omit = omit,
|
|
1327
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
1328
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
1329
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
1330
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1331
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1332
|
+
extra_headers: Headers | None = None,
|
|
1333
|
+
extra_query: Query | None = None,
|
|
1334
|
+
extra_body: Body | None = None,
|
|
1335
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1336
|
+
) -> Tool:
|
|
1337
|
+
"""
|
|
1338
|
+
Create a new tool from a callable
|
|
1339
|
+
|
|
1340
|
+
Args:
|
|
1341
|
+
func: The callable to create the tool from.
|
|
1342
|
+
|
|
1343
|
+
args_schema: The arguments schema of the function, as a Pydantic model.
|
|
1344
|
+
|
|
1345
|
+
description: The description of the tool.
|
|
1346
|
+
|
|
1347
|
+
tags: Metadata tags.
|
|
1348
|
+
|
|
1349
|
+
source_type: The source type of the function.
|
|
1350
|
+
|
|
1351
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
1352
|
+
provided)
|
|
1353
|
+
|
|
1354
|
+
return_char_limit: The maximum number of characters in the response.
|
|
1355
|
+
|
|
1356
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
1357
|
+
|
|
1358
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
1359
|
+
|
|
1360
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
1361
|
+
|
|
1362
|
+
extra_headers: Send extra headers
|
|
1363
|
+
|
|
1364
|
+
extra_query: Add additional query parameters to the request
|
|
1365
|
+
|
|
1366
|
+
extra_body: Add additional JSON properties to the request
|
|
1367
|
+
|
|
1368
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1369
|
+
|
|
1370
|
+
Examples:
|
|
1371
|
+
from letta_client import Letta
|
|
1372
|
+
|
|
1373
|
+
client = Letta(
|
|
1374
|
+
token="YOUR_TOKEN",
|
|
1375
|
+
)
|
|
1376
|
+
|
|
1377
|
+
def add_two_numbers(a: int, b: int) -> int:
|
|
1378
|
+
return a + b
|
|
1379
|
+
|
|
1380
|
+
await client.tools.create_from_function(
|
|
1381
|
+
func=add_two_numbers,
|
|
1382
|
+
)
|
|
1383
|
+
|
|
1384
|
+
class InventoryEntryData(BaseModel):
|
|
1385
|
+
data: InventoryEntry
|
|
1386
|
+
quantity_change: int
|
|
1387
|
+
|
|
1388
|
+
def manage_inventory(data: InventoryEntry, quantity_change: int) -> bool:
|
|
1389
|
+
pass
|
|
1390
|
+
|
|
1391
|
+
await client.tools.create_from_function(
|
|
1392
|
+
func=manage_inventory,
|
|
1393
|
+
args_schema=InventoryEntryData,
|
|
1394
|
+
)
|
|
1395
|
+
"""
|
|
1396
|
+
source_code = dedent(inspect.getsource(func))
|
|
1397
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit
|
|
1398
|
+
if not isinstance(args_schema, Omit) and args_schema is not None:
|
|
1399
|
+
args_json_schema = args_schema.model_json_schema()
|
|
1400
|
+
|
|
1401
|
+
return await self.create(
|
|
1402
|
+
source_code=source_code,
|
|
1403
|
+
args_json_schema=args_json_schema,
|
|
1404
|
+
description=description,
|
|
1405
|
+
tags=tags,
|
|
1406
|
+
source_type=source_type,
|
|
1407
|
+
json_schema=json_schema,
|
|
1408
|
+
return_char_limit=return_char_limit,
|
|
1409
|
+
pip_requirements=pip_requirements,
|
|
1410
|
+
npm_requirements=npm_requirements,
|
|
1411
|
+
default_requires_approval=default_requires_approval,
|
|
1412
|
+
extra_headers=extra_headers,
|
|
1413
|
+
extra_query=extra_query,
|
|
1414
|
+
extra_body=extra_body,
|
|
1415
|
+
timeout=timeout,
|
|
1416
|
+
)
|
|
1417
|
+
|
|
1418
|
+
async def upsert_from_function(
|
|
1419
|
+
self,
|
|
1420
|
+
*,
|
|
1421
|
+
func: typing.Callable[..., typing.Any],
|
|
1422
|
+
args_schema: typing.Optional[typing.Type[BaseModel]] | Omit = omit,
|
|
1423
|
+
description: Optional[str] | Omit = omit,
|
|
1424
|
+
tags: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1425
|
+
source_type: str | Omit = omit,
|
|
1426
|
+
json_schema: Optional[Dict[str, object]] | Omit = omit,
|
|
1427
|
+
return_char_limit: int | Omit = omit,
|
|
1428
|
+
pip_requirements: Optional[Iterable[PipRequirementParam]] | Omit = omit,
|
|
1429
|
+
npm_requirements: Optional[Iterable[NpmRequirementParam]] | Omit = omit,
|
|
1430
|
+
default_requires_approval: Optional[bool] | Omit = omit,
|
|
1431
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1432
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1433
|
+
extra_headers: Headers | None = None,
|
|
1434
|
+
extra_query: Query | None = None,
|
|
1435
|
+
extra_body: Body | None = None,
|
|
1436
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1437
|
+
) -> Tool:
|
|
1438
|
+
"""
|
|
1439
|
+
Create or update a tool from a callable
|
|
1440
|
+
|
|
1441
|
+
Args:
|
|
1442
|
+
func: The callable to create or update the tool from.
|
|
1443
|
+
|
|
1444
|
+
args_schema: The arguments schema of the function, as a Pydantic model.
|
|
1445
|
+
|
|
1446
|
+
description: The description of the tool.
|
|
1447
|
+
|
|
1448
|
+
tags: Metadata tags.
|
|
1449
|
+
|
|
1450
|
+
source_type: The source type of the function.
|
|
1451
|
+
|
|
1452
|
+
json_schema: The JSON schema of the function (auto-generated from source_code if not
|
|
1453
|
+
provided)
|
|
1454
|
+
|
|
1455
|
+
return_char_limit: The maximum number of characters in the response.
|
|
1456
|
+
|
|
1457
|
+
pip_requirements: Optional list of pip packages required by this tool.
|
|
1458
|
+
|
|
1459
|
+
npm_requirements: Optional list of npm packages required by this tool.
|
|
1460
|
+
|
|
1461
|
+
default_requires_approval: Whether or not to require approval before executing this tool.
|
|
1462
|
+
|
|
1463
|
+
extra_headers: Send extra headers
|
|
1464
|
+
|
|
1465
|
+
extra_query: Add additional query parameters to the request
|
|
1466
|
+
|
|
1467
|
+
extra_body: Add additional JSON properties to the request
|
|
1468
|
+
|
|
1469
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1470
|
+
|
|
1471
|
+
Examples:
|
|
1472
|
+
from letta_client import Letta
|
|
1473
|
+
|
|
1474
|
+
client = Letta(
|
|
1475
|
+
token="YOUR_TOKEN",
|
|
1476
|
+
)
|
|
1477
|
+
|
|
1478
|
+
def add_two_numbers(a: int, b: int) -> int:
|
|
1479
|
+
return a + b
|
|
1480
|
+
|
|
1481
|
+
await client.tools.upsert_from_function(
|
|
1482
|
+
func=add_two_numbers,
|
|
1483
|
+
)
|
|
1484
|
+
|
|
1485
|
+
class InventoryEntryData(BaseModel):
|
|
1486
|
+
data: InventoryEntry
|
|
1487
|
+
quantity_change: int
|
|
1488
|
+
|
|
1489
|
+
def manage_inventory(data: InventoryEntry, quantity_change: int) -> bool:
|
|
1490
|
+
pass
|
|
1491
|
+
|
|
1492
|
+
await client.tools.upsert_from_function(
|
|
1493
|
+
func=manage_inventory,
|
|
1494
|
+
args_schema=InventoryEntryData,
|
|
1495
|
+
)
|
|
1496
|
+
"""
|
|
1497
|
+
source_code = dedent(inspect.getsource(func))
|
|
1498
|
+
args_json_schema: Optional[Dict[str, object]] | Omit = omit
|
|
1499
|
+
if not isinstance(args_schema, Omit) and args_schema is not None:
|
|
1500
|
+
args_json_schema = args_schema.model_json_schema()
|
|
1501
|
+
|
|
1502
|
+
return await self.upsert(
|
|
1503
|
+
source_code=source_code,
|
|
1504
|
+
args_json_schema=args_json_schema,
|
|
1505
|
+
description=description,
|
|
1506
|
+
tags=tags,
|
|
1507
|
+
source_type=source_type,
|
|
1508
|
+
json_schema=json_schema,
|
|
1509
|
+
return_char_limit=return_char_limit,
|
|
1510
|
+
pip_requirements=pip_requirements,
|
|
1511
|
+
npm_requirements=npm_requirements,
|
|
1512
|
+
default_requires_approval=default_requires_approval,
|
|
1513
|
+
extra_headers=extra_headers,
|
|
1514
|
+
extra_query=extra_query,
|
|
1515
|
+
extra_body=extra_body,
|
|
1516
|
+
timeout=timeout,
|
|
1517
|
+
)
|
|
1518
|
+
|
|
1519
|
+
async def add(
|
|
1520
|
+
self,
|
|
1521
|
+
*,
|
|
1522
|
+
tool: BaseTool,
|
|
1523
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1524
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1525
|
+
extra_headers: Headers | None = None,
|
|
1526
|
+
extra_query: Query | None = None,
|
|
1527
|
+
extra_body: Body | None = None,
|
|
1528
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1529
|
+
) -> Tool:
|
|
1530
|
+
"""
|
|
1531
|
+
Add a tool to Letta from a custom Tool class
|
|
1532
|
+
|
|
1533
|
+
Args:
|
|
1534
|
+
tool: The tool object to be added.
|
|
1535
|
+
|
|
1536
|
+
extra_headers: Send extra headers
|
|
1537
|
+
|
|
1538
|
+
extra_query: Add additional query parameters to the request
|
|
1539
|
+
|
|
1540
|
+
extra_body: Add additional JSON properties to the request
|
|
1541
|
+
|
|
1542
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
1543
|
+
|
|
1544
|
+
Examples:
|
|
1545
|
+
from letta_client import Letta
|
|
1546
|
+
|
|
1547
|
+
client = Letta(
|
|
1548
|
+
token="YOUR_TOKEN",
|
|
1549
|
+
)
|
|
1550
|
+
|
|
1551
|
+
class InventoryItem(BaseModel):
|
|
1552
|
+
sku: str # Unique product identifier
|
|
1553
|
+
name: str # Product name
|
|
1554
|
+
price: float # Current price
|
|
1555
|
+
category: str # Product category (e.g., "Electronics", "Clothing")
|
|
1556
|
+
|
|
1557
|
+
class InventoryEntry(BaseModel):
|
|
1558
|
+
timestamp: int # Unix timestamp of the transaction
|
|
1559
|
+
item: InventoryItem # The product being updated
|
|
1560
|
+
transaction_id: str # Unique identifier for this inventory update
|
|
1561
|
+
|
|
1562
|
+
class InventoryEntryData(BaseModel):
|
|
1563
|
+
data: InventoryEntry
|
|
1564
|
+
quantity_change: int # Change in quantity (positive for additions, negative for removals)
|
|
1565
|
+
|
|
1566
|
+
class ManageInventoryTool(BaseTool):
|
|
1567
|
+
name: str = "manage_inventory"
|
|
1568
|
+
args_schema: Type[BaseModel] = InventoryEntryData
|
|
1569
|
+
description: str = "Update inventory catalogue with a new data entry"
|
|
1570
|
+
tags: List[str] = ["inventory", "shop"]
|
|
1571
|
+
|
|
1572
|
+
def run(self, data: InventoryEntry, quantity_change: int) -> bool:
|
|
1573
|
+
'''
|
|
1574
|
+
Implementation of the manage_inventory tool
|
|
1575
|
+
'''
|
|
1576
|
+
print(f"Updated inventory for {data.item.name} with a quantity change of {quantity_change}")
|
|
1577
|
+
return True
|
|
1578
|
+
|
|
1579
|
+
await client.tools.add(
|
|
1580
|
+
tool=ManageInventoryTool()
|
|
1581
|
+
)
|
|
1582
|
+
"""
|
|
1583
|
+
source_code = tool.get_source_code()
|
|
1584
|
+
args_json_schema = tool.args_schema.model_json_schema() if tool.args_schema else None
|
|
1585
|
+
|
|
1586
|
+
# Convert PipRequirement/NpmRequirement models to Param dicts
|
|
1587
|
+
pip_requirements_param = (
|
|
1588
|
+
[typing.cast(PipRequirementParam, req.model_dump()) for req in tool.pip_requirements]
|
|
1589
|
+
if tool.pip_requirements
|
|
1590
|
+
else omit
|
|
1591
|
+
)
|
|
1592
|
+
npm_requirements_param = (
|
|
1593
|
+
[typing.cast(NpmRequirementParam, req.model_dump()) for req in tool.npm_requirements]
|
|
1594
|
+
if tool.npm_requirements
|
|
1595
|
+
else omit
|
|
1596
|
+
)
|
|
1597
|
+
|
|
1598
|
+
return await self.upsert(
|
|
1599
|
+
source_code=source_code,
|
|
1600
|
+
args_json_schema=args_json_schema or omit,
|
|
1601
|
+
description=tool.description or omit,
|
|
1602
|
+
tags=tool.tags or omit,
|
|
1603
|
+
source_type=tool.source_type or omit,
|
|
1604
|
+
json_schema=tool.json_schema or omit,
|
|
1605
|
+
return_char_limit=tool.return_char_limit or omit,
|
|
1606
|
+
pip_requirements=pip_requirements_param,
|
|
1607
|
+
npm_requirements=npm_requirements_param,
|
|
1608
|
+
default_requires_approval=tool.default_requires_approval or omit,
|
|
1609
|
+
extra_headers=extra_headers,
|
|
1610
|
+
extra_query=extra_query,
|
|
1611
|
+
extra_body=extra_body,
|
|
1612
|
+
timeout=timeout,
|
|
1613
|
+
)
|
|
1614
|
+
|
|
1615
|
+
|
|
1616
|
+
class ToolsResourceWithRawResponse:
|
|
1617
|
+
def __init__(self, tools: ToolsResource) -> None:
|
|
1618
|
+
self._tools = tools
|
|
1619
|
+
|
|
1620
|
+
self.create = to_raw_response_wrapper(
|
|
1621
|
+
tools.create,
|
|
1622
|
+
)
|
|
1623
|
+
self.retrieve = to_raw_response_wrapper(
|
|
1624
|
+
tools.retrieve,
|
|
1625
|
+
)
|
|
1626
|
+
self.update = to_raw_response_wrapper(
|
|
1627
|
+
tools.update,
|
|
1628
|
+
)
|
|
1629
|
+
self.list = to_raw_response_wrapper(
|
|
1630
|
+
tools.list,
|
|
1631
|
+
)
|
|
1632
|
+
self.delete = to_raw_response_wrapper(
|
|
1633
|
+
tools.delete,
|
|
1634
|
+
)
|
|
1635
|
+
self.search = to_raw_response_wrapper(
|
|
1636
|
+
tools.search,
|
|
1637
|
+
)
|
|
1638
|
+
self.upsert = to_raw_response_wrapper(
|
|
1639
|
+
tools.upsert,
|
|
1640
|
+
)
|
|
1641
|
+
|
|
1642
|
+
|
|
1643
|
+
class AsyncToolsResourceWithRawResponse:
|
|
1644
|
+
def __init__(self, tools: AsyncToolsResource) -> None:
|
|
1645
|
+
self._tools = tools
|
|
1646
|
+
|
|
1647
|
+
self.create = async_to_raw_response_wrapper(
|
|
1648
|
+
tools.create,
|
|
1649
|
+
)
|
|
1650
|
+
self.retrieve = async_to_raw_response_wrapper(
|
|
1651
|
+
tools.retrieve,
|
|
1652
|
+
)
|
|
1653
|
+
self.update = async_to_raw_response_wrapper(
|
|
1654
|
+
tools.update,
|
|
1655
|
+
)
|
|
1656
|
+
self.list = async_to_raw_response_wrapper(
|
|
1657
|
+
tools.list,
|
|
1658
|
+
)
|
|
1659
|
+
self.delete = async_to_raw_response_wrapper(
|
|
1660
|
+
tools.delete,
|
|
1661
|
+
)
|
|
1662
|
+
self.search = async_to_raw_response_wrapper(
|
|
1663
|
+
tools.search,
|
|
1664
|
+
)
|
|
1665
|
+
self.upsert = async_to_raw_response_wrapper(
|
|
1666
|
+
tools.upsert,
|
|
1667
|
+
)
|
|
1668
|
+
|
|
1669
|
+
|
|
1670
|
+
class ToolsResourceWithStreamingResponse:
|
|
1671
|
+
def __init__(self, tools: ToolsResource) -> None:
|
|
1672
|
+
self._tools = tools
|
|
1673
|
+
|
|
1674
|
+
self.create = to_streamed_response_wrapper(
|
|
1675
|
+
tools.create,
|
|
1676
|
+
)
|
|
1677
|
+
self.retrieve = to_streamed_response_wrapper(
|
|
1678
|
+
tools.retrieve,
|
|
1679
|
+
)
|
|
1680
|
+
self.update = to_streamed_response_wrapper(
|
|
1681
|
+
tools.update,
|
|
1682
|
+
)
|
|
1683
|
+
self.list = to_streamed_response_wrapper(
|
|
1684
|
+
tools.list,
|
|
1685
|
+
)
|
|
1686
|
+
self.delete = to_streamed_response_wrapper(
|
|
1687
|
+
tools.delete,
|
|
1688
|
+
)
|
|
1689
|
+
self.search = to_streamed_response_wrapper(
|
|
1690
|
+
tools.search,
|
|
1691
|
+
)
|
|
1692
|
+
self.upsert = to_streamed_response_wrapper(
|
|
1693
|
+
tools.upsert,
|
|
1694
|
+
)
|
|
1695
|
+
|
|
1696
|
+
|
|
1697
|
+
class AsyncToolsResourceWithStreamingResponse:
|
|
1698
|
+
def __init__(self, tools: AsyncToolsResource) -> None:
|
|
1699
|
+
self._tools = tools
|
|
1700
|
+
|
|
1701
|
+
self.create = async_to_streamed_response_wrapper(
|
|
1702
|
+
tools.create,
|
|
1703
|
+
)
|
|
1704
|
+
self.retrieve = async_to_streamed_response_wrapper(
|
|
1705
|
+
tools.retrieve,
|
|
1706
|
+
)
|
|
1707
|
+
self.update = async_to_streamed_response_wrapper(
|
|
1708
|
+
tools.update,
|
|
1709
|
+
)
|
|
1710
|
+
self.list = async_to_streamed_response_wrapper(
|
|
1711
|
+
tools.list,
|
|
1712
|
+
)
|
|
1713
|
+
self.delete = async_to_streamed_response_wrapper(
|
|
1714
|
+
tools.delete,
|
|
1715
|
+
)
|
|
1716
|
+
self.search = async_to_streamed_response_wrapper(
|
|
1717
|
+
tools.search,
|
|
1718
|
+
)
|
|
1719
|
+
self.upsert = async_to_streamed_response_wrapper(
|
|
1720
|
+
tools.upsert,
|
|
1721
|
+
)
|