letta-nightly 0.4.1.dev20241007104134__tar.gz → 0.4.1.dev20241008104105__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.

Files changed (191) hide show
  1. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/PKG-INFO +1 -1
  2. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/agent.py +19 -9
  3. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/credentials.py +1 -1
  4. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/errors.py +1 -1
  5. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/llm_api/azure_openai.py +15 -19
  6. letta_nightly-0.4.1.dev20241008104105/letta/llm_api/helpers.py +153 -0
  7. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/llm_api/llm_api_tools.py +39 -215
  8. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/llm_api/openai.py +70 -2
  9. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/providers.py +5 -1
  10. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/llm_config.py +5 -2
  11. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/admin/tools.py +0 -1
  12. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/app.py +1 -17
  13. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/openai/assistants/threads.py +9 -6
  14. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/openai/chat_completions/chat_completions.py +4 -2
  15. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/agents.py +23 -13
  16. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/blocks.py +5 -3
  17. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/jobs.py +5 -3
  18. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/sources.py +24 -12
  19. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/tools.py +11 -6
  20. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/server.py +17 -34
  21. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/settings.py +2 -1
  22. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/pyproject.toml +1 -1
  23. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/LICENSE +0 -0
  24. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/README.md +0 -0
  25. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/__init__.py +0 -0
  26. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/__main__.py +0 -0
  27. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/agent_store/chroma.py +0 -0
  28. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/agent_store/db.py +0 -0
  29. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/agent_store/lancedb.py +0 -0
  30. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/agent_store/milvus.py +0 -0
  31. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/agent_store/qdrant.py +0 -0
  32. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/agent_store/storage.py +0 -0
  33. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/benchmark/benchmark.py +0 -0
  34. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/benchmark/constants.py +0 -0
  35. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/cli/cli.py +0 -0
  36. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/cli/cli_config.py +0 -0
  37. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/cli/cli_load.py +0 -0
  38. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/client/__init__.py +0 -0
  39. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/client/admin.py +0 -0
  40. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/client/client.py +0 -0
  41. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/client/streaming.py +0 -0
  42. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/client/utils.py +0 -0
  43. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/config.py +0 -0
  44. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/configs/anthropic.json +0 -0
  45. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/configs/letta_hosted.json +0 -0
  46. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/configs/openai.json +0 -0
  47. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/constants.py +0 -0
  48. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/data_sources/connectors.py +0 -0
  49. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/embeddings.py +0 -0
  50. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/functions/__init__.py +0 -0
  51. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/functions/function_sets/base.py +0 -0
  52. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/functions/function_sets/extras.py +0 -0
  53. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/functions/functions.py +0 -0
  54. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/functions/helpers.py +0 -0
  55. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/functions/schema_generator.py +0 -0
  56. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/humans/__init__.py +0 -0
  57. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/humans/examples/basic.txt +0 -0
  58. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/humans/examples/cs_phd.txt +0 -0
  59. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/interface.py +0 -0
  60. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/llm_api/__init__.py +0 -0
  61. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/llm_api/anthropic.py +0 -0
  62. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/llm_api/cohere.py +0 -0
  63. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/llm_api/google_ai.py +0 -0
  64. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/README.md +0 -0
  65. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/__init__.py +0 -0
  66. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/chat_completion_proxy.py +0 -0
  67. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/constants.py +0 -0
  68. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/function_parser.py +0 -0
  69. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/grammars/__init__.py +0 -0
  70. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/grammars/gbnf_grammar_generator.py +0 -0
  71. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/grammars/json.gbnf +0 -0
  72. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/grammars/json_func_calls_with_inner_thoughts.gbnf +0 -0
  73. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/json_parser.py +0 -0
  74. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/koboldcpp/api.py +0 -0
  75. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/koboldcpp/settings.py +0 -0
  76. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llamacpp/api.py +0 -0
  77. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llamacpp/settings.py +0 -0
  78. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/__init__.py +0 -0
  79. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/airoboros.py +0 -0
  80. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/chatml.py +0 -0
  81. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py +0 -0
  82. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/dolphin.py +0 -0
  83. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/llama3.py +0 -0
  84. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.py +0 -0
  85. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/wrapper_base.py +0 -0
  86. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/llm_chat_completion_wrappers/zephyr.py +0 -0
  87. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/lmstudio/api.py +0 -0
  88. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/lmstudio/settings.py +0 -0
  89. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/ollama/api.py +0 -0
  90. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/ollama/settings.py +0 -0
  91. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/settings/__init__.py +0 -0
  92. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/settings/deterministic_mirostat.py +0 -0
  93. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/settings/settings.py +0 -0
  94. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/settings/simple.py +0 -0
  95. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/utils.py +0 -0
  96. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/vllm/api.py +0 -0
  97. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/webui/api.py +0 -0
  98. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/webui/legacy_api.py +0 -0
  99. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/webui/legacy_settings.py +0 -0
  100. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/local_llm/webui/settings.py +0 -0
  101. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/log.py +0 -0
  102. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/main.py +0 -0
  103. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/memory.py +0 -0
  104. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/metadata.py +0 -0
  105. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/openai_backcompat/__init__.py +0 -0
  106. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/openai_backcompat/openai_object.py +0 -0
  107. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/persistence_manager.py +0 -0
  108. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/__init__.py +0 -0
  109. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/examples/anna_pa.txt +0 -0
  110. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/examples/google_search_persona.txt +0 -0
  111. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/examples/memgpt_doc.txt +0 -0
  112. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/examples/memgpt_starter.txt +0 -0
  113. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/examples/sam.txt +0 -0
  114. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/examples/sam_pov.txt +0 -0
  115. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/examples/sam_simple_pov_gpt35.txt +0 -0
  116. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/personas/examples/sqldb/test.db +0 -0
  117. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/__init__.py +0 -0
  118. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/gpt_summarize.py +0 -0
  119. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/gpt_system.py +0 -0
  120. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/system/memgpt_base.txt +0 -0
  121. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/system/memgpt_chat.txt +0 -0
  122. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/system/memgpt_chat_compressed.txt +0 -0
  123. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/system/memgpt_chat_fstring.txt +0 -0
  124. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/system/memgpt_doc.txt +0 -0
  125. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/system/memgpt_gpt35_extralong.txt +0 -0
  126. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/system/memgpt_intuitive_knowledge.txt +0 -0
  127. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/prompts/system/memgpt_modified_chat.txt +0 -0
  128. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/pytest.ini +0 -0
  129. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/agent.py +0 -0
  130. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/api_key.py +0 -0
  131. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/block.py +0 -0
  132. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/document.py +0 -0
  133. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/embedding_config.py +0 -0
  134. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/enums.py +0 -0
  135. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/health.py +0 -0
  136. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/job.py +0 -0
  137. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/letta_base.py +0 -0
  138. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/letta_message.py +0 -0
  139. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/letta_request.py +0 -0
  140. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/letta_response.py +0 -0
  141. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/memory.py +0 -0
  142. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/message.py +0 -0
  143. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/openai/chat_completion_request.py +0 -0
  144. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/openai/chat_completion_response.py +0 -0
  145. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/openai/chat_completions.py +0 -0
  146. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/openai/embedding_response.py +0 -0
  147. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/openai/openai.py +0 -0
  148. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/organization.py +0 -0
  149. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/passage.py +0 -0
  150. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/source.py +0 -0
  151. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/tool.py +0 -0
  152. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/usage.py +0 -0
  153. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/schemas/user.py +0 -0
  154. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/__init__.py +0 -0
  155. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/constants.py +0 -0
  156. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/__init__.py +0 -0
  157. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/admin/__init__.py +0 -0
  158. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/admin/agents.py +0 -0
  159. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/admin/users.py +0 -0
  160. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/auth/__init__.py +0 -0
  161. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/auth/index.py +0 -0
  162. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/auth_token.py +0 -0
  163. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/interface.py +0 -0
  164. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/__init__.py +0 -0
  165. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/openai/__init__.py +0 -0
  166. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/openai/assistants/__init__.py +0 -0
  167. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/openai/assistants/assistants.py +0 -0
  168. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/openai/assistants/schemas.py +0 -0
  169. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/openai/chat_completions/__init__.py +0 -0
  170. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/__init__.py +0 -0
  171. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/health.py +0 -0
  172. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/llms.py +0 -0
  173. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/organizations.py +0 -0
  174. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/routers/v1/users.py +0 -0
  175. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/static_files.py +0 -0
  176. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/rest_api/utils.py +0 -0
  177. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/startup.sh +0 -0
  178. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/static_files/assets/index-3ab03d5b.css +0 -0
  179. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/static_files/assets/index-9a9c449b.js +0 -0
  180. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/static_files/favicon.ico +0 -0
  181. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/static_files/index.html +0 -0
  182. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/static_files/memgpt_logo_transparent.png +0 -0
  183. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/utils.py +0 -0
  184. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/ws_api/__init__.py +0 -0
  185. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/ws_api/example_client.py +0 -0
  186. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/ws_api/interface.py +0 -0
  187. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/ws_api/protocol.py +0 -0
  188. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/server/ws_api/server.py +0 -0
  189. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/streaming_interface.py +0 -0
  190. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/system.py +0 -0
  191. {letta_nightly-0.4.1.dev20241007104134 → letta_nightly-0.4.1.dev20241008104105}/letta/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: letta-nightly
