From d93eeb86b74d999ec864524851163ebbc828ee5e Mon Sep 17 00:00:00 2001 From: Lautaro Date: Sat, 28 Dec 2024 12:40:57 -0300 Subject: [PATCH] Add: docs --- farcaster-langchain/docs/Makefile | 20 ++++++ farcaster-langchain/docs/README.md | 71 +++++++++++++++++++ farcaster-langchain/docs/conf.py | 34 +++++++++ .../docs/farcaster_langchain.rst | 37 ++++++++++ farcaster-langchain/docs/index.rst | 12 ++++ farcaster-langchain/docs/make.bat | 35 +++++++++ farcaster-langchain/docs/modules.rst | 7 ++ 7 files changed, 216 insertions(+) create mode 100644 farcaster-langchain/docs/Makefile create mode 100644 farcaster-langchain/docs/README.md create mode 100644 farcaster-langchain/docs/conf.py create mode 100644 farcaster-langchain/docs/farcaster_langchain.rst create mode 100644 farcaster-langchain/docs/index.rst create mode 100644 farcaster-langchain/docs/make.bat create mode 100644 farcaster-langchain/docs/modules.rst diff --git a/farcaster-langchain/docs/Makefile b/farcaster-langchain/docs/Makefile new file mode 100644 index 000000000..10456c034 --- /dev/null +++ b/farcaster-langchain/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/farcaster-langchain/docs/README.md b/farcaster-langchain/docs/README.md new file mode 100644 index 000000000..8c313c6b0 --- /dev/null +++ b/farcaster-langchain/docs/README.md @@ -0,0 +1,71 @@ +# Farcaster Langchain Toolkit +Farcaster integration with Langchain to enable agentic workflows using the core primitives defined in `cdp-agentkit-core`. + +This toolkit contains tools that enable an LLM agent to interact with [Farcaster](https://www.farcaster.xyz/) via the [Neynar API](https://docs.neynar.com/). The toolkit provides a wrapper around the Neynar API, allowing agents to perform social operations like posting casts and replies. + +## Setup + +### Prerequisites +- Python 3.10 or higher +- [OpenAI API Key](https://platform.openai.com/api-keys) +- [Neynar API Key](https://docs.neynar.com/reference/getting-started) +- [Neynar Signer UUID](https://docs.neynar.com/reference/create-signer) +- Farcaster Account with FID + +### Installation +bash +pip install farcaster-langchain + +### Environment Setup + +Set the following environment variables: +bash +export OPENAI_API_KEY= +export NEYNAR_API_KEY= +export NEYNAR_SIGNER_UUID= +export FARCASTER_FID= + +## API Reference + +### FarcasterApiWrapper +The main wrapper class that handles interactions with the Farcaster API via Neynar. + +#### Methods + +##### cast +python +def cast(text: str, channel_id: Optional[str] = None, embeds: Optional[List[str]] = None) -> str + +Post a new cast to Farcaster. Optionally specify a channel or include embedded URLs. + +##### get_notifications +python +def get_notifications(fid: Optional[str] = None) -> str + +Get recent notifications for the authenticated user or specified FID. + +##### get_user_details + +python +def get_user_details(username: str) -> str + +Get details about a specific Farcaster user. + +### FarcasterToolkit +A collection of LangChain tools for Farcaster interactions. + +#### Available Tools +1. **user_details** - Get user details by FID +2. **user_notifications** - Get notifications for the authenticated user +3. **cast** - Post a cast (max 320 characters, with optional channel and embeds) +4. **reply_to_cast** - Reply to an existing cast + +For detailed examples and usage, see the [main README](../README.md). + +## Contributing +See [CONTRIBUTING.md](../CONTRIBUTING.md) for detailed setup instructions and contribution guidelines. + +## Documentation +For detailed documentation, please visit: +- [Agentkit-Core](https://coinbase.github.io/cdp-agentkit/cdp-agentkit-core/) +- [Neynar API Documentation](https://docs.neynar.com/) \ No newline at end of file diff --git a/farcaster-langchain/docs/conf.py b/farcaster-langchain/docs/conf.py new file mode 100644 index 000000000..07c5f480e --- /dev/null +++ b/farcaster-langchain/docs/conf.py @@ -0,0 +1,34 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +import sys +import os + +sys.path.insert(0, os.path.abspath("..")) + +project = 'CDP Agentkit - Farcaster LangChain' +author = 'Coinbase Developer Platform' +release = '0.0.1' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'myst_parser', # Parsing Markdown + 'sphinx.ext.autodoc', # Automatically generate documentation from docstrings + 'sphinx.ext.napoleon', # Google-style docstring support + 'sphinx_autodoc_typehints' # Type hints in function signatures +] + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'alabaster' \ No newline at end of file diff --git a/farcaster-langchain/docs/farcaster_langchain.rst b/farcaster-langchain/docs/farcaster_langchain.rst new file mode 100644 index 000000000..d0807b40a --- /dev/null +++ b/farcaster-langchain/docs/farcaster_langchain.rst @@ -0,0 +1,37 @@ +farcaster\_langchain package +=========================== + +Submodules +---------- + +farcaster\_langchain.farcaster\_api\_wrapper module +------------------------------------------------ + +.. automodule:: farcaster_langchain.farcaster_api_wrapper + :members: + :undoc-members: + :show-inheritance: + +farcaster\_langchain.farcaster\_tool module +---------------------------------------- + +.. automodule:: farcaster_langchain.farcaster_tool + :members: + :undoc-members: + :show-inheritance: + +farcaster\_langchain.farcaster\_toolkit module +------------------------------------------ + +.. automodule:: farcaster_langchain.farcaster_toolkit + :members: + :undoc-members: + :show-inheritance: + +Module contents +------------- + +.. automodule:: farcaster_langchain + :members: + :undoc-members: + :show-inheritance: \ No newline at end of file diff --git a/farcaster-langchain/docs/index.rst b/farcaster-langchain/docs/index.rst new file mode 100644 index 000000000..551d3c202 --- /dev/null +++ b/farcaster-langchain/docs/index.rst @@ -0,0 +1,12 @@ +CDP Agentkit - Farcaster LangChain Documentation +============================================== + +.. include:: README.md + :parser: myst_parser.sphinx_ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + :hidden: + + modules \ No newline at end of file diff --git a/farcaster-langchain/docs/make.bat b/farcaster-langchain/docs/make.bat new file mode 100644 index 000000000..9d79dd365 --- /dev/null +++ b/farcaster-langchain/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd \ No newline at end of file diff --git a/farcaster-langchain/docs/modules.rst b/farcaster-langchain/docs/modules.rst new file mode 100644 index 000000000..979884317 --- /dev/null +++ b/farcaster-langchain/docs/modules.rst @@ -0,0 +1,7 @@ +farcaster_langchain +================== + +.. toctree:: + :maxdepth: 4 + + farcaster_langchain \ No newline at end of file