letta-nightly 0.4.1.dev20241007104134__tar.gz → 0.4.1.dev20241009104130__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.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/PKG-INFO +1 -1
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/agent.py +36 -10
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/client/client.py +8 -1
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/credentials.py +3 -3
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/errors.py +1 -1
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/schema_generator.py +1 -1
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/anthropic.py +3 -24
- letta_nightly-0.4.1.dev20241009104130/letta/llm_api/azure_openai.py +100 -0
- letta_nightly-0.4.1.dev20241009104130/letta/llm_api/azure_openai_constants.py +10 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/google_ai.py +39 -64
- letta_nightly-0.4.1.dev20241009104130/letta/llm_api/helpers.py +208 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/llm_api_tools.py +43 -218
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/openai.py +74 -50
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/main.py +1 -1
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/metadata.py +2 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/providers.py +144 -31
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/agent.py +14 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/llm_config.py +2 -2
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/chat_completion_response.py +3 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/tool.py +3 -3
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/admin/tools.py +0 -1
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/app.py +1 -17
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/assistants/threads.py +10 -7
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/chat_completions/chat_completions.py +5 -3
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/agents.py +23 -13
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/blocks.py +5 -3
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/jobs.py +5 -3
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/sources.py +25 -13
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/tools.py +12 -7
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/server.py +33 -37
- letta_nightly-0.4.1.dev20241009104130/letta/settings.py +89 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/pyproject.toml +2 -1
- letta_nightly-0.4.1.dev20241007104134/letta/llm_api/azure_openai.py +0 -155
- letta_nightly-0.4.1.dev20241007104134/letta/settings.py +0 -197
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/LICENSE +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/README.md +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/__main__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/chroma.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/db.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/lancedb.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/milvus.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/qdrant.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/storage.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/benchmark/benchmark.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/benchmark/constants.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/cli/cli.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/cli/cli_config.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/cli/cli_load.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/client/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/client/admin.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/client/streaming.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/client/utils.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/config.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/configs/anthropic.json +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/configs/letta_hosted.json +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/configs/openai.json +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/constants.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/data_sources/connectors.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/embeddings.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/function_sets/base.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/function_sets/extras.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/functions.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/helpers.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/humans/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/humans/examples/basic.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/humans/examples/cs_phd.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/interface.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/cohere.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/README.md +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/chat_completion_proxy.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/constants.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/function_parser.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/grammars/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/grammars/gbnf_grammar_generator.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/grammars/json.gbnf +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/grammars/json_func_calls_with_inner_thoughts.gbnf +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/json_parser.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/koboldcpp/api.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/koboldcpp/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llamacpp/api.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llamacpp/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/airoboros.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/chatml.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/dolphin.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/llama3.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/wrapper_base.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/zephyr.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/lmstudio/api.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/lmstudio/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/ollama/api.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/ollama/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/settings/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/settings/deterministic_mirostat.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/settings/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/settings/simple.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/utils.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/vllm/api.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/webui/api.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/webui/legacy_api.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/webui/legacy_settings.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/webui/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/log.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/memory.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/openai_backcompat/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/openai_backcompat/openai_object.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/persistence_manager.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/anna_pa.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/google_search_persona.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/memgpt_doc.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/memgpt_starter.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/sam.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/sam_pov.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/sam_simple_pov_gpt35.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/sqldb/test.db +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/gpt_summarize.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/gpt_system.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_base.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_chat.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_chat_compressed.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_chat_fstring.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_doc.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_gpt35_extralong.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_intuitive_knowledge.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_modified_chat.txt +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/pytest.ini +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/api_key.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/block.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/document.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/embedding_config.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/enums.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/health.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/job.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/letta_base.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/letta_message.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/letta_request.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/letta_response.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/memory.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/message.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/chat_completion_request.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/chat_completions.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/embedding_response.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/openai.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/organization.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/passage.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/source.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/usage.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/user.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/constants.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/admin/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/admin/agents.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/admin/users.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/auth/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/auth/index.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/auth_token.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/interface.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/assistants/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/assistants/assistants.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/assistants/schemas.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/chat_completions/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/health.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/llms.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/organizations.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/users.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/static_files.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/utils.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/startup.sh +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/assets/index-3ab03d5b.css +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/assets/index-9a9c449b.js +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/favicon.ico +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/index.html +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/memgpt_logo_transparent.png +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/utils.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/example_client.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/interface.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/protocol.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/server.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/streaming_interface.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/system.py +0 -0
- {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/utils.py +0 -0
{letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/agent.py
RENAMED
|
@@ -18,7 +18,7 @@ from letta.constants import (
|
|
|
18
18
|
MESSAGE_SUMMARY_WARNING_FRAC,
|
|
19
19
|
)
|
|
20
20
|
from letta.interface import AgentInterface
|
|
21
|
-
from letta.llm_api.llm_api_tools import create
|
|
21
|
+
from letta.llm_api.llm_api_tools import create
|
|
22
22
|
from letta.memory import ArchivalMemory, RecallMemory, summarize_messages
|
|
23
23
|
from letta.metadata import MetadataStore
|
|
24
24
|
from letta.persistence_manager import LocalStateManager
|
|
@@ -56,6 +56,7 @@ from letta.utils import (
|
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
from .errors import LLMError
|
|
59
|
+
from .llm_api.helpers import is_context_overflow_error
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
def compile_memory_metadata_block(
|
|
@@ -207,7 +208,7 @@ class BaseAgent(ABC):
|
|
|
207
208
|
recreate_message_timestamp: bool = True, # if True, when input is a Message type, recreated the 'created_at' field
|
|
208
209
|
stream: bool = False, # TODO move to config?
|
|
209
210
|
timestamp: Optional[datetime.datetime] = None,
|
|
210
|
-
|
|
211
|
+
inner_thoughts_in_kwargs_option: OptionState = OptionState.DEFAULT,
|
|
211
212
|
ms: Optional[MetadataStore] = None,
|
|
212
213
|
) -> AgentStepResponse:
|
|
213
214
|
"""
|
|
@@ -223,7 +224,7 @@ class BaseAgent(ABC):
|
|
|
223
224
|
class Agent(BaseAgent):
|
|
224
225
|
def __init__(
|
|
225
226
|
self,
|
|
226
|
-
interface: AgentInterface,
|
|
227
|
+
interface: Optional[AgentInterface],
|
|
227
228
|
# agents can be created from providing agent_state
|
|
228
229
|
agent_state: AgentState,
|
|
229
230
|
tools: List[Tool],
|
|
@@ -238,6 +239,7 @@ class Agent(BaseAgent):
|
|
|
238
239
|
assert isinstance(self.agent_state.memory, Memory), f"Memory object is not of type Memory: {type(self.agent_state.memory)}"
|
|
239
240
|
|
|
240
241
|
# link tools
|
|
242
|
+
self.tools = tools
|
|
241
243
|
self.link_tools(tools)
|
|
242
244
|
|
|
243
245
|
# gpt-4, gpt-3.5-turbo, ...
|
|
@@ -337,6 +339,9 @@ class Agent(BaseAgent):
|
|
|
337
339
|
for tool_name in self.agent_state.tools:
|
|
338
340
|
assert tool_name in [tool.name for tool in tools], f"Tool name {tool_name} not included in agent tool list"
|
|
339
341
|
|
|
342
|
+
# Update tools
|
|
343
|
+
self.tools = tools
|
|
344
|
+
|
|
340
345
|
# Store the functions schemas (this is passed as an argument to ChatCompletion)
|
|
341
346
|
self.functions = []
|
|
342
347
|
self.functions_python = {}
|
|
@@ -460,7 +465,7 @@ class Agent(BaseAgent):
|
|
|
460
465
|
function_call: str = "auto",
|
|
461
466
|
first_message: bool = False, # hint
|
|
462
467
|
stream: bool = False, # TODO move to config?
|
|
463
|
-
|
|
468
|
+
inner_thoughts_in_kwargs_option: OptionState = OptionState.DEFAULT,
|
|
464
469
|
) -> ChatCompletionResponse:
|
|
465
470
|
"""Get response from LLM API"""
|
|
466
471
|
try:
|
|
@@ -478,10 +483,10 @@ class Agent(BaseAgent):
|
|
|
478
483
|
stream=stream,
|
|
479
484
|
stream_inferface=self.interface,
|
|
480
485
|
# putting inner thoughts in func args or not
|
|
481
|
-
|
|
486
|
+
inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
|
|
482
487
|
)
|
|
483
488
|
|
|
484
|
-
if len(response.choices) == 0:
|
|
489
|
+
if len(response.choices) == 0 or response.choices[0] is None:
|
|
485
490
|
raise Exception(f"API call didn't return a message: {response}")
|
|
486
491
|
|
|
487
492
|
# special case for 'length'
|
|
@@ -551,15 +556,20 @@ class Agent(BaseAgent):
|
|
|
551
556
|
) # extend conversation with assistant's reply
|
|
552
557
|
printd(f"Function call message: {messages[-1]}")
|
|
553
558
|
|
|
559
|
+
nonnull_content = False
|
|
554
560
|
if response_message.content:
|
|
555
561
|
# The content if then internal monologue, not chat
|
|
556
562
|
self.interface.internal_monologue(response_message.content, msg_obj=messages[-1])
|
|
563
|
+
# Flag to avoid printing a duplicate if inner thoughts get popped from the function call
|
|
564
|
+
nonnull_content = True
|
|
557
565
|
|
|
558
566
|
# Step 3: call the function
|
|
559
567
|
# Note: the JSON response may not always be valid; be sure to handle errors
|
|
560
568
|
function_call = (
|
|
561
569
|
response_message.function_call if response_message.function_call is not None else response_message.tool_calls[0].function
|
|
562
570
|
)
|
|
571
|
+
|
|
572
|
+
# Get the name of the function
|
|
563
573
|
function_name = function_call.name
|
|
564
574
|
printd(f"Request to call function {function_name} with tool_call_id: {tool_call_id}")
|
|
565
575
|
|
|
@@ -608,9 +618,21 @@ class Agent(BaseAgent):
|
|
|
608
618
|
self.interface.function_message(f"Error: {error_msg}", msg_obj=messages[-1])
|
|
609
619
|
return messages, False, True # force a heartbeat to allow agent to handle error
|
|
610
620
|
|
|
621
|
+
# Check if inner thoughts is in the function call arguments (possible apparently if you are using Azure)
|
|
622
|
+
if "inner_thoughts" in function_args:
|
|
623
|
+
response_message.content = function_args.pop("inner_thoughts")
|
|
624
|
+
# The content if then internal monologue, not chat
|
|
625
|
+
if response_message.content and not nonnull_content:
|
|
626
|
+
self.interface.internal_monologue(response_message.content, msg_obj=messages[-1])
|
|
627
|
+
|
|
611
628
|
# (Still parsing function args)
|
|
612
629
|
# Handle requests for immediate heartbeat
|
|
613
630
|
heartbeat_request = function_args.pop("request_heartbeat", None)
|
|
631
|
+
|
|
632
|
+
# Edge case: heartbeat_request is returned as a stringified boolean, we will attempt to parse:
|
|
633
|
+
if isinstance(heartbeat_request, str) and heartbeat_request.lower().strip() == "true":
|
|
634
|
+
heartbeat_request = True
|
|
635
|
+
|
|
614
636
|
if not isinstance(heartbeat_request, bool) or heartbeat_request is None:
|
|
615
637
|
printd(
|
|
616
638
|
f"{CLI_WARNING_PREFIX}'request_heartbeat' arg parsed was not a bool or None, type={type(heartbeat_request)}, value={heartbeat_request}"
|
|
@@ -716,7 +738,7 @@ class Agent(BaseAgent):
|
|
|
716
738
|
recreate_message_timestamp: bool = True, # if True, when input is a Message type, recreated the 'created_at' field
|
|
717
739
|
stream: bool = False, # TODO move to config?
|
|
718
740
|
timestamp: Optional[datetime.datetime] = None,
|
|
719
|
-
|
|
741
|
+
inner_thoughts_in_kwargs_option: OptionState = OptionState.DEFAULT,
|
|
720
742
|
ms: Optional[MetadataStore] = None,
|
|
721
743
|
) -> AgentStepResponse:
|
|
722
744
|
"""Top-level event message handler for the Letta agent"""
|
|
@@ -795,7 +817,7 @@ class Agent(BaseAgent):
|
|
|
795
817
|
message_sequence=input_message_sequence,
|
|
796
818
|
first_message=True, # passed through to the prompt formatter
|
|
797
819
|
stream=stream,
|
|
798
|
-
|
|
820
|
+
inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
|
|
799
821
|
)
|
|
800
822
|
if verify_first_message_correctness(response, require_monologue=self.first_message_verify_mono):
|
|
801
823
|
break
|
|
@@ -808,7 +830,7 @@ class Agent(BaseAgent):
|
|
|
808
830
|
response = self._get_ai_reply(
|
|
809
831
|
message_sequence=input_message_sequence,
|
|
810
832
|
stream=stream,
|
|
811
|
-
|
|
833
|
+
inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
|
|
812
834
|
)
|
|
813
835
|
|
|
814
836
|
# Step 3: check if LLM wanted to call a function
|
|
@@ -892,7 +914,7 @@ class Agent(BaseAgent):
|
|
|
892
914
|
recreate_message_timestamp=recreate_message_timestamp,
|
|
893
915
|
stream=stream,
|
|
894
916
|
timestamp=timestamp,
|
|
895
|
-
|
|
917
|
+
inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
|
|
896
918
|
ms=ms,
|
|
897
919
|
)
|
|
898
920
|
|
|
@@ -1343,6 +1365,10 @@ def save_agent(agent: Agent, ms: MetadataStore):
|
|
|
1343
1365
|
else:
|
|
1344
1366
|
ms.create_agent(agent_state)
|
|
1345
1367
|
|
|
1368
|
+
for tool in agent.tools:
|
|
1369
|
+
if ms.get_tool(tool_name=tool.name, user_id=tool.user_id) is None:
|
|
1370
|
+
ms.create_tool(tool)
|
|
1371
|
+
|
|
1346
1372
|
agent.agent_state = ms.get_agent(agent_id=agent_id)
|
|
1347
1373
|
assert isinstance(agent.agent_state.memory, Memory), f"Memory is not a Memory object: {type(agent_state.memory)}"
|
|
1348
1374
|
|
|
@@ -9,7 +9,7 @@ from letta.constants import BASE_TOOLS, DEFAULT_HUMAN, DEFAULT_PERSONA
|
|
|
9
9
|
from letta.data_sources.connectors import DataConnector
|
|
10
10
|
from letta.functions.functions import parse_source_code
|
|
11
11
|
from letta.memory import get_memory_functions
|
|
12
|
-
from letta.schemas.agent import AgentState, CreateAgent, UpdateAgentState
|
|
12
|
+
from letta.schemas.agent import AgentState, AgentType, CreateAgent, UpdateAgentState
|
|
13
13
|
from letta.schemas.block import (
|
|
14
14
|
Block,
|
|
15
15
|
CreateBlock,
|
|
@@ -68,6 +68,7 @@ class AbstractClient(object):
|
|
|
68
68
|
def create_agent(
|
|
69
69
|
self,
|
|
70
70
|
name: Optional[str] = None,
|
|
71
|
+
agent_type: Optional[AgentType] = AgentType.memgpt_agent,
|
|
71
72
|
embedding_config: Optional[EmbeddingConfig] = None,
|
|
72
73
|
llm_config: Optional[LLMConfig] = None,
|
|
73
74
|
memory: Memory = ChatMemory(human=get_human_text(DEFAULT_HUMAN), persona=get_persona_text(DEFAULT_PERSONA)),
|
|
@@ -319,6 +320,8 @@ class RESTClient(AbstractClient):
|
|
|
319
320
|
def create_agent(
|
|
320
321
|
self,
|
|
321
322
|
name: Optional[str] = None,
|
|
323
|
+
# agent config
|
|
324
|
+
agent_type: Optional[AgentType] = AgentType.memgpt_agent,
|
|
322
325
|
# model configs
|
|
323
326
|
embedding_config: EmbeddingConfig = None,
|
|
324
327
|
llm_config: LLMConfig = None,
|
|
@@ -381,6 +384,7 @@ class RESTClient(AbstractClient):
|
|
|
381
384
|
memory=memory,
|
|
382
385
|
tools=tool_names,
|
|
383
386
|
system=system,
|
|
387
|
+
agent_type=agent_type,
|
|
384
388
|
llm_config=llm_config if llm_config else self._default_llm_config,
|
|
385
389
|
embedding_config=embedding_config if embedding_config else self._default_embedding_config,
|
|
386
390
|
)
|
|
@@ -1462,6 +1466,8 @@ class LocalClient(AbstractClient):
|
|
|
1462
1466
|
def create_agent(
|
|
1463
1467
|
self,
|
|
1464
1468
|
name: Optional[str] = None,
|
|
1469
|
+
# agent config
|
|
1470
|
+
agent_type: Optional[AgentType] = AgentType.memgpt_agent,
|
|
1465
1471
|
# model configs
|
|
1466
1472
|
embedding_config: EmbeddingConfig = None,
|
|
1467
1473
|
llm_config: LLMConfig = None,
|
|
@@ -1524,6 +1530,7 @@ class LocalClient(AbstractClient):
|
|
|
1524
1530
|
memory=memory,
|
|
1525
1531
|
tools=tool_names,
|
|
1526
1532
|
system=system,
|
|
1533
|
+
agent_type=agent_type,
|
|
1527
1534
|
llm_config=llm_config if llm_config else self._default_llm_config,
|
|
1528
1535
|
embedding_config=embedding_config if embedding_config else self._default_embedding_config,
|
|
1529
1536
|
),
|
{letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/credentials.py
RENAMED
|
@@ -30,7 +30,7 @@ class LettaCredentials:
|
|
|
30
30
|
|
|
31
31
|
# azure config
|
|
32
32
|
azure_auth_type: str = "api_key"
|
|
33
|
-
azure_key: Optional[str] =
|
|
33
|
+
azure_key: Optional[str] = os.getenv("AZURE_OPENAI_API_KEY")
|
|
34
34
|
|
|
35
35
|
# groq config
|
|
36
36
|
groq_key: Optional[str] = os.getenv("GROQ_API_KEY")
|
|
@@ -76,7 +76,7 @@ class LettaCredentials:
|
|
|
76
76
|
"azure_embedding_deployment": get_field(config, "azure", "embedding_deployment"),
|
|
77
77
|
# gemini
|
|
78
78
|
"google_ai_key": get_field(config, "google_ai", "key"),
|
|
79
|
-
"google_ai_service_endpoint": get_field(config, "google_ai", "service_endpoint"),
|
|
79
|
+
# "google_ai_service_endpoint": get_field(config, "google_ai", "service_endpoint"),
|
|
80
80
|
# anthropic
|
|
81
81
|
"anthropic_key": get_field(config, "anthropic", "key"),
|
|
82
82
|
# cohere
|
|
@@ -117,7 +117,7 @@ class LettaCredentials:
|
|
|
117
117
|
|
|
118
118
|
# gemini
|
|
119
119
|
set_field(config, "google_ai", "key", self.google_ai_key)
|
|
120
|
-
set_field(config, "google_ai", "service_endpoint", self.google_ai_service_endpoint)
|
|
120
|
+
# set_field(config, "google_ai", "service_endpoint", self.google_ai_service_endpoint)
|
|
121
121
|
|
|
122
122
|
# anthropic
|
|
123
123
|
set_field(config, "anthropic", "key", self.anthropic_key)
|
{letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241009104130}/letta/errors.py
RENAMED
|
@@ -56,7 +56,7 @@ class LettaMessageError(LettaError):
|
|
|
56
56
|
error_msg += f" (Explanation: {explanation})"
|
|
57
57
|
|
|
58
58
|
# Pretty print out message JSON
|
|
59
|
-
message_json = json.dumps([message.
|
|
59
|
+
message_json = json.dumps([message.model_dump() for message in messages], indent=4)
|
|
60
60
|
return f"{error_msg}\n\n{message_json}"
|
|
61
61
|
|
|
62
62
|
|
|
@@ -130,7 +130,7 @@ def generate_schema(function, name: Optional[str] = None, description: Optional[
|
|
|
130
130
|
if function.__name__ not in ["send_message", "pause_heartbeats"]:
|
|
131
131
|
schema["parameters"]["properties"]["request_heartbeat"] = {
|
|
132
132
|
"type": "boolean",
|
|
133
|
-
"description": "Request an immediate heartbeat after function execution. Set to
|
|
133
|
+
"description": "Request an immediate heartbeat after function execution. Set to `True` if you want to send a follow-up message or run a follow-up function.",
|
|
134
134
|
}
|
|
135
135
|
schema["parameters"]["required"].append("request_heartbeat")
|
|
136
136
|
|
|
@@ -2,8 +2,7 @@ import json
|
|
|
2
2
|
import re
|
|
3
3
|
from typing import List, Optional, Union
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
from letta.llm_api.helpers import make_post_request
|
|
7
6
|
from letta.schemas.message import Message
|
|
8
7
|
from letta.schemas.openai.chat_completion_request import ChatCompletionRequest, Tool
|
|
9
8
|
from letta.schemas.openai.chat_completion_response import (
|
|
@@ -295,7 +294,6 @@ def anthropic_chat_completions_request(
|
|
|
295
294
|
inner_thoughts_xml_tag: Optional[str] = "thinking",
|
|
296
295
|
) -> ChatCompletionResponse:
|
|
297
296
|
"""https://docs.anthropic.com/claude/docs/tool-use"""
|
|
298
|
-
from letta.utils import printd
|
|
299
297
|
|
|
300
298
|
url = smart_urljoin(url, "messages")
|
|
301
299
|
headers = {
|
|
@@ -360,24 +358,5 @@ def anthropic_chat_completions_request(
|
|
|
360
358
|
data.pop("user", None)
|
|
361
359
|
data.pop("tool_choice", None)
|
|
362
360
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
response = requests.post(url, headers=headers, json=data)
|
|
366
|
-
printd(f"response = {response}")
|
|
367
|
-
response.raise_for_status() # Raises HTTPError for 4XX/5XX status
|
|
368
|
-
response = response.json() # convert to dict from string
|
|
369
|
-
printd(f"response.json = {response}")
|
|
370
|
-
response = convert_anthropic_response_to_chatcompletion(response_json=response, inner_thoughts_xml_tag=inner_thoughts_xml_tag)
|
|
371
|
-
return response
|
|
372
|
-
except requests.exceptions.HTTPError as http_err:
|
|
373
|
-
# Handle HTTP errors (e.g., response 4XX, 5XX)
|
|
374
|
-
printd(f"Got HTTPError, exception={http_err}, payload={data}")
|
|
375
|
-
raise http_err
|
|
376
|
-
except requests.exceptions.RequestException as req_err:
|
|
377
|
-
# Handle other requests-related errors (e.g., connection error)
|
|
378
|
-
printd(f"Got RequestException, exception={req_err}")
|
|
379
|
-
raise req_err
|
|
380
|
-
except Exception as e:
|
|
381
|
-
# Handle other potential errors
|
|
382
|
-
printd(f"Got unknown Exception, exception={e}")
|
|
383
|
-
raise e
|
|
361
|
+
response_json = make_post_request(url, headers, data)
|
|
362
|
+
return convert_anthropic_response_to_chatcompletion(response_json=response_json, inner_thoughts_xml_tag=inner_thoughts_xml_tag)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
from letta.llm_api.helpers import make_post_request
|
|
4
|
+
from letta.schemas.llm_config import LLMConfig
|
|
5
|
+
from letta.schemas.openai.chat_completion_response import ChatCompletionResponse
|
|
6
|
+
from letta.schemas.openai.chat_completions import ChatCompletionRequest
|
|
7
|
+
from letta.schemas.openai.embedding_response import EmbeddingResponse
|
|
8
|
+
from letta.settings import ModelSettings
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_azure_chat_completions_endpoint(base_url: str, model: str, api_version: str):
|
|
12
|
+
return f"{base_url}/openai/deployments/{model}/chat/completions?api-version={api_version}"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_azure_embeddings_endpoint(base_url: str, model: str, api_version: str):
|
|
16
|
+
return f"{base_url}/openai/deployments/{model}/embeddings?api-version={api_version}"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_azure_model_list_endpoint(base_url: str, api_version: str):
|
|
20
|
+
return f"{base_url}/openai/models?api-version={api_version}"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def azure_openai_get_model_list(base_url: str, api_key: str, api_version: str) -> list:
|
|
24
|
+
"""https://learn.microsoft.com/en-us/rest/api/azureopenai/models/list?view=rest-azureopenai-2023-05-15&tabs=HTTP"""
|
|
25
|
+
|
|
26
|
+
# https://xxx.openai.azure.com/openai/models?api-version=xxx
|
|
27
|
+
headers = {"Content-Type": "application/json"}
|
|
28
|
+
if api_key is not None:
|
|
29
|
+
headers["api-key"] = f"{api_key}"
|
|
30
|
+
|
|
31
|
+
url = get_azure_model_list_endpoint(base_url, api_version)
|
|
32
|
+
try:
|
|
33
|
+
response = requests.get(url, headers=headers)
|
|
34
|
+
response.raise_for_status()
|
|
35
|
+
except requests.RequestException as e:
|
|
36
|
+
raise RuntimeError(f"Failed to retrieve model list: {e}")
|
|
37
|
+
|
|
38
|
+
return response.json().get("data", [])
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def azure_openai_get_chat_completion_model_list(base_url: str, api_key: str, api_version: str) -> list:
|
|
42
|
+
model_list = azure_openai_get_model_list(base_url, api_key, api_version)
|
|
43
|
+
# Extract models that support text generation
|
|
44
|
+
model_options = [m for m in model_list if m.get("capabilities").get("chat_completion") == True]
|
|
45
|
+
return model_options
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def azure_openai_get_embeddings_model_list(base_url: str, api_key: str, api_version: str, require_embedding_in_name: bool = True) -> list:
|
|
49
|
+
def valid_embedding_model(m: dict):
|
|
50
|
+
valid_name = True
|
|
51
|
+
if require_embedding_in_name:
|
|
52
|
+
valid_name = "embedding" in m["id"]
|
|
53
|
+
|
|
54
|
+
return m.get("capabilities").get("embeddings") == True and valid_name
|
|
55
|
+
|
|
56
|
+
model_list = azure_openai_get_model_list(base_url, api_key, api_version)
|
|
57
|
+
# Extract models that support embeddings
|
|
58
|
+
|
|
59
|
+
model_options = [m for m in model_list if valid_embedding_model(m)]
|
|
60
|
+
return model_options
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def azure_openai_chat_completions_request(
|
|
64
|
+
model_settings: ModelSettings, llm_config: LLMConfig, api_key: str, chat_completion_request: ChatCompletionRequest
|
|
65
|
+
) -> ChatCompletionResponse:
|
|
66
|
+
"""https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions"""
|
|
67
|
+
|
|
68
|
+
assert api_key is not None, "Missing required field when calling Azure OpenAI"
|
|
69
|
+
|
|
70
|
+
headers = {"Content-Type": "application/json", "api-key": f"{api_key}"}
|
|
71
|
+
data = chat_completion_request.model_dump(exclude_none=True)
|
|
72
|
+
|
|
73
|
+
# If functions == None, strip from the payload
|
|
74
|
+
if "functions" in data and data["functions"] is None:
|
|
75
|
+
data.pop("functions")
|
|
76
|
+
data.pop("function_call", None) # extra safe, should exist always (default="auto")
|
|
77
|
+
|
|
78
|
+
if "tools" in data and data["tools"] is None:
|
|
79
|
+
data.pop("tools")
|
|
80
|
+
data.pop("tool_choice", None) # extra safe, should exist always (default="auto")
|
|
81
|
+
|
|
82
|
+
url = get_azure_chat_completions_endpoint(model_settings.azure_base_url, llm_config.model, model_settings.api_version)
|
|
83
|
+
response_json = make_post_request(url, headers, data)
|
|
84
|
+
# NOTE: azure openai does not include "content" in the response when it is None, so we need to add it
|
|
85
|
+
if "content" not in response_json["choices"][0].get("message"):
|
|
86
|
+
response_json["choices"][0]["message"]["content"] = None
|
|
87
|
+
response = ChatCompletionResponse(**response_json) # convert to 'dot-dict' style which is the openai python client default
|
|
88
|
+
return response
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def azure_openai_embeddings_request(
|
|
92
|
+
resource_name: str, deployment_id: str, api_version: str, api_key: str, data: dict
|
|
93
|
+
) -> EmbeddingResponse:
|
|
94
|
+
"""https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#embeddings"""
|
|
95
|
+
|
|
96
|
+
url = f"https://{resource_name}.openai.azure.com/openai/deployments/{deployment_id}/embeddings?api-version={api_version}"
|
|
97
|
+
headers = {"Content-Type": "application/json", "api-key": f"{api_key}"}
|
|
98
|
+
|
|
99
|
+
response_json = make_post_request(url, headers, data)
|
|
100
|
+
return EmbeddingResponse(**response_json)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
AZURE_MODEL_TO_CONTEXT_LENGTH = {
|
|
2
|
+
"babbage-002": 16384,
|
|
3
|
+
"davinci-002": 16384,
|
|
4
|
+
"gpt-35-turbo-0613": 4096,
|
|
5
|
+
"gpt-35-turbo-1106": 16385,
|
|
6
|
+
"gpt-35-turbo-0125": 16385,
|
|
7
|
+
"gpt-4-0613": 8192,
|
|
8
|
+
"gpt-4o-mini-2024-07-18": 128000,
|
|
9
|
+
"gpt-4o-2024-08-06": 128000,
|
|
10
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import uuid
|
|
2
|
-
from typing import List, Optional
|
|
2
|
+
from typing import List, Optional, Tuple
|
|
3
3
|
|
|
4
4
|
import requests
|
|
5
5
|
|
|
6
6
|
from letta.constants import NON_USER_MSG_PREFIX
|
|
7
|
+
from letta.llm_api.helpers import make_post_request
|
|
7
8
|
from letta.local_llm.json_parser import clean_json_string_extra_backslash
|
|
8
9
|
from letta.local_llm.utils import count_tokens
|
|
9
10
|
from letta.schemas.openai.chat_completion_request import Tool
|
|
@@ -15,27 +16,41 @@ from letta.schemas.openai.chat_completion_response import (
|
|
|
15
16
|
ToolCall,
|
|
16
17
|
UsageStatistics,
|
|
17
18
|
)
|
|
18
|
-
from letta.utils import get_tool_call_id, get_utc_time
|
|
19
|
+
from letta.utils import get_tool_call_id, get_utc_time, json_dumps
|
|
19
20
|
|
|
20
|
-
# from letta.data_types import ToolCall
|
|
21
21
|
|
|
22
|
+
def get_gemini_endpoint_and_headers(
|
|
23
|
+
base_url: str, model: Optional[str], api_key: str, key_in_header: bool = True, generate_content: bool = False
|
|
24
|
+
) -> Tuple[str, dict]:
|
|
25
|
+
"""
|
|
26
|
+
Dynamically generate the model endpoint and headers.
|
|
27
|
+
"""
|
|
28
|
+
url = f"{base_url}/v1beta/models"
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
# Add the model
|
|
31
|
+
if model is not None:
|
|
32
|
+
url += f"/{model}"
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
# Add extension for generating content if we're hitting the LM
|
|
35
|
+
if generate_content:
|
|
36
|
+
url += ":generateContent"
|
|
30
37
|
|
|
38
|
+
# Decide if api key should be in header or not
|
|
31
39
|
# Two ways to pass the key: https://ai.google.dev/tutorials/setup
|
|
32
40
|
if key_in_header:
|
|
33
|
-
url = f"https://{service_endpoint}.googleapis.com/v1beta/models/{model}"
|
|
34
41
|
headers = {"Content-Type": "application/json", "x-goog-api-key": api_key}
|
|
35
42
|
else:
|
|
36
|
-
url
|
|
43
|
+
url += f"?key={api_key}"
|
|
37
44
|
headers = {"Content-Type": "application/json"}
|
|
38
45
|
|
|
46
|
+
return url, headers
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def google_ai_get_model_details(base_url: str, api_key: str, model: str, key_in_header: bool = True) -> List[dict]:
|
|
50
|
+
from letta.utils import printd
|
|
51
|
+
|
|
52
|
+
url, headers = get_gemini_endpoint_and_headers(base_url, model, api_key, key_in_header)
|
|
53
|
+
|
|
39
54
|
try:
|
|
40
55
|
response = requests.get(url, headers=headers)
|
|
41
56
|
printd(f"response = {response}")
|
|
@@ -66,25 +81,17 @@ def google_ai_get_model_details(service_endpoint: str, api_key: str, model: str,
|
|
|
66
81
|
raise e
|
|
67
82
|
|
|
68
83
|
|
|
69
|
-
def google_ai_get_model_context_window(
|
|
70
|
-
model_details = google_ai_get_model_details(
|
|
71
|
-
service_endpoint=service_endpoint, api_key=api_key, model=model, key_in_header=key_in_header
|
|
72
|
-
)
|
|
84
|
+
def google_ai_get_model_context_window(base_url: str, api_key: str, model: str, key_in_header: bool = True) -> int:
|
|
85
|
+
model_details = google_ai_get_model_details(base_url=base_url, api_key=api_key, model=model, key_in_header=key_in_header)
|
|
73
86
|
# TODO should this be:
|
|
74
87
|
# return model_details["inputTokenLimit"] + model_details["outputTokenLimit"]
|
|
75
88
|
return int(model_details["inputTokenLimit"])
|
|
76
89
|
|
|
77
90
|
|
|
78
|
-
def google_ai_get_model_list(
|
|
91
|
+
def google_ai_get_model_list(base_url: str, api_key: str, key_in_header: bool = True) -> List[dict]:
|
|
79
92
|
from letta.utils import printd
|
|
80
93
|
|
|
81
|
-
|
|
82
|
-
if key_in_header:
|
|
83
|
-
url = f"https://{service_endpoint}.googleapis.com/v1beta/models"
|
|
84
|
-
headers = {"Content-Type": "application/json", "x-goog-api-key": api_key}
|
|
85
|
-
else:
|
|
86
|
-
url = f"https://{service_endpoint}.googleapis.com/v1beta/models?key={api_key}"
|
|
87
|
-
headers = {"Content-Type": "application/json"}
|
|
94
|
+
url, headers = get_gemini_endpoint_and_headers(base_url, None, api_key, key_in_header)
|
|
88
95
|
|
|
89
96
|
try:
|
|
90
97
|
response = requests.get(url, headers=headers)
|
|
@@ -396,7 +403,7 @@ def convert_google_ai_response_to_chatcompletion(
|
|
|
396
403
|
|
|
397
404
|
# TODO convert 'data' type to pydantic
|
|
398
405
|
def google_ai_chat_completions_request(
|
|
399
|
-
|
|
406
|
+
base_url: str,
|
|
400
407
|
model: str,
|
|
401
408
|
api_key: str,
|
|
402
409
|
data: dict,
|
|
@@ -414,55 +421,23 @@ def google_ai_chat_completions_request(
|
|
|
414
421
|
This service has the following service endpoint and all URIs below are relative to this service endpoint:
|
|
415
422
|
https://xxx.googleapis.com
|
|
416
423
|
"""
|
|
417
|
-
from letta.utils import printd
|
|
418
424
|
|
|
419
|
-
assert service_endpoint is not None, "Missing service_endpoint when calling Google AI"
|
|
420
425
|
assert api_key is not None, "Missing api_key when calling Google AI"
|
|
421
|
-
assert model in SUPPORTED_MODELS, f"Model '{model}' not in supported models: {', '.join(SUPPORTED_MODELS)}"
|
|
422
426
|
|
|
423
|
-
|
|
424
|
-
if key_in_header:
|
|
425
|
-
url = f"https://{service_endpoint}.googleapis.com/v1beta/models/{model}:generateContent"
|
|
426
|
-
headers = {"Content-Type": "application/json", "x-goog-api-key": api_key}
|
|
427
|
-
else:
|
|
428
|
-
url = f"https://{service_endpoint}.googleapis.com/v1beta/models/{model}:generateContent?key={api_key}"
|
|
429
|
-
headers = {"Content-Type": "application/json"}
|
|
427
|
+
url, headers = get_gemini_endpoint_and_headers(base_url, model, api_key, key_in_header, generate_content=True)
|
|
430
428
|
|
|
431
429
|
# data["contents"][-1]["role"] = "model"
|
|
432
430
|
if add_postfunc_model_messages:
|
|
433
431
|
data["contents"] = add_dummy_model_messages(data["contents"])
|
|
434
432
|
|
|
435
|
-
|
|
433
|
+
response_json = make_post_request(url, headers, data)
|
|
436
434
|
try:
|
|
437
|
-
response = requests.post(url, headers=headers, json=data)
|
|
438
|
-
printd(f"response = {response}")
|
|
439
|
-
response.raise_for_status() # Raises HTTPError for 4XX/5XX status
|
|
440
|
-
response = response.json() # convert to dict from string
|
|
441
|
-
printd(f"response.json = {response}")
|
|
442
|
-
|
|
443
|
-
# Convert Google AI response to ChatCompletion style
|
|
444
435
|
return convert_google_ai_response_to_chatcompletion(
|
|
445
|
-
response_json=
|
|
446
|
-
model=model,
|
|
436
|
+
response_json=response_json,
|
|
437
|
+
model=data.get("model"),
|
|
447
438
|
input_messages=data["contents"],
|
|
448
|
-
pull_inner_thoughts_from_args=inner_thoughts_in_kwargs,
|
|
439
|
+
pull_inner_thoughts_from_args=data.get("inner_thoughts_in_kwargs", False),
|
|
449
440
|
)
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
printd(f"Got HTTPError, exception={http_err}, payload={data}")
|
|
454
|
-
# Print the HTTP status code
|
|
455
|
-
print(f"HTTP Error: {http_err.response.status_code}")
|
|
456
|
-
# Print the response content (error message from server)
|
|
457
|
-
print(f"Message: {http_err.response.text}")
|
|
458
|
-
raise http_err
|
|
459
|
-
|
|
460
|
-
except requests.exceptions.RequestException as req_err:
|
|
461
|
-
# Handle other requests-related errors (e.g., connection error)
|
|
462
|
-
printd(f"Got RequestException, exception={req_err}")
|
|
463
|
-
raise req_err
|
|
464
|
-
|
|
465
|
-
except Exception as e:
|
|
466
|
-
# Handle other potential errors
|
|
467
|
-
printd(f"Got unknown Exception, exception={e}")
|
|
468
|
-
raise e
|
|
441
|
+
except Exception as conversion_error:
|
|
442
|
+
print(f"Error during response conversion: {conversion_error}")
|
|
443
|
+
raise conversion_error
|