-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlangchain_tools_demo.py
More file actions
41 lines (28 loc) · 896 Bytes
/
langchain_tools_demo.py
File metadata and controls
41 lines (28 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
Example: Build Sentience LangChain tools (async-only).
Install:
pip install predicate-runtime[langchain]
Run:
python examples/lang-chain/langchain_tools_demo.py
Notes:
- This example focuses on creating the tools. Hook them into your agent of choice.
"""
from __future__ import annotations
import asyncio
from predicate import AsyncSentienceBrowser
from predicate.integrations.langchain import (
SentienceLangChainContext,
build_sentience_langchain_tools,
)
async def main() -> None:
browser = AsyncSentienceBrowser(headless=False)
await browser.start()
await browser.goto("https://example.com")
ctx = SentienceLangChainContext(browser=browser)
tools = build_sentience_langchain_tools(ctx)
print("Registered tools:")
for t in tools:
print(f"- {t.name}")
await browser.close()
if __name__ == "__main__":
asyncio.run(main())