lionagi 0.14.6__tar.gz → 0.14.7__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.
Files changed (296) hide show
  1. {lionagi-0.14.6 → lionagi-0.14.7}/PKG-INFO +9 -19
  2. {lionagi-0.14.6 → lionagi-0.14.7}/README.md +1 -1
  3. lionagi-0.14.7/cookbooks/007_fan_out_in.py +110 -0
  4. lionagi-0.14.7/cookbooks/claude_proxy/README.md +31 -0
  5. lionagi-0.14.7/cookbooks/claude_proxy/claude_code_proxy.py +132 -0
  6. lionagi-0.14.7/cookbooks/claude_proxy/run_w_claude_code_proxy.ipynb +217 -0
  7. lionagi-0.14.7/lionagi/libs/hash/__init__.py +3 -0
  8. lionagi-0.14.7/lionagi/libs/hash/hash_dict.py +108 -0
  9. lionagi-0.14.7/lionagi/libs/hash/manager.py +26 -0
  10. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/models/hashable_model.py +2 -1
  11. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/message.py +3 -1
  12. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/_claude_code/models.py +2 -3
  13. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/_claude_code/stream_cli.py +9 -0
  14. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/types.py +2 -1
  15. lionagi-0.14.7/lionagi/version.py +1 -0
  16. {lionagi-0.14.6 → lionagi-0.14.7}/pyproject.toml +16 -22
  17. lionagi-0.14.7/uv.lock +5622 -0
  18. lionagi-0.14.6/lionagi/version.py +0 -1
  19. lionagi-0.14.6/uv.lock +0 -5036
  20. {lionagi-0.14.6 → lionagi-0.14.7}/.coveragerc +0 -0
  21. {lionagi-0.14.6 → lionagi-0.14.7}/.env.example +0 -0
  22. {lionagi-0.14.6 → lionagi-0.14.7}/.github/FUNDING.yml +0 -0
  23. {lionagi-0.14.6 → lionagi-0.14.7}/.github/dependabot.yml +0 -0
  24. {lionagi-0.14.6 → lionagi-0.14.7}/.github/workflows/ci.yml +0 -0
  25. {lionagi-0.14.6 → lionagi-0.14.7}/.github/workflows/codeql.yml +0 -0
  26. {lionagi-0.14.6 → lionagi-0.14.7}/.github/workflows/docs.yml +0 -0
  27. {lionagi-0.14.6 → lionagi-0.14.7}/.github/workflows/release.yml +0 -0
  28. {lionagi-0.14.6 → lionagi-0.14.7}/.gitignore +0 -0
  29. {lionagi-0.14.6 → lionagi-0.14.7}/.pre-commit-config.yaml +0 -0
  30. {lionagi-0.14.6 → lionagi-0.14.7}/.python-version +0 -0
  31. {lionagi-0.14.6 → lionagi-0.14.7}/CODE_OF_CONDUCT.md +0 -0
  32. {lionagi-0.14.6 → lionagi-0.14.7}/CONTRIBUTING.md +0 -0
  33. {lionagi-0.14.6 → lionagi-0.14.7}/LICENSE +0 -0
  34. {lionagi-0.14.6 → lionagi-0.14.7}/assets/operation_builder.gif +0 -0
  35. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/001_branch_converse.ipynb +0 -0
  36. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/002_branch_interact.ipynb +0 -0
  37. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/003_branch_info.ipynb +0 -0
  38. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/004_conversation_patterns.ipynb +0 -0
  39. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/005_react_basics.ipynb +0 -0
  40. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/006_operation_graphs_claim_extraction.ipynb +0 -0
  41. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/data/002_comedian.json +0 -0
  42. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/data/002_critic.json +0 -0
  43. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/data/006_lion_proof_ch2.md +0 -0
  44. {lionagi-0.14.6 → lionagi-0.14.7}/cookbooks/using_claude_code.py +0 -0
  45. {lionagi-0.14.6 → lionagi-0.14.7}/docs/Makefile +0 -0
  46. {lionagi-0.14.6 → lionagi-0.14.7}/docs/_static/custom.css +0 -0
  47. {lionagi-0.14.6 → lionagi-0.14.7}/docs/_templates/layout.html +0 -0
  48. {lionagi-0.14.6 → lionagi-0.14.7}/docs/conf.py +0 -0
  49. {lionagi-0.14.6 → lionagi-0.14.7}/docs/discussions/anyio-migration.md +0 -0
  50. {lionagi-0.14.6 → lionagi-0.14.7}/docs/index.rst +0 -0
  51. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/action.rst +0 -0
  52. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/adapter.rst +0 -0
  53. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/branch.rst +0 -0
  54. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/branch_operations.rst +0 -0
  55. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/concepts.rst +0 -0
  56. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/element_id.rst +0 -0
  57. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/event.rst +0 -0
  58. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/form.rst +0 -0
  59. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/graph.rst +0 -0
  60. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/index.rst +0 -0
  61. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/instruct.rst +0 -0
  62. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/lib_file.rst +0 -0
  63. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/lib_nested.rst +0 -0
  64. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/lib_package.rst +0 -0
  65. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/lib_schema.rst +0 -0
  66. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/lib_validate.rst +0 -0
  67. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/log.rst +0 -0
  68. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/mail.rst +0 -0
  69. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/message.rst +0 -0
  70. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/models.rst +0 -0
  71. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/operative_step.rst +0 -0
  72. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/pile.rst +0 -0
  73. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/processor.rst +0 -0
  74. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/progression.rst +0 -0
  75. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/service.rst +0 -0
  76. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/session.rst +0 -0
  77. {lionagi-0.14.6 → lionagi-0.14.7}/docs/modules/utils.rst +0 -0
  78. {lionagi-0.14.6 → lionagi-0.14.7}/docs/tutorials/get_started.rst +0 -0
  79. {lionagi-0.14.6 → lionagi-0.14.7}/docs/tutorials/get_started_pt2.rst +0 -0
  80. {lionagi-0.14.6 → lionagi-0.14.7}/docs/tutorials/get_started_pt3.rst +0 -0
  81. {lionagi-0.14.6 → lionagi-0.14.7}/docs/tutorials/index.rst +0 -0
  82. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/__init__.py +0 -0
  83. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/_class_registry.py +0 -0
  84. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/_errors.py +0 -0
  85. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/_types.py +0 -0
  86. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/adapters/__init__.py +0 -0
  87. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/adapters/async_postgres_adapter.py +0 -0
  88. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/adapters/postgres_model_adapter.py +0 -0
  89. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/config.py +0 -0
  90. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/fields/__init__.py +0 -0
  91. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/fields/action.py +0 -0
  92. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/fields/base.py +0 -0
  93. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/fields/code.py +0 -0
  94. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/fields/file.py +0 -0
  95. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/fields/instruct.py +0 -0
  96. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/fields/reason.py +0 -0
  97. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/fields/research.py +0 -0
  98. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/__init__.py +0 -0
  99. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/concurrency/__init__.py +0 -0
  100. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/concurrency/cancel.py +0 -0
  101. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/concurrency/errors.py +0 -0
  102. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/concurrency/patterns.py +0 -0
  103. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/concurrency/primitives.py +0 -0
  104. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/concurrency/resource_tracker.py +0 -0
  105. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/concurrency/task.py +0 -0
  106. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/file/__init__.py +0 -0
  107. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/file/chunk.py +0 -0
  108. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/file/concat.py +0 -0
  109. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/file/concat_files.py +0 -0
  110. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/file/file_ops.py +0 -0
  111. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/file/params.py +0 -0
  112. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/file/process.py +0 -0
  113. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/file/save.py +0 -0
  114. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/__init__.py +0 -0
  115. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/flatten.py +0 -0
  116. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/nfilter.py +0 -0
  117. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/nget.py +0 -0
  118. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/ninsert.py +0 -0
  119. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/nmerge.py +0 -0
  120. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/npop.py +0 -0
  121. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/nset.py +0 -0
  122. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/unflatten.py +0 -0
  123. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/nested/utils.py +0 -0
  124. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/package/__init__.py +0 -0
  125. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/package/imports.py +0 -0
  126. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/package/management.py +0 -0
  127. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/package/params.py +0 -0
  128. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/package/system.py +0 -0
  129. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/parse.py +0 -0
  130. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/schema/__init__.py +0 -0
  131. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/schema/as_readable.py +0 -0
  132. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/schema/extract_code_block.py +0 -0
  133. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/schema/extract_docstring.py +0 -0
  134. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/schema/function_to_schema.py +0 -0
  135. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/schema/json_schema.py +0 -0
  136. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/schema/load_pydantic_model_from_schema.py +0 -0
  137. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/__init__.py +0 -0
  138. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/base.py +0 -0
  139. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/llmlingua.py +0 -0
  140. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/perplexity.py +0 -0
  141. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/symbolic_compress_context.py +0 -0
  142. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang.py +0 -0
  143. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/base.py +0 -0
  144. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/abstract_algebra.toml +0 -0
  145. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/category_theory.toml +0 -0
  146. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/complex_analysis.toml +0 -0
  147. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/framework_options.json +0 -0
  148. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/group_theory.toml +0 -0
  149. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/math_logic.toml +0 -0
  150. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/reflective_patterns.toml +0 -0
  151. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/set_theory.toml +0 -0
  152. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/frameworks/topology_fundamentals.toml +0 -0
  153. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/mapping/lion_emoji_mapping.toml +0 -0
  154. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/mapping/python_math_mapping.toml +0 -0
  155. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/mapping/rust_chinese_mapping.toml +0 -0
  156. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/resources/utility/base_synthlang_system_prompt.toml +0 -0
  157. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/synthlang_/translate_to_synthlang.py +0 -0
  158. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/token_transform/types.py +0 -0
  159. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/validate/__init__.py +0 -0
  160. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/validate/common_field_validators.py +0 -0
  161. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/validate/fuzzy_match_keys.py +0 -0
  162. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/validate/fuzzy_validate_mapping.py +0 -0
  163. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/validate/string_similarity.py +0 -0
  164. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/libs/validate/validate_boolean.py +0 -0
  165. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/models/__init__.py +0 -0
  166. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/models/field_model.py +0 -0
  167. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/models/model_params.py +0 -0
  168. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/models/note.py +0 -0
  169. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/models/operable_model.py +0 -0
  170. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/models/schema_model.py +0 -0
  171. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/ReAct/ReAct.py +0 -0
  172. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/ReAct/__init__.py +0 -0
  173. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/ReAct/utils.py +0 -0
  174. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/__init__.py +0 -0
  175. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/_act/__init__.py +0 -0
  176. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/_act/act.py +0 -0
  177. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/brainstorm/__init__.py +0 -0
  178. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/brainstorm/brainstorm.py +0 -0
  179. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/brainstorm/prompt.py +0 -0
  180. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/builder.py +0 -0
  181. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/chat/__init__.py +0 -0
  182. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/chat/chat.py +0 -0
  183. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/communicate/__init__.py +0 -0
  184. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/communicate/communicate.py +0 -0
  185. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/flow.py +0 -0
  186. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/instruct/__init__.py +0 -0
  187. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/instruct/instruct.py +0 -0
  188. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/interpret/__init__.py +0 -0
  189. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/interpret/interpret.py +0 -0
  190. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/manager.py +0 -0
  191. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/node.py +0 -0
  192. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/operate/__init__.py +0 -0
  193. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/operate/operate.py +0 -0
  194. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/parse/__init__.py +0 -0
  195. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/parse/parse.py +0 -0
  196. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/plan/__init__.py +0 -0
  197. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/plan/plan.py +0 -0
  198. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/plan/prompt.py +0 -0
  199. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/select/__init__.py +0 -0
  200. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/select/select.py +0 -0
  201. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/select/utils.py +0 -0
  202. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/translate/__init__.py +0 -0
  203. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/translate/translate.py +0 -0
  204. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/types.py +0 -0
  205. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/operations/utils.py +0 -0
  206. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/__init__.py +0 -0
  207. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/_concepts.py +0 -0
  208. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/action/__init__.py +0 -0
  209. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/action/function_calling.py +0 -0
  210. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/action/manager.py +0 -0
  211. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/action/tool.py +0 -0
  212. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/forms/__init__.py +0 -0
  213. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/forms/base.py +0 -0
  214. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/forms/flow.py +0 -0
  215. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/forms/form.py +0 -0
  216. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/forms/report.py +0 -0
  217. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/generic/__init__.py +0 -0
  218. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/generic/element.py +0 -0
  219. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/generic/event.py +0 -0
  220. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/generic/log.py +0 -0
  221. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/generic/pile.py +0 -0
  222. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/generic/processor.py +0 -0
  223. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/generic/progression.py +0 -0
  224. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/graph/__init__.py +0 -0
  225. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/graph/edge.py +0 -0
  226. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/graph/graph.py +0 -0
  227. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/graph/node.py +0 -0
  228. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/mail/__init__.py +0 -0
  229. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/mail/exchange.py +0 -0
  230. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/mail/mail.py +0 -0
  231. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/mail/mailbox.py +0 -0
  232. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/mail/manager.py +0 -0
  233. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/mail/package.py +0 -0
  234. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/__init__.py +0 -0
  235. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/action_request.py +0 -0
  236. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/action_response.py +0 -0
  237. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/assistant_response.py +0 -0
  238. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/base.py +0 -0
  239. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/instruction.py +0 -0
  240. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/manager.py +0 -0
  241. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/system.py +0 -0
  242. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/templates/README.md +0 -0
  243. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/templates/action_request.jinja2 +0 -0
  244. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/templates/action_response.jinja2 +0 -0
  245. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/templates/assistant_response.jinja2 +0 -0
  246. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/templates/instruction_message.jinja2 +0 -0
  247. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/templates/system_message.jinja2 +0 -0
  248. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/messages/templates/tool_schemas.jinja2 +0 -0
  249. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/operatives/__init__.py +0 -0
  250. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/operatives/operative.py +0 -0
  251. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/operatives/step.py +0 -0
  252. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/protocols/types.py +0 -0
  253. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/py.typed +0 -0
  254. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/__init__.py +0 -0
  255. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/__init__.py +0 -0
  256. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/api_calling.py +0 -0
  257. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/endpoint.py +0 -0
  258. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/endpoint_config.py +0 -0
  259. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/header_factory.py +0 -0
  260. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/match_endpoint.py +0 -0
  261. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/__init__.py +0 -0
  262. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/_claude_code/__init__.py +0 -0
  263. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/anthropic_.py +0 -0
  264. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/claude_code_.py +0 -0
  265. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/claude_code_cli.py +0 -0
  266. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/exa_.py +0 -0
  267. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/oai_.py +0 -0
  268. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/ollama_.py +0 -0
  269. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/connections/providers/perplexity_.py +0 -0
  270. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/imodel.py +0 -0
  271. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/manager.py +0 -0
  272. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/rate_limited_processor.py +0 -0
  273. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/resilience.py +0 -0
  274. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/third_party/README.md +0 -0
  275. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/third_party/__init__.py +0 -0
  276. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/third_party/anthropic_models.py +0 -0
  277. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/third_party/exa_models.py +0 -0
  278. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/third_party/openai_models.py +0 -0
  279. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/third_party/pplx_models.py +0 -0
  280. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/service/token_calculator.py +0 -0
  281. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/session/__init__.py +0 -0
  282. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/session/branch.py +0 -0
  283. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/session/prompts.py +0 -0
  284. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/session/session.py +0 -0
  285. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/settings.py +0 -0
  286. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/tools/__init__.py +0 -0
  287. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/tools/base.py +0 -0
  288. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/tools/file/__init__.py +0 -0
  289. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/tools/file/reader.py +0 -0
  290. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/tools/memory/tools.py +0 -0
  291. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/tools/types.py +0 -0
  292. {lionagi-0.14.6 → lionagi-0.14.7}/lionagi/utils.py +0 -0
  293. {lionagi-0.14.6 → lionagi-0.14.7}/main.py +0 -0
  294. {lionagi-0.14.6 → lionagi-0.14.7}/scripts/README.md +0 -0
  295. {lionagi-0.14.6 → lionagi-0.14.7}/scripts/concat.py +0 -0
  296. {lionagi-0.14.6 → lionagi-0.14.7}/scripts/config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lionagi