3
- Version: 0.4.1.dev20241007104134
3
+ Version: 0.4.1.dev20241008104105
4
4
  Summary: Create LLM agents with long-term memory and custom tools
5
5
  License: Apache License
6
6
  Author: Letta Team
@@ -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, is_context_overflow_error
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
- inner_thoughts_in_kwargs: OptionState = OptionState.DEFAULT,
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],
@@ -460,7 +461,7 @@ class Agent(BaseAgent):
460
461
  function_call: str = "auto",
461
462
  first_message: bool = False, # hint
462
463
  stream: bool = False, # TODO move to config?
463
- inner_thoughts_in_kwargs: OptionState = OptionState.DEFAULT,
464
+ inner_thoughts_in_kwargs_option: OptionState = OptionState.DEFAULT,
464
465
  ) -> ChatCompletionResponse:
465
466
  """Get response from LLM API"""
466
467
  try:
@@ -478,7 +479,7 @@ class Agent(BaseAgent):
478
479
  stream=stream,
479
480
  stream_inferface=self.interface,
480
481
  # putting inner thoughts in func args or not
481
- inner_thoughts_in_kwargs=inner_thoughts_in_kwargs,
482
+ inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
482
483
  )
483
484
 
484
485
  if len(response.choices) == 0:
@@ -560,6 +561,8 @@ class Agent(BaseAgent):
560
561
  function_call = (
561
562
  response_message.function_call if response_message.function_call is not None else response_message.tool_calls[0].function
562
563
  )
