letta-nightly 0.4.1.dev20241008104105__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.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/PKG-INFO +1 -1
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/agent.py +18 -2
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/client/client.py +8 -1
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/credentials.py +2 -2
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/schema_generator.py +1 -1
- {letta_nightly-0.4.1.dev20241008104105 → 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.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/google_ai.py +39 -64
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/helpers.py +57 -2
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/llm_api_tools.py +4 -3
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/openai.py +5 -49
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/main.py +1 -1
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/metadata.py +2 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/providers.py +139 -30
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/agent.py +14 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/llm_config.py +0 -3
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/chat_completion_response.py +3 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/tool.py +3 -3
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/assistants/threads.py +5 -5
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/chat_completions/chat_completions.py +2 -2
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/agents.py +11 -11
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/blocks.py +2 -2
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/jobs.py +2 -2
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/sources.py +12 -12
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/tools.py +6 -6
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/server.py +18 -5
- letta_nightly-0.4.1.dev20241009104130/letta/settings.py +89 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/pyproject.toml +2 -1
- letta_nightly-0.4.1.dev20241008104105/letta/llm_api/azure_openai.py +0 -151
- letta_nightly-0.4.1.dev20241008104105/letta/settings.py +0 -198
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/LICENSE +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/README.md +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/__main__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/chroma.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/db.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/lancedb.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/milvus.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/qdrant.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/agent_store/storage.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/benchmark/benchmark.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/benchmark/constants.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/cli/cli.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/cli/cli_config.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/cli/cli_load.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/client/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/client/admin.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/client/streaming.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/client/utils.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/config.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/configs/anthropic.json +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/configs/letta_hosted.json +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/configs/openai.json +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/constants.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/data_sources/connectors.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/embeddings.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/errors.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/function_sets/base.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/function_sets/extras.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/functions.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/functions/helpers.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/humans/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/humans/examples/basic.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/humans/examples/cs_phd.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/interface.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/llm_api/cohere.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/README.md +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/chat_completion_proxy.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/constants.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/function_parser.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/grammars/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/grammars/gbnf_grammar_generator.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/grammars/json.gbnf +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/grammars/json_func_calls_with_inner_thoughts.gbnf +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/json_parser.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/koboldcpp/api.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/koboldcpp/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llamacpp/api.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llamacpp/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/airoboros.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/chatml.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/dolphin.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/llama3.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/wrapper_base.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/llm_chat_completion_wrappers/zephyr.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/lmstudio/api.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/lmstudio/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/ollama/api.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/ollama/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/settings/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/settings/deterministic_mirostat.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/settings/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/settings/simple.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/utils.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/vllm/api.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/webui/api.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/webui/legacy_api.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/webui/legacy_settings.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/local_llm/webui/settings.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/log.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/memory.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/openai_backcompat/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/openai_backcompat/openai_object.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/persistence_manager.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/anna_pa.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/google_search_persona.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/memgpt_doc.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/memgpt_starter.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/sam.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/sam_pov.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/sam_simple_pov_gpt35.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/personas/examples/sqldb/test.db +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/gpt_summarize.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/gpt_system.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_base.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_chat.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_chat_compressed.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_chat_fstring.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_doc.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_gpt35_extralong.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_intuitive_knowledge.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/prompts/system/memgpt_modified_chat.txt +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/pytest.ini +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/api_key.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/block.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/document.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/embedding_config.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/enums.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/health.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/job.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/letta_base.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/letta_message.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/letta_request.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/letta_response.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/memory.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/message.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/chat_completion_request.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/chat_completions.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/embedding_response.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/openai/openai.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/organization.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/passage.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/source.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/usage.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/schemas/user.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/constants.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/admin/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/admin/agents.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/admin/tools.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/admin/users.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/app.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/auth/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/auth/index.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/auth_token.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/interface.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/assistants/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/assistants/assistants.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/assistants/schemas.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/openai/chat_completions/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/health.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/llms.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/organizations.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/routers/v1/users.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/static_files.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/rest_api/utils.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/startup.sh +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/assets/index-3ab03d5b.css +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/assets/index-9a9c449b.js +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/favicon.ico +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/index.html +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/static_files/memgpt_logo_transparent.png +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/utils.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/__init__.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/example_client.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/interface.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/protocol.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/server/ws_api/server.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/streaming_interface.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/system.py +0 -0
- {letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/utils.py +0 -0
{letta_nightly-0.4.1.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/agent.py
RENAMED
|
@@ -239,6 +239,7 @@ class Agent(BaseAgent):
|
|
|
239
239
|
assert isinstance(self.agent_state.memory, Memory), f"Memory object is not of type Memory: {type(self.agent_state.memory)}"
|
|
240
240
|
|
|
241
241
|
# link tools
|
|
242
|
+
self.tools = tools
|
|
242
243
|
self.link_tools(tools)
|
|
243
244
|
|
|
244
245
|
# gpt-4, gpt-3.5-turbo, ...
|
|
@@ -338,6 +339,9 @@ class Agent(BaseAgent):
|
|
|
338
339
|
for tool_name in self.agent_state.tools:
|
|
339
340
|
assert tool_name in [tool.name for tool in tools], f"Tool name {tool_name} not included in agent tool list"
|
|
340
341
|
|
|
342
|
+
# Update tools
|
|
343
|
+
self.tools = tools
|
|
344
|
+
|
|
341
345
|
# Store the functions schemas (this is passed as an argument to ChatCompletion)
|
|
342
346
|
self.functions = []
|
|
343
347
|
self.functions_python = {}
|
|
@@ -482,7 +486,7 @@ class Agent(BaseAgent):
|
|
|
482
486
|
inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
|
|
483
487
|
)
|
|
484
488
|
|
|
485
|
-
if len(response.choices) == 0:
|
|
489
|
+
if len(response.choices) == 0 or response.choices[0] is None:
|
|
486
490
|
raise Exception(f"API call didn't return a message: {response}")
|
|
487
491
|
|
|
488
492
|
# special case for 'length'
|
|
@@ -552,9 +556,12 @@ class Agent(BaseAgent):
|
|
|
552
556
|
) # extend conversation with assistant's reply
|
|
553
557
|
printd(f"Function call message: {messages[-1]}")
|
|
554
558
|
|
|
559
|
+
nonnull_content = False
|
|
555
560
|
if response_message.content:
|
|
556
561
|
# The content if then internal monologue, not chat
|
|
557
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
|
|
558
565
|
|
|
559
566
|
# Step 3: call the function
|
|
560
567
|
# Note: the JSON response may not always be valid; be sure to handle errors
|
|
@@ -615,12 +622,17 @@ class Agent(BaseAgent):
|
|
|
615
622
|
if "inner_thoughts" in function_args:
|
|
616
623
|
response_message.content = function_args.pop("inner_thoughts")
|
|
617
624
|
# The content if then internal monologue, not chat
|
|
618
|
-
if response_message.content:
|
|
625
|
+
if response_message.content and not nonnull_content:
|
|
619
626
|
self.interface.internal_monologue(response_message.content, msg_obj=messages[-1])
|
|
620
627
|
|
|
621
628
|
# (Still parsing function args)
|
|
622
629
|
# Handle requests for immediate heartbeat
|
|
623
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
|
+
|
|
624
636
|
if not isinstance(heartbeat_request, bool) or heartbeat_request is None:
|
|
625
637
|
printd(
|
|
626
638
|
f"{CLI_WARNING_PREFIX}'request_heartbeat' arg parsed was not a bool or None, type={type(heartbeat_request)}, value={heartbeat_request}"
|
|
@@ -1353,6 +1365,10 @@ def save_agent(agent: Agent, ms: MetadataStore):
|
|
|
1353
1365
|
else:
|
|
1354
1366
|
ms.create_agent(agent_state)
|
|
1355
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
|
+
|
|
1356
1372
|
agent.agent_state = ms.get_agent(agent_id=agent_id)
|
|
1357
1373
|
assert isinstance(agent.agent_state.memory, Memory), f"Memory is not a Memory object: {type(agent_state.memory)}"
|
|
1358
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.dev20241008104105 → letta_nightly-0.4.1.dev20241009104130}/letta/credentials.py
RENAMED
|
@@ -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)
|
|
@@ -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
|
|
@@ -1,14 +1,69 @@
|
|
|
1
1
|
import copy
|
|
2
2
|
import json
|
|
3
3
|
import warnings
|
|
4
|
-
from typing import List, Union
|
|
4
|
+
from typing import Any, List, Union
|
|
5
5
|
|
|
6
6
|
import requests
|
|
7
7
|
|
|
8
8
|
from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING
|
|
9
9
|
from letta.schemas.enums import OptionState
|
|
10
10
|
from letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choice
|
|
11
|
-
from letta.utils import json_dumps
|
|
11
|
+
from letta.utils import json_dumps, printd
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def make_post_request(url: str, headers: dict[str, str], data: dict[str, Any]) -> dict[str, Any]:
|
|
15
|
+
printd(f"Sending request to {url}")
|
|
16
|
+
try:
|
|
17
|
+
# Make the POST request
|
|
18
|
+
response = requests.post(url, headers=headers, json=data)
|
|
19
|
+
printd(f"Response status code: {response.status_code}")
|
|
20
|
+
|
|
21
|
+
# Raise for 4XX/5XX HTTP errors
|
|
22
|
+
response.raise_for_status()
|
|
23
|
+
|
|
24
|
+
# Ensure the content is JSON before parsing
|
|
25
|
+
if response.headers.get("Content-Type") == "application/json":
|
|
26
|
+
response_data = response.json() # Convert to dict from JSON
|
|
27
|
+
printd(f"Response JSON: {response_data}")
|
|
28
|
+
else:
|
|
29
|
+
error_message = f"Unexpected content type returned: {response.headers.get('Content-Type')}"
|
|
30
|
+
printd(error_message)
|
|
31
|
+
raise ValueError(error_message)
|
|
32
|
+
|
|
33
|
+
# Process the response using the callback function
|
|
34
|
+
return response_data
|
|
35
|
+
|
|
36
|
+
except requests.exceptions.HTTPError as http_err:
|
|
37
|
+
# HTTP errors (4XX, 5XX)
|
|
38
|
+
error_message = f"HTTP error occurred: {http_err}"
|
|
39
|
+
if http_err.response is not None:
|
|
40
|
+
error_message += f" | Status code: {http_err.response.status_code}, Message: {http_err.response.text}"
|
|
41
|
+
printd(error_message)
|
|
42
|
+
raise requests.exceptions.HTTPError(error_message) from http_err
|
|
43
|
+
|
|
44
|
+
except requests.exceptions.Timeout as timeout_err:
|
|
45
|
+
# Handle timeout errors
|
|
46
|
+
error_message = f"Request timed out: {timeout_err}"
|
|
47
|
+
printd(error_message)
|
|
48
|
+
raise requests.exceptions.Timeout(error_message) from timeout_err
|
|
49
|
+
|
|
50
|
+
except requests.exceptions.RequestException as req_err:
|
|
51
|
+
# Non-HTTP errors (e.g., connection, SSL errors)
|
|
52
|
+
error_message = f"Request failed: {req_err}"
|
|
53
|
+
printd(error_message)
|
|
54
|
+
raise requests.exceptions.RequestException(error_message) from req_err
|
|
55
|
+
|
|
56
|
+
except ValueError as val_err:
|
|
57
|
+
# Handle content-type or non-JSON response issues
|
|
58
|
+
error_message = f"ValueError: {val_err}"
|
|
59
|
+
printd(error_message)
|
|
60
|
+
raise ValueError(error_message) from val_err
|
|
61
|
+
|
|
62
|
+
except Exception as e:
|
|
63
|
+
# Catch any other unknown exceptions
|
|
64
|
+
error_message = f"An unexpected error occurred: {e}"
|
|
65
|
+
printd(error_message)
|
|
66
|
+
raise Exception(error_message) from e
|
|
12
67
|
|
|
13
68
|
|
|
14
69
|
# TODO update to use better types
|
|
@@ -28,7 +28,6 @@ from letta.local_llm.constants import (
|
|
|
28
28
|
INNER_THOUGHTS_KWARG,
|
|
29
29
|
INNER_THOUGHTS_KWARG_DESCRIPTION,
|
|
30
30
|
)
|
|
31
|
-
from letta.providers import GoogleAIProvider
|
|
32
31
|
from letta.schemas.enums import OptionState
|
|
33
32
|
from letta.schemas.llm_config import LLMConfig
|
|
34
33
|
from letta.schemas.message import Message
|
|
@@ -189,6 +188,9 @@ def create(
|
|
|
189
188
|
if model_settings.azure_base_url is None:
|
|
190
189
|
raise ValueError(f"Azure base url is missing. Did you set AZURE_BASE_URL in your env?")
|
|
191
190
|
|
|
191
|
+
if model_settings.azure_api_version is None:
|
|
192
|
+
raise ValueError(f"Azure API version is missing. Did you set AZURE_API_VERSION in your env?")
|
|
193
|
+
|
|
192
194
|
# Set the llm config model_endpoint from model_settings
|
|
193
195
|
# 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
|
|
194
196
|
llm_config.model_endpoint = model_settings.azure_base_url
|
|
@@ -228,7 +230,7 @@ def create(
|
|
|
228
230
|
|
|
229
231
|
return google_ai_chat_completions_request(
|
|
230
232
|
inner_thoughts_in_kwargs=google_ai_inner_thoughts_in_kwarg,
|
|
231
|
-
|
|
233
|
+
base_url=llm_config.model_endpoint,
|
|
232
234
|
model=llm_config.model,
|
|
233
235
|
api_key=model_settings.gemini_api_key,
|
|
234
236
|
# see structure of payload here: https://ai.google.dev/docs/function_calling
|
|
@@ -296,7 +298,6 @@ def create(
|
|
|
296
298
|
raise NotImplementedError(f"Streaming not yet implemented for Groq.")
|
|
297
299
|
|
|
298
300
|
if model_settings.groq_api_key is None and llm_config.model_endpoint == "https://api.groq.com/openai/v1/chat/completions":
|
|
299
|
-
# only is a problem if we are *not* using an openai proxy
|
|
300
301
|
raise ValueError(f"Groq key is missing from letta config file")
|
|
301
302
|
|
|
302
303
|
# force to true for groq, since they don't support 'content' is non-null
|
|
@@ -9,7 +9,7 @@ from httpx_sse._exceptions import SSEError
|
|
|
9
9
|
|
|
10
10
|
from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING
|
|
11
11
|
from letta.errors import LLMError
|
|
12
|
-
from letta.llm_api.helpers import add_inner_thoughts_to_functions
|
|
12
|
+
from letta.llm_api.helpers import add_inner_thoughts_to_functions, make_post_request
|
|
13
13
|
from letta.local_llm.constants import (
|
|
14
14
|
INNER_THOUGHTS_KWARG,
|
|
15
15
|
INNER_THOUGHTS_KWARG_DESCRIPTION,
|
|
@@ -483,58 +483,14 @@ def openai_chat_completions_request(
|
|
|
483
483
|
data.pop("tools")
|
|
484
484
|
data.pop("tool_choice", None) # extra safe, should exist always (default="auto")
|
|
485
485
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
response = requests.post(url, headers=headers, json=data)
|
|
489
|
-
printd(f"response = {response}, response.text = {response.text}")
|
|
490
|
-
# print(json.dumps(data, indent=4))
|
|
491
|
-
# raise requests.exceptions.HTTPError
|
|
492
|
-
response.raise_for_status() # Raises HTTPError for 4XX/5XX status
|
|
493
|
-
|
|
494
|
-
response = response.json() # convert to dict from string
|
|
495
|
-
printd(f"response.json = {response}")
|
|
496
|
-
|
|
497
|
-
response = ChatCompletionResponse(**response) # convert to 'dot-dict' style which is the openai python client default
|
|
498
|
-
return response
|
|
499
|
-
except requests.exceptions.HTTPError as http_err:
|
|
500
|
-
# Handle HTTP errors (e.g., response 4XX, 5XX)
|
|
501
|
-
printd(f"Got HTTPError, exception={http_err}, payload={data}")
|
|
502
|
-
raise http_err
|
|
503
|
-
except requests.exceptions.RequestException as req_err:
|
|
504
|
-
# Handle other requests-related errors (e.g., connection error)
|
|
505
|
-
printd(f"Got RequestException, exception={req_err}")
|
|
506
|
-
raise req_err
|
|
507
|
-
except Exception as e:
|
|
508
|
-
# Handle other potential errors
|
|
509
|
-
printd(f"Got unknown Exception, exception={e}")
|
|
510
|
-
raise e
|
|
486
|
+
response_json = make_post_request(url, headers, data)
|
|
487
|
+
return ChatCompletionResponse(**response_json)
|
|
511
488
|
|
|
512
489
|
|
|
513
490
|
def openai_embeddings_request(url: str, api_key: str, data: dict) -> EmbeddingResponse:
|
|
514
491
|
"""https://platform.openai.com/docs/api-reference/embeddings/create"""
|
|
515
|
-
from letta.utils import printd
|
|
516
492
|
|
|
517
493
|
url = smart_urljoin(url, "embeddings")
|
|
518
494
|
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {api_key}"}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
try:
|
|
522
|
-
response = requests.post(url, headers=headers, json=data)
|
|
523
|
-
printd(f"response = {response}")
|
|
524
|
-
response.raise_for_status() # Raises HTTPError for 4XX/5XX status
|
|
525
|
-
response = response.json() # convert to dict from string
|
|
526
|
-
printd(f"response.json = {response}")
|
|
527
|
-
response = EmbeddingResponse(**response) # convert to 'dot-dict' style which is the openai python client default
|
|
528
|
-
return response
|
|
529
|
-
except requests.exceptions.HTTPError as http_err:
|
|
530
|
-
# Handle HTTP errors (e.g., response 4XX, 5XX)
|
|
531
|
-
printd(f"Got HTTPError, exception={http_err}, payload={data}")
|
|
532
|
-
raise http_err
|
|
533
|
-
except requests.exceptions.RequestException as req_err:
|
|
534
|
-
# Handle other requests-related errors (e.g., connection error)
|
|
535
|
-
printd(f"Got RequestException, exception={req_err}")
|
|
536
|
-
raise req_err
|
|
537
|
-
except Exception as e:
|
|
538
|
-
# Handle other potential errors
|
|
539
|
-
printd(f"Got unknown Exception, exception={e}")
|
|
540
|
-
raise e
|
|
495
|
+
response_json = make_post_request(url, headers, data)
|
|
496
|
+
return EmbeddingResponse(**response_json)
|