Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/docs/integrations/providers/naver-community.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# NAVER

All functionality related to Naver tools and services integrated with LangChain.

> [Naver](https://navercorp.com/) is a global technology company based in South Korea, offering various services including search, commerce, fintech, content, cloud, and AI.

> **Note**: `langchain-naver-community` is an unofficial, community-maintained package and is not officially supported by Naver or LangChain. It provides integration with Naver services through their public APIs.

## Installation and Setup

```bash
pip install -U langchain-naver-community
```

## Tools

### Naver Search

The Naver Search integration allows your LangChain applications to retrieve information from Naver's search engine. This is particularly useful for Korean language queries and getting up-to-date information about Korean topics.

To use the Naver Search tools, you need to:

1. Sign in to the [Naver Developers portal](https://developers.naver.com/main/)
2. Create a new application and enable the Search API
3. Obtain your **NAVER_CLIENT_ID** and **NAVER_CLIENT_SECRET** from the "Application List" section
4. Set these as environment variables in your application

```python
from langchain_naver_community.tool import NaverSearchResults
from langchain_naver_community.utils import NaverSearchAPIWrapper

# Set up the search wrapper
search = NaverSearchAPIWrapper()

# Create a tool
tool = NaverSearchResults(api_wrapper=search)
```

See a [usage example](/docs/integrations/tools/naver_search) for more details.

### Specialized Search Tools

The package also provides specialized search tools for different types of content:

```python
from langchain_naver_community.tool import NaverNewsSearch # For news articles
from langchain_naver_community.tool import NaverBlogSearch # For blog posts
from langchain_naver_community.tool import NaverImageSearch # For images
```

Each of these can be used within LangChain agents to provide more targeted search capabilities.
12 changes: 11 additions & 1 deletion docs/docs/integrations/providers/naver.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@ See a [usage example](/docs/integrations/text_embedding/naver).

```python
from langchain_community.embeddings import ClovaXEmbeddings
```
```

## Tools

### Naver_search

See a [usage example](/docs/integrations/text_embedding/naver).

```python
from langchain_naver_community.tool import NaverSearchResults
```
262 changes: 262 additions & 0 deletions docs/docs/integrations/tools/naver_search.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "245a954a",
"metadata": {},
"source": [
"# Naver Search\n",
"\n",
"## Overview\n",
"\n",
"### Integration details\n",
"\n",
"| Class | Package | Serializable | JS support | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: |\n",
"| NaverSearchResults | [langchain-naver-community](https://pypi.org/project/langchain-naver-community/) | ❌ | ❌ | ![PyPI - Version](https://img.shields.io/pypi/v/langchain-naver-community?style=flat-square&label=%20) |\n",
"\n",
"### Tool features\n",
"\n",
"**Search** : The Naver Search Tool provides a simple interface to search Naver and get results: \n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence ends abruptly.

Copy link
Contributor Author

@e7217 e7217 Mar 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback.

"\n",
"## Setup\n",
"### Setting Up API Credentials\n",
"To use Naver Search, you need to obtain API credentials. Follow these steps:\n",
"\n",
"Sign in to the [Naver Developers portal](https://developers.naver.com/main/).\n",
"Create a new application and enable the Search API.\n",
"Obtain your **NAVER_CLIENT_ID** and **NAVER_CLIENT_SECRET** from the \"Application List\" section.\n",
"\n",
"### Setting Up Environment Variables\n",
"After obtaining the credentials, set them as environment variables in your script:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a2998f9c",
"metadata": {},
"outputs": [],
"source": [
"%pip install --upgrade --quiet langchain-naver-community"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "30692b20",
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"if not os.environ.get(\"NAVER_CLIENT_ID\"):\n",
" os.environ[\"NAVER_CLIENT_ID\"] = getpass.getpass(\"Enter your Naver Client ID:\\n\")\n",
"\n",
"if not os.environ.get(\"NAVER_CLIENT_SECRET\"):\n",
" os.environ[\"NAVER_CLIENT_SECRET\"] = getpass.getpass(\n",
" \"Enter your Naver Client Secret:\\n\"\n",
" )"
]
},
{
"cell_type": "markdown",
"id": "c43917d5",
"metadata": {},
"source": [
"## Instantiation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3d2be578",
"metadata": {},
"outputs": [],
"source": [
"from langchain_naver_community.utils import NaverSearchAPIWrapper\n",
"\n",
"search = NaverSearchAPIWrapper()"
]
},
{
"cell_type": "markdown",
"id": "c97b3f7a",
"metadata": {},
"source": [
"## Invocation"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "ac4910f8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'title': 'Seoul shares rise for 4th day on tech gains; won at 2-week low',\n",
" 'link': 'https://n.news.naver.com/mnews/article/001/0015277717?sid=104',\n",
" 'description': 'stocks-summary Seoul shares rise for 4th day on tech gains; won at 2-week low SEOUL, March 20 (Yonhap) -- Seoul shares extended their winning streak to a fourth day Thursday on the back of gains... ',\n",
" 'pubDate': 'Thu, 20 Mar 2025 16:09:00 +0900'},\n",
" {'title': \"Seoul Mayor Oh's residence, office raided over alleged ties to shadowy po...\",\n",
" 'link': 'https://n.news.naver.com/mnews/article/640/0000067073?sid=100',\n",
" 'description': 'Prosecutors on Thursday raided Seoul Mayor Oh Se-hoon’s official residence and the City Hall... The raid came as part of the Seoul Central District Prosecutors’ Office’s probe into... ',\n",
" 'pubDate': 'Thu, 20 Mar 2025 19:12:00 +0900'},\n",
" {'title': 'Education can heal divides: Seoul schools chief',\n",
" 'link': 'https://n.news.naver.com/mnews/article/044/0000267866?sid=104',\n",
" 'description': 'Jung Keun-sik, Superintendent of Seoul Metropolitan Office of Education speaks during an interview with The Korea Herald at his office on March 13. (Lim Se-jun/ The Korea Herald) Seoul education... ',\n",
" 'pubDate': 'Thu, 20 Mar 2025 14:35:00 +0900'}]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"search.results(\"Seoul\")[:3]"
]
},
{
"cell_type": "markdown",
"id": "2511982a",
"metadata": {},
"source": [
"## Tool Usage"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "e17126e7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'title': \"2025 is here. Here's what to watch out for\",\n",
" 'link': 'https://n.news.naver.com/mnews/article/044/0000265707?sid=104',\n",
" 'description': 'The trend was predicted in "Trend Korea 2025," written by Kim Ran-do, a professor of consumer science at Seoul National University, and his team. The annually published book also predicts that... ',\n",
" 'pubDate': 'Sat, 18 Jan 2025 16:01:00 +0900'},\n",
" {'title': '[INTERVIEW] Korea to overhaul weather prediction model against climate ch...',\n",
" 'link': 'https://www.koreatimes.co.kr/www/nation/2023/06/371_353628.html?utm_source=na',\n",
" 'description': 'western Seoul to protest its confusing weather predictions, false forecasting is hardly accepted compared to what Yoo saw in Oklahoma. The administrator hopes the Korean public would understand... ',\n",
" 'pubDate': 'Sun, 25 Jun 2023 17:22:00 +0900'}]"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from langchain_naver_community.tool import NaverSearchResults\n",
"from langchain_naver_community.utils import NaverSearchAPIWrapper\n",
"\n",
"search = NaverSearchAPIWrapper()\n",
"\n",
"tool = NaverSearchResults(api_wrapper=search)\n",
"\n",
"tool.invoke(\"what is the weather in seoul?\")[3:5]"
]
},
{
"cell_type": "markdown",
"id": "74295cb5",
"metadata": {},
"source": [
"## Use within an agent\n",
"\n",
"The Naver Search tool can be integrated into LangChain agents for more complex tasks. Below we demonstrate how to set up an agent that can search Naver for current information.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "386e19b0",
"metadata": {},
"outputs": [],
"source": [
"from langchain_openai import ChatOpenAI\n",
"\n",
"llm = ChatOpenAI(model=\"gpt-4o-mini\")\n",
"\n",
"system_prompt = \"\"\"\n",
"You are a helpful assistant that can search the web for information.\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "70da8682",
"metadata": {},
"outputs": [],
"source": [
"from langchain_naver_community.tool import NaverNewsSearch\n",
"from langgraph.prebuilt import create_react_agent\n",
"\n",
"tools = [NaverNewsSearch()]\n",
"\n",
"agent_executor = create_react_agent(\n",
" llm,\n",
" tools,\n",
" prompt=system_prompt,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "4b73dbaf",
"metadata": {},
"source": [
"Now we can run the agent with a query."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "726e575a",
"metadata": {},
"outputs": [],
"source": [
"query = \"What is the weather in Seoul?\"\n",
"result = agent_executor.invoke({\"messages\": [(\"human\", query)]})\n",
"result[\"messages\"][-1].content"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"result[\"messages\"][-1].content"
"result[\"messages\"][-1].pretty_print()"

Might be nice to run this to show output!

]
},
{
"cell_type": "markdown",
"id": "d566a4c0",
"metadata": {},
"source": [
"## API reference\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
3 changes: 3 additions & 0 deletions libs/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,6 @@ packages:
provider_page: zotero
downloads: 153
downloads_updated_at: '2025-03-22T21:59:15.663971+00:00'
- name: langchain-naver-community
path: .
repo: e7217/langchain-naver-community
Loading