3
- Version: 0.14.6
3
+ Version: 0.14.7
4
4
  Summary: An Intelligence Operating System.
5
5
  Author-email: HaiyangLi <quantocean.li@gmail.com>, Liangbingyan Luo <llby_luo@outlook.com>
6
6
  License: Apache License
@@ -234,9 +234,9 @@ Requires-Dist: tiktoken>=0.8.0
234
234
  Requires-Dist: toml>=0.9.0
235
235
  Provides-Extra: all
236
236
  Requires-Dist: aiosqlite>=0.21.0; extra == 'all'
237
- Requires-Dist: claude-code-sdk>=0.0.14; extra == 'all'
237
+ Requires-Dist: claude-code-sdk>=0.0.15; extra == 'all'
238
238
  Requires-Dist: datamodel-code-generator>=0.31.2; extra == 'all'
239
- Requires-Dist: docling>=2.15.1; extra == 'all'
239
+ Requires-Dist: docling>=2.15.0; extra == 'all'
240
240
  Requires-Dist: fastmcp>=2.10.5; extra == 'all'
241
241
  Requires-Dist: matplotlib>=3.7.0; extra == 'all'
242
242
  Requires-Dist: networkx>=3.0.0; extra == 'all'
@@ -244,36 +244,26 @@ Requires-Dist: ollama>=0.4.0; extra == 'all'
244
244
  Requires-Dist: pydapter[postgres]; extra == 'all'