564
+
565
+ # Get the name of the function
563
566
  function_name = function_call.name
564
567
  printd(f"Request to call function {function_name} with tool_call_id: {tool_call_id}")
565
568
 
@@ -608,6 +611,13 @@ class Agent(BaseAgent):
608
611
  self.interface.function_message(f"Error: {error_msg}", msg_obj=messages[-1])
609
612
  return messages, False, True # force a heartbeat to allow agent to handle error
610
613
 
614
+ # Check if inner thoughts is in the function call arguments (possible apparently if you are using Azure)
615
+ if "inner_thoughts" in function_args:
616
+ response_message.content = function_args.pop("inner_thoughts")
617
+ # The content if then internal monologue, not chat
618
+ if response_message.content:
619
+ self.interface.internal_monologue(response_message.content, msg_obj=messages[-1])
620
+
611
621
  # (Still parsing function args)
612
622
  # Handle requests for immediate heartbeat
613
623
  heartbeat_request = function_args.pop("request_heartbeat", None)
@@ -716,7 +726,7 @@ class Agent(BaseAgent):
716
726
  recreate_message_timestamp: bool = True, # if True, when input is a Message type, recreated the 'created_at' field
717
727
  stream: bool = False, # TODO move to config?
718
728
  timestamp: Optional[datetime.datetime] = None,
719
- inner_thoughts_in_kwargs: OptionState = OptionState.DEFAULT,
729
+ inner_thoughts_in_kwargs_option: OptionState = OptionState.DEFAULT,
720
730
  ms: Optional[MetadataStore] = None,
721
731
  ) -> AgentStepResponse:
722
732
  """Top-level event message handler for the Letta agent"""
@@ -795,7 +805,7 @@ class Agent(BaseAgent):
795
805
  message_sequence=input_message_sequence,
796
806
  first_message=True, # passed through to the prompt formatter
797
807
  stream=stream,
798
- inner_thoughts_in_kwargs=inner_thoughts_in_kwargs,
808
+ inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
799
809
  )
800
810
  if verify_first_message_correctness(response, require_monologue=self.first_message_verify_mono):
801
811
  break
