Skip to content

Commit

Permalink
Add ntbk
Browse files Browse the repository at this point in the history
  • Loading branch information
rlancemartin committed Sep 17, 2024
1 parent 038bb9d commit b0e80c4
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 26 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ LangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/)

[^1]: https://python.langchain.com/docs/concepts/#tools

## LangGraph API

We can also interact with the graph using the LangGraph API.

See `ntbk/testing.ipynb` for an example of how to do this.

LangGraph Cloud (see [here](https://langchain-ai.github.io/langgraph/cloud/#overview)) make it possible to deploy the agent.

<!--
Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
{
Expand Down
208 changes: 208 additions & 0 deletions ntbk/testing.ipynb

Large diffs are not rendered by default.

29 changes: 3 additions & 26 deletions src/enrichment_agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@


async def search(
query: str, *, config: Annotated[RunnableConfig, InjectedToolArg]
query: str,
*,
config: Annotated[RunnableConfig, InjectedToolArg]
) -> Optional[list[dict[str, Any]]]:
"""
Perform a general web search using the Tavily search engine.
Expand All @@ -31,19 +33,6 @@ async def search(
2. Initializes a TavilySearchResults object with a maximum number of results.
3. Invokes the Tavily search with the given query.
4. Returns the search results as a list of dictionaries.
Args:
query (str): The search query string.
config (RunnableConfig): Configuration object containing search parameters.
Returns:
Optional[list[dict[str, Any]]]: A list of search result dictionaries, or None if the search fails.
Each dictionary typically contains information like title, url, content snippet, etc.
Note:
This function uses the Tavily search engine, which is designed for comprehensive
and accurate results, particularly useful for current events and factual queries.
The maximum number of results is determined by the configuration.
"""
configuration = Configuration.from_runnable_config(config)
wrapped = TavilySearchResults(max_results=configuration.max_search_results)
Expand Down Expand Up @@ -80,18 +69,6 @@ async def scrape_website(
2. Formats a prompt using the fetched content and the extraction schema from the state.
3. Initializes a language model using the provided configuration.
4. Invokes the model with the formatted prompt to summarize the content.
Args:
url (str): The URL of the website to scrape.
state (State): Injected state containing the extraction schema.
config (RunnableConfig): Configuration for initializing the language model.
Returns:
str: A summary of the scraped content, tailored to the extraction schema.
Note:
The function uses aiohttp for asynchronous HTTP requests and assumes the
existence of a _INFO_PROMPT template and an init_model function.
"""
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
Expand Down

0 comments on commit b0e80c4

Please sign in to comment.