245
245
  Requires-Dist: rich>=13.0.0; extra == 'all'
246
246
  Provides-Extra: claude-code
247
- Requires-Dist: claude-code-sdk>=0.0.14; extra == 'claude-code'
248
- Provides-Extra: docs
249
- Requires-Dist: furo>=2024.8.6; extra == 'docs'
250
- Requires-Dist: sphinx-autobuild>=2024.10.3; extra == 'docs'
251
- Requires-Dist: sphinx>=8.1.3; extra == 'docs'
247
+ Requires-Dist: claude-code-sdk>=0.0.15; extra == 'claude-code'
252
248
  Provides-Extra: graph
253
249
  Requires-Dist: matplotlib>=3.7.0; extra == 'graph'
254
250
  Requires-Dist: networkx>=3.0.0; extra == 'graph'
255
- Provides-Extra: lint
256
- Requires-Dist: black[jupyter]>=24.10.0; extra == 'lint'
257
- Requires-Dist: isort>=5.13.2; extra == 'lint'
258
- Requires-Dist: pre-commit>=4.0.1; extra == 'lint'
259
251
  Provides-Extra: mcp
260
252
  Requires-Dist: fastmcp>=2.10.5; extra == 'mcp'
261
253
  Provides-Extra: ollama
262
254
  Requires-Dist: ollama>=0.4.0; extra == 'ollama'