@@ -808,7 +818,7 @@ class Agent(BaseAgent):
808
818
  response = self._get_ai_reply(
809
819
  message_sequence=input_message_sequence,
810
820
  stream=stream,
811
- inner_thoughts_in_kwargs=inner_thoughts_in_kwargs,
821
+ inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
812
822
  )
813
823
 
814
824
  # Step 3: check if LLM wanted to call a function
@@ -892,7 +902,7 @@ class Agent(BaseAgent):
892
902
  recreate_message_timestamp=recreate_message_timestamp,
893
903
  stream=stream,
894
904
  timestamp=timestamp,
895
- inner_thoughts_in_kwargs=inner_thoughts_in_kwargs,
905
+ inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs_option,
896
906
  ms=ms,
897
907
  )
898
908
 
@@ -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] = None
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")
@@ -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.model_dump_json(indent=4) for message in messages], indent=4)
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
 
@@ -2,8 +2,11 @@ from typing import Union
2
2
 
3
3
  import requests
4
4
 
5
+ from letta.schemas.llm_config import LLMConfig
5
6
  from letta.schemas.openai.chat_completion_response import ChatCompletionResponse
7
+ from letta.schemas.openai.chat_completions import ChatCompletionRequest
6
8
  from letta.schemas.openai.embedding_response import EmbeddingResponse
9
+ from letta.settings import ModelSettings
7
10
  from letta.utils import smart_urljoin
8
11
 
