-
Notifications
You must be signed in to change notification settings - Fork 41
Description
I just had a chat with a contributor and thought I should share here as well for anyone interested. It would be great to transform this issue into documentation eventually :)
They wrote:
I’m starting to work on wrapping some Goat SDK functionality in lux…. I’m totally new to elixir. I’m wondering if there are existing beams/lenses that would make some sense to model these after. The first one I was going to try to create was the ability to swap tokens on Uniswap through Goat.
Lenses
are just an http client that hits an endpoint and does some transformation + a json schema for LLMs to know what to do with them. They also come with some helpers for you to define auth. You can transform the request before it's sent, or you can transform the response before it is returned. COnceptually, you could think of lenses as the tools you'd use to load "Resources"
Prisms
are more for when you want to write your own logic and conceptually I like to think of them as the tool you'd use to implement "Actions".
The first one I was going to try to create was the ability to swap tokens on Uniswap through Goat.
This for example, looks like a Prism!
Since GOAT supports python and node, and our support for Python is a bit better tested, I'd recomend writing these prisms in python, or perhaps in elixir with a python sigil.
From the docs:
The Python integration supports:
* Direct Python code execution with `~PY` sigils
* Variable binding between Elixir and Python
* Package management with `import_package/1`
* Error handling and timeouts
* Multi-line Python code with proper indentation
* Access to the full Python ecosystem
Best practices for Python integration:
1. Always handle package imports explicitly
2. Use proper error handling for Python code execution
3. Keep Python code focused and modular
4. Leverage Python's scientific and ML libraries when appropriate
5. Use type hints and docstrings in Python code
6. Follow both Elixir and Python style guides
Want to learn more about Python integration? Check out the [Python language support doc](language_support/python.livemd).If you have any more questions or suggestions on how to improve the epxerience of contributors, please share here or create a new issue!