263
255
  Provides-Extra: postgres
264
- Requires-Dist: aiosqlite>=0.21.0; extra == 'postgres'
265
256
  Requires-Dist: pydapter[postgres]; extra == 'postgres'
266
257
  Provides-Extra: reader
267
- Requires-Dist: docling>=2.15.1; extra == 'reader'
258
+ Requires-Dist: docling>=2.15.0; extra == 'reader'
268
259
  Provides-Extra: rich
269
260
  Requires-Dist: rich>=13.0.0; extra == 'rich'
270
261
  Provides-Extra: schema
271
262
  Requires-Dist: datamodel-code-generator>=0.31.2; extra == 'schema'
272
- Provides-Extra: test
273
- Requires-Dist: pytest-asyncio>=1.0.0; extra == 'test'
274
- Requires-Dist: pytest>=8.3.4; extra == 'test'
263
+ Provides-Extra: sqlite
264
+ Requires-Dist: aiosqlite>=0.21.0; extra == 'sqlite'
275
265
  Provides-Extra: tools
276
- Requires-Dist: docling>=2.15.1; extra == 'tools'
266
+ Requires-Dist: docling>=2.15.0; extra == 'tools'
277
267
  Description-Content-Type: text/markdown
278
268
 
279
269
  ![PyPI - Version](https://img.shields.io/pypi/v/lionagi?labelColor=233476aa&color=231fc935)
@@ -416,7 +406,7 @@ Seamlessly route to different models in the same workflow.
416
406
 
417
407
  ### Claude Code Integration
418
408
 
419
- LionAGI now supports Anthropic's [Claude Code SDK](https://github.com/anthropics/claude-code-sdk), enabling autonomous coding capabilities with persistent session management:
409
+ LionAGI now supports Anthropic's [Claude Code Python SDK](https://github.com/anthropics/claude-code-sdk-python), enabling autonomous coding capabilities with persistent session management:
420
410
 
421
411
  ```python
422
412
  from lionagi import iModel, Branch
@@ -138,7 +138,7 @@ Seamlessly route to different models in the same workflow.
138
138
 
139
139
  ### Claude Code Integration
140
140
 
141
- LionAGI now supports Anthropic's [Claude Code SDK](https://github.com/anthropics/claude-code-sdk), enabling autonomous coding capabilities with persistent session management:
141
+ LionAGI now supports Anthropic's [Claude Code Python SDK](https://github.com/anthropics/claude-code-sdk-python), enabling autonomous coding capabilities with persistent session management:
142
142
 
143
143
  ```python
144
144
  from lionagi import iModel, Branch
@@ -0,0 +1,110 @@
1
+ from lionagi import Branch, Builder, Session, iModel
2
+ from lionagi.fields import LIST_INSTRUCT_FIELD_MODEL, Instruct
3
+
4
+ CC_WORKSPACE = ".khive/workspace"
5
+
6
+
7
+ def create_cc(
8
+ subdir: str,
9
+ model: str = "sonnet",
10
+ verbose_output: bool = True,
11
+ permission_mode="default",
12
+ auto_finish: bool = False,
13
+ ):
14
+ return iModel(
15
+ provider="claude_code",
16
+ endpoint="query_cli",
17
+ model=model,
18
+ api_key="dummy_api_key",
19
+ ws=f"{CC_WORKSPACE}/{subdir}",
20
+ verbose_output=verbose_output,
21
+ add_dir="../../../",
22
+ permission_mode=permission_mode,
23
+ cli_display_theme="dark",
24
+ auto_finish=auto_finish,
25
+ )
26
+
27
+
28
+ prompt = """
29
+ Task: Investigate the codebase in the specified directory and provide a comprehensive overview.
30
+
31
+ ---START
32
+ read into the specified dir, glance over the key components and pay attention to architecture,
33
+ design patterns, and any notable features. Think deeply about the codebase and give three parallel
34
+ instructions, as part of the structured output (`instruct_models`) in the final response message.
35
+
36
+ ---Then
37
+ The instruct models will be run in parallel by each researcher branch, and I will provide you with
38
+ the researchers' findings for you to continue your investigation.
39
+
40
+ ---Finally
41
+ Once the researchers have completed their tasks, synthesize the information they provided into a cohesive
42
+ overview of the codebase, including:
43
+ 1. Key components and their roles
44
+ 2. Architectural patterns used
45
+ 3. Design patterns and notable features
46
+ ---END
47
+ """
48
+
49
+
50
+ async def main():
51
+ try:
52
+ orc_cc = create_cc("orchestrator")
53
+ orc_branch = Branch(
54
+ chat_model=orc_cc,
55
+ parse_model=orc_cc,
56
+ use_lion_system_message=True,
57
+ system_datetime=True,
58
+ name="orchestrator",
59
+ )
60
+ session = Session(default_branch=orc_branch)
61
+
62
+ builder = Builder("CodeInvestigator")
63
+ root = builder.add_operation(
64
+ "operate",
65
+ instruct=Instruct(
66
+ instruction=prompt,
67
+ context="lionagi",
68
+ ),
69
+ reason=True,
70
+ field_models=[LIST_INSTRUCT_FIELD_MODEL],
71
+ )
72
+
73
+ result = await session.flow(builder.get_graph())
74
+
75
+ instruct_models: list[Instruct] = result["operation_results"][
76
+ root
77
+ ].instruct_models
78
+ research_nodes = []
79
+
80
+ for i in instruct_models:
81
+ node = builder.add_operation(
82
+ "communicate",
83
+ depends_on=[root],
84
+ chat_model=create_cc("researcher"),
85
+ **i.to_dict(),
86
+ )
87
+ research_nodes.append(node)
88
+
89
+ synthesis = builder.add_aggregation(
90
+ "communicate",
91
+ source_node_ids=research_nodes,
92
+ branch=orc_branch,
93
+ instruction="Synthesize the information from the researcher branches.",
94
+ )
95
+
96
+ result2 = await session.flow(builder.get_graph())
97
+ result_synthesis = result2["operation_results"][synthesis]
98
+ print(result_synthesis)
99
+
100
+ except Exception as e:
101
+ print(f"Error: {e}")
102
+ import traceback
103
+
104
+ traceback.print_exc()
105
+
106
+
107
+ if __name__ == "__main__":
108
+ import anyio
109
+
110
+ anyio.run(main)
@@ -0,0 +1,31 @@
1
+ # LionAGI Claude Code Proxy
2
+
3
+ to use please first install `lionagi` and `fastapi`
4
+
5
+ ```bash
6
+ uv add lionagi fastapi loguru
7
+ ```
8
+
9
+ then run the proxy with:
10
+
11
+ ```bash
12
+ uv run cookbooks/claude_proxy/claude_code_proxy.py --port 8000
13
+ ```
14
+
15
+ Next, configure a cutsom endpoint
16
+
17
+ ```python
18
+ from lionagi.service import Endpoint, EndpointConfig, iModel
19
+ claude_code_config = EndpointConfig(
20
+ name="claude_code_cli_proxy",
21
+ provider="claude_code_proxy",
22
+ base_url="http://localhost:8000/v1",
23
+ endpoint="query",
24
+ api_key="dummy_api_key",
25
+ kwargs={"model": "sonnet"},
26
+ )
27
+ cc_proxy_endpoint = Endpoint(claude_code_config)
28
+ claude_code = iModel(endpoint=cc_proxy_endpoint)
29
+ ```
30
+
31
+ Done, now you can run `claude code` in jupyter or any other environment that supports `lionagi`.
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Claude Code Proxy API Server - OpenAI Compatible
4
+ A FastAPI server that proxies requests to Claude Code CLI using OpenAI API format.
5
+ Compatible with Roo Code, Cline, and other OpenAI API clients.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import json
11
+ import subprocess
12
+ import sys
13
+ from contextlib import asynccontextmanager
14
+
15
+ import uvicorn
16
+ from fastapi import FastAPI, HTTPException, Request, Response
17
+ from loguru import logger
18
+
19
+ from lionagi.service.connections.providers.claude_code_cli import (
20
+ ClaudeCodeCLIEndpoint,
21
+ ClaudeCodeRequest,
22
+ )
23
+
24
+ # Configure logging
25
+ logger.remove()
26
+ logger.add(sys.stderr, level="INFO")
27
+
28
+
29
+ @asynccontextmanager
30
+ async def lifespan(app: FastAPI):
31
+ check_claude_code()
32
+ logger.info("Claude Code CLI Proxy API started successfully")
33
+ yield
34
+ pass
35
+
36
+
37
+ # FastAPI app
38
+ app = FastAPI(
39
+ title="Claude Code Proxy API - OpenAI Compatible",
40
+ description="Proxy server for Claude Code CLI - Personal Development Use",
41
+ version="1.0.0",
42
+ lifespan=lifespan,
43
+ )
44
+
45
+
46
+ # Check if Claude Code is available
47
+ def check_claude_code():
48
+ """Verify Claude Code CLI is installed and accessible"""
49
+ try:
50
+ from lionagi.service.connections.providers._claude_code.stream_cli import (
51
+ CLAUDE,
52
+ )
53
+
54
+ result = subprocess.run(
55
+ [CLAUDE, "--version"], capture_output=True, text=True
56
+ )
57
+ if result.returncode != 0:
58
+ raise RuntimeError(
59
+ f"Claude Code not found, please install it first:\n"
60
+ )
61
+ logger.info(f"Claude Code found: {result.stdout.strip()}")
62
+ except Exception as e:
63
+ logger.error(f"Claude Code check failed: {e}")
64
+ raise RuntimeError(
65
+ "Claude Code CLI not found. Please install it first:\n"
66
+ "npm install -g @anthropic-ai/claude-code"
67
+ )
68
+
69
+
70
+ # Health check
71
+ @app.get("/health")
72
+ async def health_check():
73
+ return {"status": "healthy", "service": "claude-code-cli-proxy"}
74
+
75
+
76
+ @app.post("/v1/query")
77
+ async def query(request: ClaudeCodeRequest):
78
+
79
+ endpoint = ClaudeCodeCLIEndpoint()
80
+ try:
81
+ return await endpoint._call(payload={"request": request}, headers={})
82
+ except Exception as e:
83
+ logger.error(f"Error processing request: {e}")
84
+ raise HTTPException(
85
+ status_code=500, detail=f"Internal server error: {str(e)}"
86
+ )
87
+
88
+
89
+ # Error handling
90
+ @app.exception_handler(Exception)
91
+ async def general_exception_handler(request: Request, exc: Exception):
92
+ logger.error(f"Unhandled exception: {exc}")
93
+ return Response(
94
+ content=json.dumps(
95
+ {
96
+ "error": {
97
+ "message": str(exc),
98
+ "type": "internal_error",
99
+ "param": None,
100
+ "code": None,
101
+ }
102
+ }
103
+ ),
104
+ status_code=500,
105
+ media_type="application/json",
106
+ )
107
+
108
+
109
+ if __name__ == "__main__":
110
+ # Parse command line arguments
111
+ import argparse
112
+
113
+ parser = argparse.ArgumentParser(
114
+ description="Claude Code Proxy API Server"
115
+ )
116
+ parser.add_argument("--host", default="127.0.0.1", help="Host to bind to")
117
+ parser.add_argument(
118
+ "--port", type=int, default=8000, help="Port to bind to"
119
+ )
120
+ parser.add_argument(
121
+ "--reload", action="store_true", help="Enable auto-reload"
122
+ )
123
+ args = parser.parse_args()
124
+
125
+ # Run server
126
+ uvicorn.run(
127
+ "claude_code_proxy:app" if args.reload else app,
128
+ host=args.host,
129
+ port=args.port,
130
+ reload=args.reload,
131
+ log_level="info",
132
+ )
@@ -0,0 +1,217 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "d2ceb407",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "from lionagi.service.connections.endpoint_config import EndpointConfig\n",
11
+ "from lionagi.service.imodel import Endpoint\n",
12
+ "from lionagi.service.connections.providers.claude_code_cli import (\n",
13
+ " ClaudeCodeRequest,\n",
14
+ ")\n",
15
+ "\n",
16
+ "claude_code_config = EndpointConfig(\n",
17
+ " name=\"claude_code_cli_proxy\",\n",
18
+ " provider=\"claude_code\",\n",
19
+ " base_url=\"http://localhost:8000/v1\",\n",
20
+ " endpoint=\"query\",\n",
21
+ " api_key=\"dummy_api_key\",\n",
22
+ " kwargs={\"model\": \"sonnet\"},\n",
23
+ ")\n",
24
+ "claude_code = Endpoint(claude_code_config)"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": 2,
30
+ "id": "5fc216f4",
31
+ "metadata": {},
32
+ "outputs": [
33
+ {
34
+ "data": {
35
+ "text/plain": [
36
+ "{'session_id': 'bb6041af-a950-4364-bef1-f80f40698ec6',\n",
37
+ " 'model': 'claude-sonnet-4-20250514',\n",
38
+ " 'chunks': [{'raw': {'type': 'system',\n",
39
+ " 'subtype': 'init',\n",
40
+ " 'cwd': '/Users/lion/lionagi/notebooks/using_claude_code',\n",
41
+ " 'session_id': 'bb6041af-a950-4364-bef1-f80f40698ec6',\n",
42
+ " 'tools': ['Task',\n",
43
+ " 'Bash',\n",
44
+ " 'Glob',\n",
45
+ " 'Grep',\n",
46
+ " 'LS',\n",
47
+ " 'ExitPlanMode',\n",
48
+ " 'Read',\n",
49
+ " 'Edit',\n",
50
+ " 'MultiEdit',\n",
51
+ " 'Write',\n",
52
+ " 'NotebookRead',\n",
53
+ " 'NotebookEdit',\n",
54
+ " 'WebFetch',\n",
55
+ " 'TodoWrite',\n",
56
+ " 'WebSearch'],\n",
57
+ " 'mcp_servers': [],\n",
58
+ " 'model': 'claude-sonnet-4-20250514',\n",
59
+ " 'permissionMode': 'default',\n",
60
+ " 'apiKeySource': 'none'},\n",
61
+ " 'type': 'system',\n",
62
+ " 'thinking': None,\n",
63
+ " 'text': None,\n",
64
+ " 'tool_use': None,\n",
65
+ " 'tool_result': None},\n",
66
+ " {'raw': {'type': 'assistant',\n",
67
+ " 'message': {'id': 'msg_016an9mp2mrH7Fe1Vr6xwSUP',\n",
68
+ " 'type': 'message',\n",
69
+ " 'role': 'assistant',\n",
70
+ " 'model': 'claude-sonnet-4-20250514',\n",
71
+ " 'content': [{'type': 'text',\n",
72
+ " 'text': '```python\\ndef factorial(n):\\n if n < 0:\\n raise ValueError(\"Factorial is not defined for negative numbers\")\\n if n == 0 or n == 1:\\n return 1\\n \\n result = 1\\n for i in range(2, n + 1):\\n result *= i\\n return result\\n```'}],\n",
73
+ " 'stop_reason': None,\n",
74
+ " 'stop_sequence': None,\n",
75
+ " 'usage': {'input_tokens': 4,\n",
76
+ " 'cache_creation_input_tokens': 18345,\n",
77
+ " 'cache_read_input_tokens': 11019,\n",
78
+ " 'output_tokens': 85,\n",
79
+ " 'service_tier': 'standard'}},\n",
80
+ " 'parent_tool_use_id': None,\n",
81
+ " 'session_id': 'bb6041af-a950-4364-bef1-f80f40698ec6'},\n",
82
+ " 'type': 'assistant',\n",
83
+ " 'thinking': None,\n",
84
+ " 'text': '```python\\ndef factorial(n):\\n if n < 0:\\n raise ValueError(\"Factorial is not defined for negative numbers\")\\n if n == 0 or n == 1:\\n return 1\\n \\n result = 1\\n for i in range(2, n + 1):\\n result *= i\\n return result\\n```',\n",
85
+ " 'tool_use': None,\n",
86
+ " 'tool_result': None},\n",
87
+ " {'raw': {'type': 'result',\n",
88
+ " 'subtype': 'success',\n",
89
+ " 'is_error': False,\n",
90
+ " 'duration_ms': 3322,\n",
91
+ " 'duration_api_ms': 3202,\n",
92
+ " 'num_turns': 1,\n",
93
+ " 'result': '```python\\ndef factorial(n):\\n if n < 0:\\n raise ValueError(\"Factorial is not defined for negative numbers\")\\n if n == 0 or n == 1:\\n return 1\\n \\n result = 1\\n for i in range(2, n + 1):\\n result *= i\\n return result\\n```',\n",
94
+ " 'session_id': 'bb6041af-a950-4364-bef1-f80f40698ec6',\n",
95
+ " 'total_cost_usd': 0.07340145000000001,\n",
96
+ " 'usage': {'input_tokens': 4,\n",
97
+ " 'cache_creation_input_tokens': 18345,\n",
98
+ " 'cache_read_input_tokens': 11019,\n",
99
+ " 'output_tokens': 86,\n",
100
+ " 'server_tool_use': {'web_search_requests': 0},\n",
101
+ " 'service_tier': 'standard'}},\n",
102
+ " 'type': 'result',\n",
103
+ " 'thinking': None,\n",
104
+ " 'text': None,\n",
105
+ " 'tool_use': None,\n",
106
+ " 'tool_result': None}],\n",
107
+ " 'thinking_log': [],\n",
108
+ " 'messages': [{'id': 'msg_016an9mp2mrH7Fe1Vr6xwSUP',\n",
109
+ " 'type': 'message',\n",
110
+ " 'role': 'assistant',\n",
111
+ " 'model': 'claude-sonnet-4-20250514',\n",
112
+ " 'content': [{'type': 'text',\n",
113
+ " 'text': '```python\\ndef factorial(n):\\n if n < 0:\\n raise ValueError(\"Factorial is not defined for negative numbers\")\\n if n == 0 or n == 1:\\n return 1\\n \\n result = 1\\n for i in range(2, n + 1):\\n result *= i\\n return result\\n```'}],\n",
114
+ " 'stop_reason': None,\n",
115
+ " 'stop_sequence': None,\n",
116
+ " 'usage': {'input_tokens': 4,\n",
117
+ " 'cache_creation_input_tokens': 18345,\n",
118
+ " 'cache_read_input_tokens': 11019,\n",
119
+ " 'output_tokens': 85,\n",
120
+ " 'service_tier': 'standard'}}],\n",
121
+ " 'tool_uses': [],\n",
122
+ " 'tool_results': [],\n",
123
+ " 'result': '```python\\ndef factorial(n):\\n if n < 0:\\n raise ValueError(\"Factorial is not defined for negative numbers\")\\n if n == 0 or n == 1:\\n return 1\\n \\n result = 1\\n for i in range(2, n + 1):\\n result *= i\\n return result\\n```\\n```python\\ndef factorial(n):\\n if n < 0:\\n raise ValueError(\"Factorial is not defined for negative numbers\")\\n if n == 0 or n == 1:\\n return 1\\n \\n result = 1\\n for i in range(2, n + 1):\\n result *= i\\n return result\\n```',\n",
124
+ " 'usage': {'input_tokens': 4,\n",
125
+ " 'cache_creation_input_tokens': 18345,\n",
126
+ " 'cache_read_input_tokens': 11019,\n",
127
+ " 'output_tokens': 86,\n",
128
+ " 'server_tool_use': {'web_search_requests': 0},\n",
129
+ " 'service_tier': 'standard'},\n",
130
+ " 'total_cost_usd': 0.07340145000000001,\n",
131
+ " 'num_turns': 1,\n",
132
+ " 'duration_ms': 3322,\n",
133
+ " 'duration_api_ms': 3202,\n",
134
+ " 'is_error': False}"
135
+ ]
136
+ },
137
+ "execution_count": 2,
138
+ "metadata": {},
139
+ "output_type": "execute_result"
140
+ }
141
+ ],
142
+ "source": [
143
+ "prompt = \"reply in text only, Write a Python function to calculate the factorial of a number.\"\n",
144
+ "\n",
145
+ "await claude_code.call(request=ClaudeCodeRequest(prompt=prompt))"
146
+ ]
147
+ },
148
+ {
149
+ "cell_type": "code",
150
+ "execution_count": 2,
151
+ "id": "4c173814",
152
+ "metadata": {},
153
+ "outputs": [],
154
+ "source": [
155
+ "from lionagi import iModel\n",
156
+ "\n",
157
+ "claude_code = iModel(endpoint=claude_code)"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "code",
162
+ "execution_count": 3,
163
+ "id": "fe6dcca4",
164
+ "metadata": {},
165
+ "outputs": [
166
+ {
167
+ "name": "stderr",
168
+ "output_type": "stream",
169
+ "text": [
170
+ "API call failed: 404, message=\"Request failed with status 404: {'detail': 'Not Found'}\", url='http://localhost:8000/v1/query'\n"
171
+ ]
172
+ }
173
+ ],
174
+ "source": [
175
+ "result = await claude_code.invoke(\n",
176
+ " messages=[\n",
177
+ " {\n",
178
+ " \"role\": \"user\",\n",
179
+ " \"content\": \"reply in text only, Write a Python function to calculate the factorial of a number.\",\n",
180
+ " }\n",
181
+ " ]\n",
182
+ ")"
183
+ ]
184
+ },
185
+ {
186
+ "cell_type": "code",
187
+ "execution_count": 4,
188
+ "id": "88db9e9a",
189
+ "metadata": {},
190
+ "outputs": [],
191
+ "source": [
192
+ "result.response"
193
+ ]
194
+ }
195
+ ],
196
+ "metadata": {
197
+ "kernelspec": {
198
+ "display_name": "lionagi",
199
+ "language": "python",
200
+ "name": "python3"
201
+ },
202
+ "language_info": {
203
+ "codemirror_mode": {
204
+ "name": "ipython",
205
+ "version": 3
206
+ },
207
+ "file_extension": ".py",
208
+ "mimetype": "text/x-python",
209
+ "name": "python",
210
+ "nbconvert_exporter": "python",
211
+ "pygments_lexer": "ipython3",
212
+ "version": "3.10.15"
213
+ }
214
+ },
215
+ "nbformat": 4,
216
+ "nbformat_minor": 5
217
+ }
@@ -0,0 +1,3 @@
1
+ from .manager import HashUtils
2
+
3
+ __all__ = ("HashUtils",)
@@ -0,0 +1,108 @@
1
+ import copy
2
+
3
+ from pydantic import BaseModel as PydanticBaseModel
4
+
5
+ __all__ = ("hash_dict",)
6
+
7
+ # --- Canonical Representation Generator ---
8
+ _PRIMITIVE_TYPES = (str, int, float, bool, type(None))
9
+ _TYPE_MARKER_DICT = 0
10
+ _TYPE_MARKER_LIST = 1
11
+ _TYPE_MARKER_TUPLE = 2
12
+ _TYPE_MARKER_SET = 3
13
+ _TYPE_MARKER_FROZENSET = 4
14
+ _TYPE_MARKER_PYDANTIC = 5 # Distinguishes dumped Pydantic models
15
+
16
+
17
+ def _generate_hashable_representation(item: any) -> any:
18
+ """
19
+ Recursively converts a Python object into a stable, hashable representation.
20
+ This ensures that logically identical but structurally different inputs
21
+ (e.g., dicts with different key orders) produce the same representation.
22
+ """
23
+ if isinstance(item, _PRIMITIVE_TYPES):
24
+ return item
25
+
26
+ if isinstance(item, PydanticBaseModel):
27
+ # Process the Pydantic model by first dumping it to a dict, then processing that dict.
28
+ # The type marker distinguishes this from a regular dictionary.
29
+ return (
30
+ _TYPE_MARKER_PYDANTIC,
31
+ _generate_hashable_representation(item.model_dump()),
32
+ )
33
+
34
+ if isinstance(item, dict):
35
+ # Sort dictionary items by key (stringified) for order-insensitivity.
36
+ return (
37
+ _TYPE_MARKER_DICT,
38
+ tuple(
39
+ (str(k), _generate_hashable_representation(v))
40
+ for k, v in sorted(item.items(), key=lambda x: str(x[0]))
41
+ ),
42
+ )
43
+
44
+ if isinstance(item, list):
45
+ return (
46
+ _TYPE_MARKER_LIST,
47
+ tuple(_generate_hashable_representation(elem) for elem in item),
48
+ )
49
+
50
+ if isinstance(item, tuple):
51
+ return (
52
+ _TYPE_MARKER_TUPLE,
53
+ tuple(_generate_hashable_representation(elem) for elem in item),
54
+ )
55
+
56
+ # frozenset must be checked before set
57
+ if isinstance(item, frozenset):
58
+ try: # Attempt direct sort for comparable elements
59
+ sorted_elements = sorted(list(item))
60
+ except TypeError: # Fallback for unorderable mixed types
61
+ sorted_elements = sorted(
62
+ list(item), key=lambda x: (str(type(x)), str(x))
63
+ )
64
+ return (
65
+ _TYPE_MARKER_FROZENSET,
66
+ tuple(
67
+ _generate_hashable_representation(elem)
68
+ for elem in sorted_elements
69
+ ),
70
+ )
71
+
72
+ if isinstance(item, set):
73
+ try:
74
+ sorted_elements = sorted(list(item))
75
+ except TypeError:
76
+ sorted_elements = sorted(
77
+ list(item), key=lambda x: (str(type(x)), str(x))
78
+ )
79
+ return (
80
+ _TYPE_MARKER_SET,
81
+ tuple(
82
+ _generate_hashable_representation(elem)
83
+ for elem in sorted_elements
84
+ ),
85
+ )
86
+
87
+ # Fallback for other types (e.g., custom objects not derived from the above)
88
+ try:
89
+ return str(item)
90
+ except Exception: # If str() fails for some reason
91
+ return repr(item)
92
+
93
+
94
+ def hash_dict(data: any, strict: bool = False) -> int:
95
+ data_to_process = data
96
+ if strict:
97
+ data_to_process = copy.deepcopy(data)
98
+
99
+ hashable_repr = _generate_hashable_representation(data_to_process)
100
+
101
+ try:
102
+ return hash(hashable_repr)
103
+ except TypeError as e:
104
+ raise TypeError(
105
+ f"The generated representation for the input data was not hashable. "
106
+ f"Input type: {type(data).__name__}, Representation type: {type(hashable_repr).__name__}. "
107
+ f"Original error: {e}"
108
+ )