9
12
  MODEL_TO_AZURE_ENGINE = {
@@ -13,17 +16,16 @@ MODEL_TO_AZURE_ENGINE = {
13
16
  "gpt-3.5": "gpt-35-turbo",
14
17
  "gpt-3.5-turbo": "gpt-35-turbo",
15
18
  "gpt-3.5-turbo-16k": "gpt-35-turbo-16k",
19
+ "gpt-4o-mini": "gpt-4o-mini",
16
20
  }
17
21
 
18
22
 
19
- def clean_azure_endpoint(raw_endpoint_name: str) -> str:
20
- """Make sure the endpoint is of format 'https://YOUR_RESOURCE_NAME.openai.azure.com'"""
21
- if raw_endpoint_name is None:
22
- raise ValueError(raw_endpoint_name)
23
- endpoint_address = raw_endpoint_name.strip("/").replace(".openai.azure.com", "")
24
- endpoint_address = endpoint_address.replace("http://", "")
25
- endpoint_address = endpoint_address.replace("https://", "")
26
- return endpoint_address
23
+ def get_azure_endpoint(llm_config: LLMConfig, model_settings: ModelSettings):
24
+ assert llm_config.api_version, "Missing model version! This field must be provided in the LLM config for Azure."
25
+ assert llm_config.model in MODEL_TO_AZURE_ENGINE, f"{llm_config.model} not in supported models: {list(MODEL_TO_AZURE_ENGINE.keys())}"
26
+
27
+ model = MODEL_TO_AZURE_ENGINE[llm_config.model]
28
+ return f"{model_settings.azure_base_url}/openai/deployments/{model}/chat/completions?api-version={llm_config.api_version}"
27
29
 
28
30
 
29
31
  def azure_openai_get_model_list(url: str, api_key: Union[str, None], api_version: str) -> dict:
@@ -72,19 +74,15 @@ def azure_openai_get_model_list(url: str, api_key: Union[str, None], api_version
72
74
 
73
75
 
74
76
  def azure_openai_chat_completions_request(
75
- resource_name: str, deployment_id: str, api_version: str, api_key: str, data: dict
77
+ model_settings: ModelSettings, llm_config: LLMConfig, api_key: str, chat_completion_request: ChatCompletionRequest
76
78
  ) -> ChatCompletionResponse:
77
79
  """https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions"""
78
80
  from letta.utils import printd
79
81
 
80
- assert resource_name is not None, "Missing required field when calling Azure OpenAI"
81
- assert deployment_id is not None, "Missing required field when calling Azure OpenAI"
82
- assert api_version is not None, "Missing required field when calling Azure OpenAI"
83
82
  assert api_key is not None, "Missing required field when calling Azure OpenAI"
84
83
 
85
- resource_name = clean_azure_endpoint(resource_name)
86
- url = f"https://{resource_name}.openai.azure.com/openai/deployments/{deployment_id}/chat/completions?api-version={api_version}"
87
84
  headers = {"Content-Type": "application/json", "api-key": f"{api_key}"}
85
+ data = chat_completion_request.model_dump(exclude_none=True)
88
86
 
89
87
  # If functions == None, strip from the payload
90
88
  if "functions" in data and data["functions"] is None:
@@ -95,11 +93,10 @@ def azure_openai_chat_completions_request(
95
93
  data.pop("tools")
96
94
  data.pop("tool_choice", None) # extra safe, should exist always (default="auto")
97
95
 
98
- printd(f"Sending request to {url}")
96
+ model_endpoint = get_azure_endpoint(llm_config, model_settings)
97
+ printd(f"Sending request to {model_endpoint}")
99
98
  try:
100
- data["messages"] = [i.to_openai_dict() for i in data["messages"]]
101
- response = requests.post(url, headers=headers, json=data)
102
- printd(f"response = {response}")
99
+ response = requests.post(model_endpoint, headers=headers, json=data)
103
100
  response.raise_for_status() # Raises HTTPError for 4XX/5XX status
104
101
  response = response.json() # convert to dict from string
105
102
  printd(f"response.json = {response}")
@@ -128,7 +125,6 @@ def azure_openai_embeddings_request(
128
125
  """https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#embeddings"""
129
126
  from letta.utils import printd
130
127
 
131
- resource_name = clean_azure_endpoint(resource_name)
132
128
  url = f"https://{resource_name}.openai.azure.com/openai/deployments/{deployment_id}/embeddings?api-version={api_version}"
133
129
  headers = {"Content-Type": "application/json", "api-key": f"{api_key}"}
134
130
 
@@ -0,0 +1,153 @@
1
+ import copy
2
+ import json
3
+ import warnings
4
+ from typing import List, Union
5
+
6
+ import requests
7
+
8
+ from letta.constants import OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING
9
+ from letta.schemas.enums import OptionState
10
+ from letta.schemas.openai.chat_completion_response import ChatCompletionResponse, Choice
11
+ from letta.utils import json_dumps
12
+
13
+
14
+ # TODO update to use better types
15
+ def add_inner_thoughts_to_functions(
16
+ functions: List[dict],
17
+ inner_thoughts_key: str,
18
+ inner_thoughts_description: str,
19
+ inner_thoughts_required: bool = True,
20
+ # inner_thoughts_to_front: bool = True, TODO support sorting somewhere, probably in the to_dict?
21
+ ) -> List[dict]:
22
+ """Add an inner_thoughts kwarg to every function in the provided list"""
23
+ # return copies
24
+ new_functions = []
25
+
26
+ # functions is a list of dicts in the OpenAI schema (https://platform.openai.com/docs/api-reference/chat/create)
27
+ for function_object in functions:
28
+ function_params = function_object["parameters"]["properties"]
29
+ required_params = list(function_object["parameters"]["required"])
30
+
31
+ # if the inner thoughts arg doesn't exist, add it
32
+ if inner_thoughts_key not in function_params:
33
+ function_params[inner_thoughts_key] = {
34
+ "type": "string",
35
+ "description": inner_thoughts_description,
36
+ }
37
+
38
+ # make sure it's tagged as required
39
+ new_function_object = copy.deepcopy(function_object)
40
+ if inner_thoughts_required and inner_thoughts_key not in required_params:
41
+ required_params.append(inner_thoughts_key)
42
+ new_function_object["parameters"]["required"] = required_params
43
+
44
+ new_functions.append(new_function_object)
45
+
46
+ # return a list of copies
47
+ return new_functions
48
+
49
+
50
+ def unpack_all_inner_thoughts_from_kwargs(
51
+ response: ChatCompletionResponse,
52
+ inner_thoughts_key: str,
53
+ ) -> ChatCompletionResponse:
54
+ """Strip the inner thoughts out of the tool call and put it in the message content"""
55
+ if len(response.choices) == 0:
56
+ raise ValueError(f"Unpacking inner thoughts from empty response not supported")
57
+
58
+ new_choices = []
59
+ for choice in response.choices:
60
+ new_choices.append(unpack_inner_thoughts_from_kwargs(choice, inner_thoughts_key))
61
+
62
+ # return an updated copy
63
+ new_response = response.model_copy(deep=True)
64
+ new_response.choices = new_choices
65
+ return new_response
66
+
67
+
68
+ def unpack_inner_thoughts_from_kwargs(choice: Choice, inner_thoughts_key: str) -> Choice:
69
+ message = choice.message
70
+ if message.role == "assistant" and message.tool_calls and len(message.tool_calls) >= 1:
71
+ if len(message.tool_calls) > 1:
72
+ warnings.warn(f"Unpacking inner thoughts from more than one tool call ({len(message.tool_calls)}) is not supported")
73
+ # TODO support multiple tool calls
74
+ tool_call = message.tool_calls[0]
75
+
76
+ try:
77
+ # Sadly we need to parse the JSON since args are in string format
78
+ func_args = dict(json.loads(tool_call.function.arguments))
79
+ if inner_thoughts_key in func_args:
80
+ # extract the inner thoughts
81
+ inner_thoughts = func_args.pop(inner_thoughts_key)
82
+
83
+ # replace the kwargs
84
+ new_choice = choice.model_copy(deep=True)
85
+ new_choice.message.tool_calls[0].function.arguments = json_dumps(func_args)
86
+ # also replace the message content
87
+ if new_choice.message.content is not None:
88
+ warnings.warn(f"Overwriting existing inner monologue ({new_choice.message.content}) with kwarg ({inner_thoughts})")
89
+ new_choice.message.content = inner_thoughts
90
+
91
+ return new_choice
92
+ else:
93
+ warnings.warn(f"Did not find inner thoughts in tool call: {str(tool_call)}")
94
+
95
+ except json.JSONDecodeError as e:
96
+ warnings.warn(f"Failed to strip inner thoughts from kwargs: {e}")
97
+ raise e
98
+
99
+
100
+ def is_context_overflow_error(exception: Union[requests.exceptions.RequestException, Exception]) -> bool:
101
+ """Checks if an exception is due to context overflow (based on common OpenAI response messages)"""
102
+ from letta.utils import printd
103
+
104
+ match_string = OPENAI_CONTEXT_WINDOW_ERROR_SUBSTRING
105
+
106
+ # Backwards compatibility with openai python package/client v0.28 (pre-v1 client migration)
107
+ if match_string in str(exception):
108
+ printd(f"Found '{match_string}' in str(exception)={(str(exception))}")
109
+ return True
110
+
111
+ # Based on python requests + OpenAI REST API (/v1)
112
+ elif isinstance(exception, requests.exceptions.HTTPError):
113
+ if exception.response is not None and "application/json" in exception.response.headers.get("Content-Type", ""):
114
+ try:
115
+ error_details = exception.response.json()
116
+ if "error" not in error_details:
117
+ printd(f"HTTPError occurred, but couldn't find error field: {error_details}")
118
+ return False
119
+ else:
120
+ error_details = error_details["error"]
121
+
122
+ # Check for the specific error code
123
+ if error_details.get("code") == "context_length_exceeded":
124
+ printd(f"HTTPError occurred, caught error code {error_details.get('code')}")
125
+ return True
126
+ # Soft-check for "maximum context length" inside of the message
127
+ elif error_details.get("message") and "maximum context length" in error_details.get("message"):
128
+ printd(f"HTTPError occurred, found '{match_string}' in error message contents ({error_details})")
129
+ return True
130
+ else:
131
+ printd(f"HTTPError occurred, but unknown error message: {error_details}")
132
+ return False
133
+ except ValueError:
134
+ # JSON decoding failed
135
+ printd(f"HTTPError occurred ({exception}), but no JSON error message.")
136
+
137
+ # Generic fail
138
+ else:
139
+ return False
140
+
141
+
142
+ def derive_inner_thoughts_in_kwargs(inner_thoughts_in_kwargs_option: OptionState, model: str):
143
+ if inner_thoughts_in_kwargs_option == OptionState.DEFAULT:
144
+ # model that are known to not use `content` fields on tool calls
145
+ inner_thoughts_in_kwargs = "gpt-4o" in model or "gpt-4-turbo" in model or "gpt-3.5-turbo" in model
146
+ else:
147
+ inner_thoughts_in_kwargs = True if inner_thoughts_in_kwargs_option == OptionState.YES else False
148
+
149
+ if not isinstance(inner_thoughts_in_kwargs, bool):
150
+ warnings.warn(f"Bad type detected: {type(inner_thoughts_in_kwargs)}")
151
+ inner_thoughts_in_kwargs = bool(inner_thoughts_in_kwargs)
152
+
153
+ return inner_thoughts_in_kwargs