letta-nightly 0.6.23.dev20250211104055__tar.gz → 0.6.24.dev20250212072610__tar.gz
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.
Potentially problematic release.
This version of letta-nightly might be problematic. Click here for more details.
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/PKG-INFO +2 -1
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/__init__.py +1 -2
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/agent.py +11 -7
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/cli/cli.py +3 -2
- letta_nightly-0.6.24.dev20250212072610/letta/client/streaming.py +94 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/constants.py +0 -3
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/embeddings.py +30 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/anthropic.py +73 -8
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/llm_api_tools.py +17 -11
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/openai.py +6 -5
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/llm_config.py +5 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/message.py +20 -4
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/providers.py +10 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/chat_completions_interface.py +39 -30
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/interface.py +51 -28
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/health.py +2 -2
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/utils.py +13 -2
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/agent_manager.py +6 -6
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/settings.py +1 -1
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/pyproject.toml +2 -1
- letta_nightly-0.6.23.dev20250211104055/letta/client/streaming.py +0 -99
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/LICENSE +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/README.md +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/__main__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/benchmark/benchmark.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/benchmark/constants.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/chat_only_agent.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/cli/cli_config.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/cli/cli_load.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/client/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/client/client.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/client/utils.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/config.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/data_sources/connectors.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/data_sources/connectors_helper.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/errors.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/ast_parsers.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/function_sets/base.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/function_sets/extras.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/function_sets/multi_agent.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/functions.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/helpers.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/interface.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/functions/schema_generator.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/helpers/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/helpers/tool_rule_solver.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/humans/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/humans/examples/basic.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/humans/examples/cs_phd.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/interface.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/aws_bedrock.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/azure_openai.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/azure_openai_constants.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/cohere.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/google_ai.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/helpers.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/llm_api/mistral.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/README.md +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/chat_completion_proxy.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/constants.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/function_parser.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/grammars/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/grammars/gbnf_grammar_generator.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/grammars/json.gbnf +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/grammars/json_func_calls_with_inner_thoughts.gbnf +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/json_parser.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/koboldcpp/api.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/koboldcpp/settings.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llamacpp/api.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llamacpp/settings.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/airoboros.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/chatml.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/dolphin.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/llama3.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/wrapper_base.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/llm_chat_completion_wrappers/zephyr.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/lmstudio/api.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/lmstudio/settings.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/ollama/api.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/ollama/settings.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/settings/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/settings/deterministic_mirostat.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/settings/settings.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/settings/simple.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/utils.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/vllm/api.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/webui/api.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/webui/legacy_api.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/webui/legacy_settings.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/local_llm/webui/settings.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/log.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/main.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/memory.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/offline_memory_agent.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/openai_backcompat/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/openai_backcompat/openai_object.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/__all__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/agent.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/agents_tags.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/base.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/block.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/blocks_agents.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/custom_columns.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/enums.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/errors.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/file.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/job.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/job_messages.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/message.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/mixins.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/organization.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/passage.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/provider.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/sandbox_config.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/source.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/sources_agents.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/sqlalchemy_base.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/sqlite_functions.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/step.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/tool.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/tools_agents.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/orm/user.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/anna_pa.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/google_search_persona.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/memgpt_doc.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/memgpt_starter.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/o1_persona.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/offline_memory_persona.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/sam.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/sam_pov.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/sam_simple_pov_gpt35.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/personas/examples/sqldb/test.db +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/gpt_summarize.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/gpt_system.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_base.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_chat.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_chat_compressed.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_chat_fstring.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_convo_only.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_doc.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_gpt35_extralong.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_intuitive_knowledge.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_modified_chat.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_modified_o1.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_offline_memory.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/prompts/system/memgpt_offline_memory_chat.txt +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/pytest.ini +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/agent.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/block.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/embedding_config.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/embedding_config_overrides.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/enums.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/environment_variables.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/file.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/health.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/job.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/letta_base.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/letta_message.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/letta_request.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/letta_response.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/llm_config_overrides.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/memory.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/openai/chat_completion_request.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/openai/chat_completion_response.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/openai/chat_completions.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/openai/embedding_response.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/openai/openai.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/organization.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/passage.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/run.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/sandbox_config.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/source.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/step.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/tool.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/tool_rule.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/usage.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/schemas/user.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/constants.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/generate_openapi_schema.sh +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/app.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/auth/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/auth/index.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/auth_token.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/optimistic_json_parser.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/openai/chat_completions/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/openai/chat_completions/chat_completions.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/agents.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/blocks.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/jobs.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/llms.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/organizations.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/providers.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/runs.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/sandbox_configs.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/sources.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/steps.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/tags.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/tools.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/routers/v1/users.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/rest_api/static_files.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/server.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/startup.sh +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/static_files/assets/index-048c9598.js +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/static_files/assets/index-0e31b727.css +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/static_files/favicon.ico +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/static_files/index.html +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/static_files/memgpt_logo_transparent.png +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/utils.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/ws_api/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/ws_api/example_client.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/ws_api/interface.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/ws_api/protocol.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/server/ws_api/server.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/__init__.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/block_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/helpers/agent_manager_helper.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/helpers/tool_execution_helper.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/job_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/message_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/organization_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/passage_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/per_agent_lock_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/provider_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/sandbox_config_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/source_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/step_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/tool_execution_sandbox.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/tool_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/services/user_manager.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/streaming_interface.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/streaming_utils.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/system.py +0 -0
- {letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: letta-nightly
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.24.dev20250212072610
|
|
4
4
|
Summary: Create LLM agents with long-term memory and custom tools
|
|
5
5
|
License: Apache License
|
|
6
6
|
Author: Letta Team
|
|
@@ -34,6 +34,7 @@ Requires-Dist: docker (>=7.1.0,<8.0.0) ; extra == "external-tools" or extra == "
|
|
|
34
34
|
Requires-Dist: docstring-parser (>=0.16,<0.17)
|
|
35
35
|
Requires-Dist: docx2txt (>=0.8,<0.9)
|
|
36
36
|
Requires-Dist: e2b-code-interpreter (>=1.0.3,<2.0.0) ; extra == "cloud-tool-sandbox"
|
|
37
|
+
Requires-Dist: faker (>=36.1.0,<37.0.0)
|
|
37
38
|
Requires-Dist: fastapi (>=0.115.6,<0.116.0) ; extra == "server" or extra == "all"
|
|
38
39
|
Requires-Dist: grpcio (>=1.68.1,<2.0.0)
|
|
39
40
|
Requires-Dist: grpcio-tools (>=1.68.1,<2.0.0)
|
{letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/agent.py
RENAMED
|
@@ -260,6 +260,7 @@ class Agent(BaseAgent):
|
|
|
260
260
|
error_msg: str,
|
|
261
261
|
tool_call_id: str,
|
|
262
262
|
function_name: str,
|
|
263
|
+
function_args: dict,
|
|
263
264
|
function_response: str,
|
|
264
265
|
messages: List[Message],
|
|
265
266
|
include_function_failed_message: bool = False,
|
|
@@ -394,6 +395,7 @@ class Agent(BaseAgent):
|
|
|
394
395
|
|
|
395
396
|
messages = [] # append these to the history when done
|
|
396
397
|
function_name = None
|
|
398
|
+
function_args = {}
|
|
397
399
|
|
|
398
400
|
# Step 2: check if LLM wanted to call a function
|
|
399
401
|
if response_message.function_call or (response_message.tool_calls is not None and len(response_message.tool_calls) > 0):
|
|
@@ -445,8 +447,6 @@ class Agent(BaseAgent):
|
|
|
445
447
|
function_call = (
|
|
446
448
|
response_message.function_call if response_message.function_call is not None else response_message.tool_calls[0].function
|
|
447
449
|
)
|
|
448
|
-
|
|
449
|
-
# Get the name of the function
|
|
450
450
|
function_name = function_call.name
|
|
451
451
|
self.logger.info(f"Request to call function {function_name} with tool_call_id: {tool_call_id}")
|
|
452
452
|
|
|
@@ -459,7 +459,9 @@ class Agent(BaseAgent):
|
|
|
459
459
|
if not target_letta_tool:
|
|
460
460
|
error_msg = f"No function named {function_name}"
|
|
461
461
|
function_response = "None" # more like "never ran?"
|
|
462
|
-
messages = self._handle_function_error_response(
|
|
462
|
+
messages = self._handle_function_error_response(
|
|
463
|
+
error_msg, tool_call_id, function_name, function_args, function_response, messages
|
|
464
|
+
)
|
|
463
465
|
return messages, False, True # force a heartbeat to allow agent to handle error
|
|
464
466
|
|
|
465
467
|
# Failure case 2: function name is OK, but function args are bad JSON
|
|
@@ -469,7 +471,9 @@ class Agent(BaseAgent):
|
|
|
469
471
|
except Exception:
|
|
470
472
|
error_msg = f"Error parsing JSON for function '{function_name}' arguments: {function_call.arguments}"
|
|
471
473
|
function_response = "None" # more like "never ran?"
|
|
472
|
-
messages = self._handle_function_error_response(
|
|
474
|
+
messages = self._handle_function_error_response(
|
|
475
|
+
error_msg, tool_call_id, function_name, function_args, function_response, messages
|
|
476
|
+
)
|
|
473
477
|
return messages, False, True # force a heartbeat to allow agent to handle error
|
|
474
478
|
|
|
475
479
|
# Check if inner thoughts is in the function call arguments (possible apparently if you are using Azure)
|
|
@@ -506,7 +510,7 @@ class Agent(BaseAgent):
|
|
|
506
510
|
|
|
507
511
|
if sandbox_run_result and sandbox_run_result.status == "error":
|
|
508
512
|
messages = self._handle_function_error_response(
|
|
509
|
-
function_response, tool_call_id, function_name, function_response, messages
|
|
513
|
+
function_response, tool_call_id, function_name, function_args, function_response, messages
|
|
510
514
|
)
|
|
511
515
|
return messages, False, True # force a heartbeat to allow agent to handle error
|
|
512
516
|
|
|
@@ -535,7 +539,7 @@ class Agent(BaseAgent):
|
|
|
535
539
|
error_msg_user = f"{error_msg}\n{traceback.format_exc()}"
|
|
536
540
|
self.logger.error(error_msg_user)
|
|
537
541
|
messages = self._handle_function_error_response(
|
|
538
|
-
error_msg, tool_call_id, function_name, function_response, messages, include_function_failed_message=True
|
|
542
|
+
error_msg, tool_call_id, function_name, function_args, function_response, messages, include_function_failed_message=True
|
|
539
543
|
)
|
|
540
544
|
return messages, False, True # force a heartbeat to allow agent to handle error
|
|
541
545
|
|
|
@@ -543,7 +547,7 @@ class Agent(BaseAgent):
|
|
|
543
547
|
if function_response_string.startswith(ERROR_MESSAGE_PREFIX):
|
|
544
548
|
error_msg = function_response_string
|
|
545
549
|
messages = self._handle_function_error_response(
|
|
546
|
-
error_msg, tool_call_id, function_name, function_response, messages, include_function_failed_message=True
|
|
550
|
+
error_msg, tool_call_id, function_name, function_args, function_response, messages, include_function_failed_message=True
|
|
547
551
|
)
|
|
548
552
|
return messages, False, True # force a heartbeat to allow agent to handle error
|
|
549
553
|
|
{letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/cli/cli.py
RENAMED
|
@@ -15,7 +15,6 @@ from letta.local_llm.constants import ASSISTANT_MESSAGE_CLI_SYMBOL
|
|
|
15
15
|
from letta.log import get_logger
|
|
16
16
|
from letta.schemas.enums import OptionState
|
|
17
17
|
from letta.schemas.memory import ChatMemory, Memory
|
|
18
|
-
from letta.server.server import logger as server_logger
|
|
19
18
|
|
|
20
19
|
# from letta.interface import CLIInterface as interface # for printing to terminal
|
|
21
20
|
from letta.streaming_interface import StreamingRefreshCLIInterface as interface # for printing to terminal
|
|
@@ -119,6 +118,8 @@ def run(
|
|
|
119
118
|
utils.DEBUG = debug
|
|
120
119
|
# TODO: add logging command line options for runtime log level
|
|
121
120
|
|
|
121
|
+
from letta.server.server import logger as server_logger
|
|
122
|
+
|
|
122
123
|
if debug:
|
|
123
124
|
logger.setLevel(logging.DEBUG)
|
|
124
125
|
server_logger.setLevel(logging.DEBUG)
|
|
@@ -360,4 +361,4 @@ def delete_agent(
|
|
|
360
361
|
def version() -> str:
|
|
361
362
|
import letta
|
|
362
363
|
|
|
363
|
-
|
|
364
|
+
print(letta.__version__)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import Generator, Union, get_args
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
from httpx_sse import SSEError, connect_sse
|
|
6
|
+
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk
|
|
7
|
+
|
|
8
|
+
from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING
|
|
9
|
+
from letta.errors import LLMError
|
|
10
|
+
from letta.log import get_logger
|
|
11
|
+
from letta.schemas.enums import MessageStreamStatus
|
|
12
|
+
from letta.schemas.letta_message import AssistantMessage, ReasoningMessage, ToolCallMessage, ToolReturnMessage
|
|
13
|
+
from letta.schemas.letta_response import LettaStreamingResponse
|
|
14
|
+
from letta.schemas.usage import LettaUsageStatistics
|
|
15
|
+
|
|
16
|
+
logger = get_logger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _sse_post(url: str, data: dict, headers: dict) -> Generator[Union[LettaStreamingResponse, ChatCompletionChunk], None, None]:
|
|
20
|
+
"""
|
|
21
|
+
Sends an SSE POST request and yields parsed response chunks.
|
|
22
|
+
"""
|
|
23
|
+
# TODO: Please note his is a very generous timeout for e2b reasons
|
|
24
|
+
with httpx.Client(timeout=httpx.Timeout(5 * 60.0, read=5 * 60.0)) as client:
|
|
25
|
+
with connect_sse(client, method="POST", url=url, json=data, headers=headers) as event_source:
|
|
26
|
+
|
|
27
|
+
# Check for immediate HTTP errors before processing the SSE stream
|
|
28
|
+
if not event_source.response.is_success:
|
|
29
|
+
response_bytes = event_source.response.read()
|
|
30
|
+
logger.warning(f"SSE request error: {vars(event_source.response)}")
|
|
31
|
+
logger.warning(response_bytes.decode("utf-8"))
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
response_dict = json.loads(response_bytes.decode("utf-8"))
|
|
35
|
+
error_message = response_dict.get("error", {}).get("message", "")
|
|
36
|
+
|
|
37
|
+
if OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING in error_message:
|
|
38
|
+
logger.error(error_message)
|
|
39
|
+
raise LLMError(error_message)
|
|
40
|
+
except LLMError:
|
|
41
|
+
raise
|
|
42
|
+
except Exception:
|
|
43
|
+
logger.error("Failed to parse SSE message, raising HTTP error")
|
|
44
|
+
event_source.response.raise_for_status()
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
for sse in event_source.iter_sse():
|
|
48
|
+
if sse.data in {status.value for status in MessageStreamStatus}:
|
|
49
|
+
yield MessageStreamStatus(sse.data)
|
|
50
|
+
if sse.data == MessageStreamStatus.done.value:
|
|
51
|
+
# We received the [DONE], so stop reading the stream.
|
|
52
|
+
break
|
|
53
|
+
else:
|
|
54
|
+
chunk_data = json.loads(sse.data)
|
|
55
|
+
|
|
56
|
+
if "reasoning" in chunk_data:
|
|
57
|
+
yield ReasoningMessage(**chunk_data)
|
|
58
|
+
elif chunk_data.get("message_type") == "assistant_message":
|
|
59
|
+
yield AssistantMessage(**chunk_data)
|
|
60
|
+
elif "tool_call" in chunk_data:
|
|
61
|
+
yield ToolCallMessage(**chunk_data)
|
|
62
|
+
elif "tool_return" in chunk_data:
|
|
63
|
+
yield ToolReturnMessage(**chunk_data)
|
|
64
|
+
elif "step_count" in chunk_data:
|
|
65
|
+
yield LettaUsageStatistics(**chunk_data)
|
|
66
|
+
elif chunk_data.get("object") == get_args(ChatCompletionChunk.__annotations__["object"])[0]:
|
|
67
|
+
yield ChatCompletionChunk(**chunk_data)
|
|
68
|
+
else:
|
|
69
|
+
raise ValueError(f"Unknown message type in chunk_data: {chunk_data}")
|
|
70
|
+
|
|
71
|
+
except SSEError as e:
|
|
72
|
+
logger.error(f"SSE stream error: {e}")
|
|
73
|
+
|
|
74
|
+
if "application/json" in str(e):
|
|
75
|
+
response = client.post(url=url, json=data, headers=headers)
|
|
76
|
+
|
|
77
|
+
if response.headers.get("Content-Type", "").startswith("application/json"):
|
|
78
|
+
error_details = response.json()
|
|
79
|
+
logger.error(f"POST Error: {error_details}")
|
|
80
|
+
else:
|
|
81
|
+
logger.error("Failed to retrieve JSON error message via retry.")
|
|
82
|
+
|
|
83
|
+
raise e
|
|
84
|
+
|
|
85
|
+
except Exception as e:
|
|
86
|
+
logger.error(f"Unexpected exception: {e}")
|
|
87
|
+
|
|
88
|
+
if event_source.response.request:
|
|
89
|
+
logger.error(f"HTTP Request: {vars(event_source.response.request)}")
|
|
90
|
+
if event_source.response:
|
|
91
|
+
logger.error(f"HTTP Status: {event_source.response.status_code}")
|
|
92
|
+
logger.error(f"HTTP Headers: {event_source.response.headers}")
|
|
93
|
+
|
|
94
|
+
raise e
|
{letta_nightly-0.6.23.dev20250211104055 → letta_nightly-0.6.24.dev20250212072610}/letta/constants.py
RENAMED
|
@@ -51,9 +51,6 @@ BASE_TOOLS = ["send_message", "conversation_search", "archival_memory_insert", "
|
|
|
51
51
|
BASE_MEMORY_TOOLS = ["core_memory_append", "core_memory_replace"]
|
|
52
52
|
# Multi agent tools
|
|
53
53
|
MULTI_AGENT_TOOLS = ["send_message_to_agent_and_wait_for_reply", "send_message_to_agents_matching_all_tags", "send_message_to_agent_async"]
|
|
54
|
-
MULTI_AGENT_SEND_MESSAGE_MAX_RETRIES = 3
|
|
55
|
-
MULTI_AGENT_SEND_MESSAGE_TIMEOUT = 20 * 60
|
|
56
|
-
MULTI_AGENT_CONCURRENT_SENDS = 15
|
|
57
54
|
|
|
58
55
|
# The name of the tool used to send message to the user
|
|
59
56
|
# May not be relevant in cases where the agent has multiple ways to message to user (send_imessage, send_discord_mesasge, ...)
|
|
@@ -167,6 +167,27 @@ class OllamaEmbeddings:
|
|
|
167
167
|
return response_json["embedding"]
|
|
168
168
|
|
|
169
169
|
|
|
170
|
+
class GoogleEmbeddings:
|
|
171
|
+
def __init__(self, api_key: str, model: str, base_url: str):
|
|
172
|
+
self.api_key = api_key
|
|
173
|
+
self.model = model
|
|
174
|
+
self.base_url = base_url # Expected to be "https://generativelanguage.googleapis.com"
|
|
175
|
+
|
|
176
|
+
def get_text_embedding(self, text: str):
|
|
177
|
+
import httpx
|
|
178
|
+
|
|
179
|
+
headers = {"Content-Type": "application/json"}
|
|
180
|
+
# Build the URL based on the provided base_url, model, and API key.
|
|
181
|
+
url = f"{self.base_url}/v1beta/models/{self.model}:embedContent?key={self.api_key}"
|
|
182
|
+
payload = {"model": self.model, "content": {"parts": [{"text": text}]}}
|
|
183
|
+
with httpx.Client() as client:
|
|
184
|
+
response = client.post(url, headers=headers, json=payload)
|
|
185
|
+
# Raise an error for non-success HTTP status codes.
|
|
186
|
+
response.raise_for_status()
|
|
187
|
+
response_json = response.json()
|
|
188
|
+
return response_json["embedding"]["values"]
|
|
189
|
+
|
|
190
|
+
|
|
170
191
|
def query_embedding(embedding_model, query_text: str):
|
|
171
192
|
"""Generate padded embedding for querying database"""
|
|
172
193
|
query_vec = embedding_model.get_text_embedding(query_text)
|
|
@@ -237,5 +258,14 @@ def embedding_model(config: EmbeddingConfig, user_id: Optional[uuid.UUID] = None
|
|
|
237
258
|
)
|
|
238
259
|
return model
|
|
239
260
|
|
|
261
|
+
elif endpoint_type == "google_ai":
|
|
262
|
+
assert all([model_settings.gemini_api_key is not None, model_settings.gemini_base_url is not None])
|
|
263
|
+
model = GoogleEmbeddings(
|
|
264
|
+
model=config.embedding_model,
|
|
265
|
+
api_key=model_settings.gemini_api_key,
|
|
266
|
+
base_url=model_settings.gemini_base_url,
|
|
267
|
+
)
|
|
268
|
+
return model
|
|
269
|
+
|
|
240
270
|
else:
|
|
241
271
|
raise ValueError(f"Unknown endpoint type {endpoint_type}")
|
|
@@ -19,6 +19,8 @@ from anthropic.types.beta import (
|
|
|
19
19
|
|
|
20
20
|
from letta.errors import BedrockError, BedrockPermissionError
|
|
21
21
|
from letta.llm_api.aws_bedrock import get_bedrock_client
|
|
22
|
+
from letta.llm_api.helpers import add_inner_thoughts_to_functions
|
|
23
|
+
from letta.local_llm.constants import INNER_THOUGHTS_KWARG, INNER_THOUGHTS_KWARG_DESCRIPTION
|
|
22
24
|
from letta.local_llm.utils import num_tokens_from_functions, num_tokens_from_messages
|
|
23
25
|
from letta.schemas.message import Message as _Message
|
|
24
26
|
from letta.schemas.message import MessageRole as _MessageRole
|
|
@@ -513,9 +515,23 @@ def convert_anthropic_stream_event_to_chatcompletion(
|
|
|
513
515
|
def _prepare_anthropic_request(
|
|
514
516
|
data: ChatCompletionRequest,
|
|
515
517
|
inner_thoughts_xml_tag: Optional[str] = "thinking",
|
|
518
|
+
# if true, prefix fill the generation with the thinking tag
|
|
519
|
+
prefix_fill: bool = True,
|
|
520
|
+
# if true, put COT inside the tool calls instead of inside the content
|
|
521
|
+
put_inner_thoughts_in_kwargs: bool = False,
|
|
516
522
|
) -> dict:
|
|
517
523
|
"""Prepare the request data for Anthropic API format."""
|
|
518
|
-
|
|
524
|
+
|
|
525
|
+
# if needed, put inner thoughts as a kwarg for all tools
|
|
526
|
+
if data.tools and put_inner_thoughts_in_kwargs:
|
|
527
|
+
functions = add_inner_thoughts_to_functions(
|
|
528
|
+
functions=[t.function.model_dump() for t in data.tools],
|
|
529
|
+
inner_thoughts_key=INNER_THOUGHTS_KWARG,
|
|
530
|
+
inner_thoughts_description=INNER_THOUGHTS_KWARG_DESCRIPTION,
|
|
531
|
+
)
|
|
532
|
+
data.tools = [Tool(function=f) for f in functions]
|
|
533
|
+
|
|
534
|
+
# convert the tools to Anthropic's payload format
|
|
519
535
|
anthropic_tools = None if data.tools is None else convert_tools_to_anthropic_format(data.tools)
|
|
520
536
|
|
|
521
537
|
# pydantic -> dict
|
|
@@ -529,11 +545,25 @@ def _prepare_anthropic_request(
|
|
|
529
545
|
data.pop("tools")
|
|
530
546
|
data.pop("tool_choice", None)
|
|
531
547
|
elif anthropic_tools is not None:
|
|
548
|
+
# TODO eventually enable parallel tool use
|
|
532
549
|
data["tools"] = anthropic_tools
|
|
533
|
-
|
|
550
|
+
|
|
551
|
+
# tool_choice_type other than "auto" only plays nice if thinking goes inside the tool calls
|
|
552
|
+
if put_inner_thoughts_in_kwargs:
|
|
553
|
+
if len(anthropic_tools) == 1:
|
|
554
|
+
data["tool_choice"] = {
|
|
555
|
+
"type": "tool",
|
|
556
|
+
"name": anthropic_tools[0]["name"],
|
|
557
|
+
"disable_parallel_tool_use": True,
|
|
558
|
+
}
|
|
559
|
+
else:
|
|
560
|
+
data["tool_choice"] = {
|
|
561
|
+
"type": "any",
|
|
562
|
+
"disable_parallel_tool_use": True,
|
|
563
|
+
}
|
|
564
|
+
else:
|
|
534
565
|
data["tool_choice"] = {
|
|
535
|
-
"type": "
|
|
536
|
-
"name": anthropic_tools[0]["name"],
|
|
566
|
+
"type": "auto",
|
|
537
567
|
"disable_parallel_tool_use": True,
|
|
538
568
|
}
|
|
539
569
|
|
|
@@ -548,8 +578,21 @@ def _prepare_anthropic_request(
|
|
|
548
578
|
message["content"] = None
|
|
549
579
|
|
|
550
580
|
# Convert to Anthropic format
|
|
551
|
-
msg_objs = [
|
|
552
|
-
|
|
581
|
+
msg_objs = [
|
|
582
|
+
_Message.dict_to_message(
|
|
583
|
+
user_id=None,
|
|
584
|
+
agent_id=None,
|
|
585
|
+
openai_message_dict=m,
|
|
586
|
+
)
|
|
587
|
+
for m in data["messages"]
|
|
588
|
+
]
|
|
589
|
+
data["messages"] = [
|
|
590
|
+
m.to_anthropic_dict(
|
|
591
|
+
inner_thoughts_xml_tag=inner_thoughts_xml_tag,
|
|
592
|
+
put_inner_thoughts_in_kwargs=put_inner_thoughts_in_kwargs,
|
|
593
|
+
)
|
|
594
|
+
for m in msg_objs
|
|
595
|
+
]
|
|
553
596
|
|
|
554
597
|
# Ensure first message is user
|
|
555
598
|
if data["messages"][0]["role"] != "user":
|
|
@@ -558,6 +601,16 @@ def _prepare_anthropic_request(
|
|
|
558
601
|
# Handle alternating messages
|
|
559
602
|
data["messages"] = merge_tool_results_into_user_messages(data["messages"])
|
|
560
603
|
|
|
604
|
+
# Handle prefix fill (not compatible with inner-thouguhts-in-kwargs)
|
|
605
|
+
# https://docs.anthropic.com/en/api/messages#body-messages
|
|
606
|
+
# NOTE: cannot prefill with tools for opus:
|
|
607
|
+
# Your API request included an `assistant` message in the final position, which would pre-fill the `assistant` response. When using tools with "claude-3-opus-20240229"
|
|
608
|
+
if prefix_fill and not put_inner_thoughts_in_kwargs and "opus" not in data["model"]:
|
|
609
|
+
data["messages"].append(
|
|
610
|
+
# Start the thinking process for the assistant
|
|
611
|
+
{"role": "assistant", "content": f"<{inner_thoughts_xml_tag}>"},
|
|
612
|
+
)
|
|
613
|
+
|
|
561
614
|
# Validate max_tokens
|
|
562
615
|
assert "max_tokens" in data, data
|
|
563
616
|
|
|
@@ -571,6 +624,7 @@ def _prepare_anthropic_request(
|
|
|
571
624
|
def anthropic_chat_completions_request(
|
|
572
625
|
data: ChatCompletionRequest,
|
|
573
626
|
inner_thoughts_xml_tag: Optional[str] = "thinking",
|
|
627
|
+
put_inner_thoughts_in_kwargs: bool = False,
|
|
574
628
|
betas: List[str] = ["tools-2024-04-04"],
|
|
575
629
|
) -> ChatCompletionResponse:
|
|
576
630
|
"""https://docs.anthropic.com/claude/docs/tool-use"""
|
|
@@ -580,7 +634,11 @@ def anthropic_chat_completions_request(
|
|
|
580
634
|
anthropic_client = anthropic.Anthropic(api_key=anthropic_override_key)
|
|
581
635
|
elif model_settings.anthropic_api_key:
|
|
582
636
|
anthropic_client = anthropic.Anthropic()
|
|
583
|
-
data = _prepare_anthropic_request(
|
|
637
|
+
data = _prepare_anthropic_request(
|
|
638
|
+
data=data,
|
|
639
|
+
inner_thoughts_xml_tag=inner_thoughts_xml_tag,
|
|
640
|
+
put_inner_thoughts_in_kwargs=put_inner_thoughts_in_kwargs,
|
|
641
|
+
)
|
|
584
642
|
response = anthropic_client.beta.messages.create(
|
|
585
643
|
**data,
|
|
586
644
|
betas=betas,
|
|
@@ -611,6 +669,7 @@ def anthropic_bedrock_chat_completions_request(
|
|
|
611
669
|
def anthropic_chat_completions_request_stream(
|
|
612
670
|
data: ChatCompletionRequest,
|
|
613
671
|
inner_thoughts_xml_tag: Optional[str] = "thinking",
|
|
672
|
+
put_inner_thoughts_in_kwargs: bool = False,
|
|
614
673
|
betas: List[str] = ["tools-2024-04-04"],
|
|
615
674
|
) -> Generator[ChatCompletionChunkResponse, None, None]:
|
|
616
675
|
"""Stream chat completions from Anthropic API.
|
|
@@ -618,7 +677,11 @@ def anthropic_chat_completions_request_stream(
|
|
|
618
677
|
Similar to OpenAI's streaming, but using Anthropic's native streaming support.
|
|
619
678
|
See: https://docs.anthropic.com/claude/reference/messages-streaming
|
|
620
679
|
"""
|
|
621
|
-
data = _prepare_anthropic_request(
|
|
680
|
+
data = _prepare_anthropic_request(
|
|
681
|
+
data=data,
|
|
682
|
+
inner_thoughts_xml_tag=inner_thoughts_xml_tag,
|
|
683
|
+
put_inner_thoughts_in_kwargs=put_inner_thoughts_in_kwargs,
|
|
684
|
+
)
|
|
622
685
|
|
|
623
686
|
anthropic_override_key = ProviderManager().get_anthropic_override_key()
|
|
624
687
|
if anthropic_override_key:
|
|
@@ -666,6 +729,7 @@ def anthropic_chat_completions_process_stream(
|
|
|
666
729
|
chat_completion_request: ChatCompletionRequest,
|
|
667
730
|
stream_interface: Optional[Union[AgentChunkStreamingInterface, AgentRefreshStreamingInterface]] = None,
|
|
668
731
|
inner_thoughts_xml_tag: Optional[str] = "thinking",
|
|
732
|
+
put_inner_thoughts_in_kwargs: bool = False,
|
|
669
733
|
create_message_id: bool = True,
|
|
670
734
|
create_message_datetime: bool = True,
|
|
671
735
|
betas: List[str] = ["tools-2024-04-04"],
|
|
@@ -743,6 +807,7 @@ def anthropic_chat_completions_process_stream(
|
|
|
743
807
|
anthropic_chat_completions_request_stream(
|
|
744
808
|
data=chat_completion_request,
|
|
745
809
|
inner_thoughts_xml_tag=inner_thoughts_xml_tag,
|
|
810
|
+
put_inner_thoughts_in_kwargs=put_inner_thoughts_in_kwargs,
|
|
746
811
|
betas=betas,
|
|
747
812
|
)
|
|
748
813
|
):
|
|
@@ -111,7 +111,6 @@ def create(
|
|
|
111
111
|
# streaming?
|
|
112
112
|
stream: bool = False,
|
|
113
113
|
stream_interface: Optional[Union[AgentRefreshStreamingInterface, AgentChunkStreamingInterface]] = None,
|
|
114
|
-
max_tokens: Optional[int] = None,
|
|
115
114
|
model_settings: Optional[dict] = None, # TODO: eventually pass from server
|
|
116
115
|
) -> ChatCompletionResponse:
|
|
117
116
|
"""Return response to chat completion with backoff"""
|
|
@@ -157,7 +156,7 @@ def create(
|
|
|
157
156
|
else:
|
|
158
157
|
function_call = "required"
|
|
159
158
|
|
|
160
|
-
data = build_openai_chat_completions_request(llm_config, messages, user_id, functions, function_call, use_tool_naming
|
|
159
|
+
data = build_openai_chat_completions_request(llm_config, messages, user_id, functions, function_call, use_tool_naming)
|
|
161
160
|
if stream: # Client requested token streaming
|
|
162
161
|
data.stream = True
|
|
163
162
|
assert isinstance(stream_interface, AgentChunkStreamingInterface) or isinstance(
|
|
@@ -212,7 +211,7 @@ def create(
|
|
|
212
211
|
# For Azure, this model_endpoint is required to be configured via env variable, so users don't need to provide it in the LLM config
|
|
213
212
|
llm_config.model_endpoint = model_settings.azure_base_url
|
|
214
213
|
chat_completion_request = build_openai_chat_completions_request(
|
|
215
|
-
llm_config, messages, user_id, functions, function_call, use_tool_naming
|
|
214
|
+
llm_config, messages, user_id, functions, function_call, use_tool_naming
|
|
216
215
|
)
|
|
217
216
|
|
|
218
217
|
response = azure_openai_chat_completions_request(
|
|
@@ -248,7 +247,7 @@ def create(
|
|
|
248
247
|
data=dict(
|
|
249
248
|
contents=[m.to_google_ai_dict() for m in messages],
|
|
250
249
|
tools=tools,
|
|
251
|
-
generation_config={"temperature": llm_config.temperature},
|
|
250
|
+
generation_config={"temperature": llm_config.temperature, "max_output_tokens": llm_config.max_tokens},
|
|
252
251
|
),
|
|
253
252
|
inner_thoughts_in_kwargs=llm_config.put_inner_thoughts_in_kwargs,
|
|
254
253
|
)
|
|
@@ -268,7 +267,7 @@ def create(
|
|
|
268
267
|
messages=[cast_message_to_subtype(m.to_openai_dict()) for m in messages],
|
|
269
268
|
tools=([{"type": "function", "function": f} for f in functions] if functions else None),
|
|
270
269
|
tool_choice=tool_call,
|
|
271
|
-
max_tokens=
|
|
270
|
+
max_tokens=llm_config.max_tokens, # Note: max_tokens is required for Anthropic API
|
|
272
271
|
temperature=llm_config.temperature,
|
|
273
272
|
stream=stream,
|
|
274
273
|
)
|
|
@@ -279,14 +278,21 @@ def create(
|
|
|
279
278
|
|
|
280
279
|
response = anthropic_chat_completions_process_stream(
|
|
281
280
|
chat_completion_request=chat_completion_request,
|
|
281
|
+
put_inner_thoughts_in_kwargs=llm_config.put_inner_thoughts_in_kwargs,
|
|
282
282
|
stream_interface=stream_interface,
|
|
283
283
|
)
|
|
284
|
-
return response
|
|
285
284
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
else:
|
|
286
|
+
# Client did not request token streaming (expect a blocking backend response)
|
|
287
|
+
response = anthropic_chat_completions_request(
|
|
288
|
+
data=chat_completion_request,
|
|
289
|
+
put_inner_thoughts_in_kwargs=llm_config.put_inner_thoughts_in_kwargs,
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
if llm_config.put_inner_thoughts_in_kwargs:
|
|
293
|
+
response = unpack_all_inner_thoughts_from_kwargs(response=response, inner_thoughts_key=INNER_THOUGHTS_KWARG)
|
|
294
|
+
|
|
295
|
+
return response
|
|
290
296
|
|
|
291
297
|
# elif llm_config.model_endpoint_type == "cohere":
|
|
292
298
|
# if stream:
|
|
@@ -416,7 +422,7 @@ def create(
|
|
|
416
422
|
tool_choice=tool_call,
|
|
417
423
|
# user=str(user_id),
|
|
418
424
|
# NOTE: max_tokens is required for Anthropic API
|
|
419
|
-
max_tokens=
|
|
425
|
+
max_tokens=llm_config.max_tokens,
|
|
420
426
|
),
|
|
421
427
|
)
|
|
422
428
|
|
|
@@ -7,6 +7,7 @@ from openai import OpenAI
|
|
|
7
7
|
from letta.llm_api.helpers import add_inner_thoughts_to_functions, convert_to_structured_output, make_post_request
|
|
8
8
|
from letta.local_llm.constants import INNER_THOUGHTS_KWARG, INNER_THOUGHTS_KWARG_DESCRIPTION, INNER_THOUGHTS_KWARG_DESCRIPTION_GO_FIRST
|
|
9
9
|
from letta.local_llm.utils import num_tokens_from_functions, num_tokens_from_messages
|
|
10
|
+
from letta.log import get_logger
|
|
10
11
|
from letta.schemas.llm_config import LLMConfig
|
|
11
12
|
from letta.schemas.message import Message as _Message
|
|
12
13
|
from letta.schemas.message import MessageRole as _MessageRole
|
|
@@ -26,7 +27,7 @@ from letta.schemas.openai.embedding_response import EmbeddingResponse
|
|
|
26
27
|
from letta.streaming_interface import AgentChunkStreamingInterface, AgentRefreshStreamingInterface
|
|
27
28
|
from letta.utils import get_tool_call_id, smart_urljoin
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
logger = get_logger(__name__)
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
def openai_get_model_list(
|
|
@@ -93,7 +94,6 @@ def build_openai_chat_completions_request(
|
|
|
93
94
|
functions: Optional[list],
|
|
94
95
|
function_call: Optional[str],
|
|
95
96
|
use_tool_naming: bool,
|
|
96
|
-
max_tokens: Optional[int],
|
|
97
97
|
) -> ChatCompletionRequest:
|
|
98
98
|
if functions and llm_config.put_inner_thoughts_in_kwargs:
|
|
99
99
|
# Special case for LM Studio backend since it needs extra guidance to force out the thoughts first
|
|
@@ -130,7 +130,7 @@ def build_openai_chat_completions_request(
|
|
|
130
130
|
tools=[Tool(type="function", function=f) for f in functions] if functions else None,
|
|
131
131
|
tool_choice=tool_choice,
|
|
132
132
|
user=str(user_id),
|
|
133
|
-
max_completion_tokens=max_tokens,
|
|
133
|
+
max_completion_tokens=llm_config.max_tokens,
|
|
134
134
|
temperature=llm_config.temperature,
|
|
135
135
|
)
|
|
136
136
|
else:
|
|
@@ -140,7 +140,7 @@ def build_openai_chat_completions_request(
|
|
|
140
140
|
functions=functions,
|
|
141
141
|
function_call=function_call,
|
|
142
142
|
user=str(user_id),
|
|
143
|
-
max_completion_tokens=max_tokens,
|
|
143
|
+
max_completion_tokens=llm_config.max_tokens,
|
|
144
144
|
temperature=llm_config.temperature,
|
|
145
145
|
)
|
|
146
146
|
# https://platform.openai.com/docs/guides/text-generation/json-mode
|
|
@@ -354,9 +354,10 @@ def openai_chat_completions_process_stream(
|
|
|
354
354
|
except Exception as e:
|
|
355
355
|
if stream_interface:
|
|
356
356
|
stream_interface.stream_end()
|
|
357
|
-
|
|
357
|
+
logger.error(f"Parsing ChatCompletion stream failed with error:\n{str(e)}")
|
|
358
358
|
raise e
|
|
359
359
|
finally:
|
|
360
|
+
logger.info(f"Finally ending streaming interface.")
|
|
360
361
|
if stream_interface:
|
|
361
362
|
stream_interface.stream_end()
|
|
362
363
|
|
|
@@ -15,6 +15,7 @@ class LLMConfig(BaseModel):
|
|
|
15
15
|
context_window (int): The context window size for the model.
|
|
16
16
|
put_inner_thoughts_in_kwargs (bool): Puts `inner_thoughts` as a kwarg in the function call if this is set to True. This helps with function calling performance and also the generation of inner thoughts.
|
|
17
17
|
temperature (float): The temperature to use when generating text with the model. A higher temperature will result in more random text.
|
|
18
|
+
max_tokens (int): The maximum number of tokens to generate.
|
|
18
19
|
"""
|
|
19
20
|
|
|
20
21
|
# TODO: 🤮 don't default to a vendor! bug city!
|
|
@@ -51,6 +52,10 @@ class LLMConfig(BaseModel):
|
|
|
51
52
|
0.7,
|
|
52
53
|
description="The temperature to use when generating text with the model. A higher temperature will result in more random text.",
|
|
53
54
|
)
|
|
55
|
+
max_tokens: Optional[int] = Field(
|
|
56
|
+
1024,
|
|
57
|
+
description="The maximum number of tokens to generate. If not set, the model will use its default value.",
|
|
58
|
+
)
|
|
54
59
|
|
|
55
60
|
# FIXME hack to silence pydantic protected namespace warning
|
|
56
61
|
model_config = ConfigDict(protected_namespaces=())
|
|
@@ -542,7 +542,11 @@ class Message(BaseMessage):
|
|
|
542
542
|
|
|
543
543
|
return openai_message
|
|
544
544
|
|
|
545
|
-
def to_anthropic_dict(
|
|
545
|
+
def to_anthropic_dict(
|
|
546
|
+
self,
|
|
547
|
+
inner_thoughts_xml_tag="thinking",
|
|
548
|
+
put_inner_thoughts_in_kwargs: bool = False,
|
|
549
|
+
) -> dict:
|
|
546
550
|
"""
|
|
547
551
|
Convert to an Anthropic message dictionary
|
|
548
552
|
|
|
@@ -586,26 +590,38 @@ class Message(BaseMessage):
|
|
|
586
590
|
"role": self.role,
|
|
587
591
|
}
|
|
588
592
|
content = []
|
|
589
|
-
|
|
593
|
+
# COT / reasoning / thinking
|
|
594
|
+
if self.text is not None and not put_inner_thoughts_in_kwargs:
|
|
590
595
|
content.append(
|
|
591
596
|
{
|
|
592
597
|
"type": "text",
|
|
593
598
|
"text": add_xml_tag(string=self.text, xml_tag=inner_thoughts_xml_tag),
|
|
594
599
|
}
|
|
595
600
|
)
|
|
601
|
+
# Tool calling
|
|
596
602
|
if self.tool_calls is not None:
|
|
597
603
|
for tool_call in self.tool_calls:
|
|
604
|
+
|
|
605
|
+
if put_inner_thoughts_in_kwargs:
|
|
606
|
+
tool_call_input = add_inner_thoughts_to_tool_call(
|
|
607
|
+
tool_call,
|
|
608
|
+
inner_thoughts=self.text,
|
|
609
|
+
inner_thoughts_key=INNER_THOUGHTS_KWARG,
|
|
610
|
+
).model_dump()
|
|
611
|
+
else:
|
|
612
|
+
tool_call_input = json.loads(tool_call.function.arguments)
|
|
613
|
+
|
|
598
614
|
content.append(
|
|
599
615
|
{
|
|
600
616
|
"type": "tool_use",
|
|
601
617
|
"id": tool_call.id,
|
|
602
618
|
"name": tool_call.function.name,
|
|
603
|
-
"input":
|
|
619
|
+
"input": tool_call_input,
|
|
604
620
|
}
|
|
605
621
|
)
|
|
606
622
|
|
|
607
623
|
# If the only content was text, unpack it back into a singleton
|
|
608
|
-
# TODO
|
|
624
|
+
# TODO support multi-modal
|
|
609
625
|
anthropic_message["content"] = content
|
|
610
626
|
|
|
611
627
|
# Optional fields, do not include if null
|
|
@@ -347,6 +347,15 @@ class AnthropicProvider(Provider):
|
|
|
347
347
|
|
|
348
348
|
configs = []
|
|
349
349
|
for model in models:
|
|
350
|
+
|
|
351
|
+
# We set this to false by default, because Anthropic can
|
|
352
|
+
# natively support <thinking> tags inside of content fields
|
|
353
|
+
# However, putting COT inside of tool calls can make it more
|
|
354
|
+
# reliable for tool calling (no chance of a non-tool call step)
|
|
355
|
+
# Since tool_choice_type 'any' doesn't work with in-content COT
|
|
356
|
+
# NOTE For Haiku, it can be flaky if we don't enable this by default
|
|
357
|
+
inner_thoughts_in_kwargs = True if "haiku" in model["name"] else False
|
|
358
|
+
|
|
350
359
|
configs.append(
|
|
351
360
|
LLMConfig(
|
|
352
361
|
model=model["name"],
|
|
@@ -354,6 +363,7 @@ class AnthropicProvider(Provider):
|
|
|
354
363
|
model_endpoint=self.base_url,
|
|
355
364
|
context_window=model["context_window"],
|
|
356
365
|
handle=self.get_handle(model["name"]),
|
|
366
|
+
put_inner_thoughts_in_kwargs=inner_thoughts_in_kwargs,
|
|
357
367
|
)
|
|
358
368
|
)
|
|
359
369
|
return configs
|