langchain-shinapi 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ __pycache__/
2
+ .venv/
3
+ dist/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ShinAPI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.5
2
+ Name: langchain-shinapi
3
+ Version: 0.1.1
4
+ Summary: Search what high-authority Japanese sites say now, as a LangChain tool and retriever. By ShinAPI.
5
+ Project-URL: Homepage, https://shinapi.com
6
+ Project-URL: Documentation, https://docs.shinapi.com
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: agents,japan,japanese,langchain,llm,rag,search
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: langchain-core<2,>=1
12
+ Requires-Dist: shinapi>=0.1
13
+ Description-Content-Type: text/markdown
14
+
15
+ # langchain-shinapi
16
+
17
+ Search what high-authority Japanese sites say now, from LangChain: a tool for agents and a retriever for RAG. By
18
+ [ShinAPI](https://shinapi.com).
19
+
20
+ ```sh
21
+ pip install langchain-shinapi
22
+ ```
23
+
24
+ Get a key in the [console](https://console.shinapi.com) and set `SHINAPI_KEY`, or pass `api_key`.
25
+
26
+ ## The tool
27
+
28
+ ```python
29
+ from langchain.agents import create_agent
30
+ from langchain_shinapi import ShinAPISearch
31
+
32
+ agent = create_agent("anthropic:claude-sonnet-5-5", tools=[ShinAPISearch()])
33
+ agent.invoke({"messages": [{"role": "user", "content": "2026年の年収の壁はいくらですか"}]})
34
+ ```
35
+
36
+ The tool answers the model with the search's JSON, and keeps the parsed answer as the message's artifact. Its
37
+ description tells the model what is indexed and what to do with each outcome: `answered`, `no_match_in_scope` or
38
+ `out_of_scope`.
39
+
40
+ ## The retriever
41
+
42
+ ```python
43
+ from langchain_shinapi import ShinAPIRetriever
44
+
45
+ retriever = ShinAPIRetriever(k=8, exclude_domains=["example.co.jp"])
46
+ for document in retriever.invoke("育児休業給付金の支給率"):
47
+ print(document.metadata["url"], document.metadata["attribution"], document.page_content)
48
+ ```
49
+
50
+ Each passage is a document: its text is the page content, and its URL, title, publisher, dates, licence and credit line
51
+ are the metadata. Show the attribution where you show the text.
52
+
53
+ Read the [docs](https://docs.shinapi.com).
@@ -0,0 +1,39 @@
1
+ # langchain-shinapi
2
+
3
+ Search what high-authority Japanese sites say now, from LangChain: a tool for agents and a retriever for RAG. By
4
+ [ShinAPI](https://shinapi.com).
5
+
6
+ ```sh
7
+ pip install langchain-shinapi
8
+ ```
9
+
10
+ Get a key in the [console](https://console.shinapi.com) and set `SHINAPI_KEY`, or pass `api_key`.
11
+
12
+ ## The tool
13
+
14
+ ```python
15
+ from langchain.agents import create_agent
16
+ from langchain_shinapi import ShinAPISearch
17
+
18
+ agent = create_agent("anthropic:claude-sonnet-5-5", tools=[ShinAPISearch()])
19
+ agent.invoke({"messages": [{"role": "user", "content": "2026年の年収の壁はいくらですか"}]})
20
+ ```
21
+
22
+ The tool answers the model with the search's JSON, and keeps the parsed answer as the message's artifact. Its
23
+ description tells the model what is indexed and what to do with each outcome: `answered`, `no_match_in_scope` or
24
+ `out_of_scope`.
25
+
26
+ ## The retriever
27
+
28
+ ```python
29
+ from langchain_shinapi import ShinAPIRetriever
30
+
31
+ retriever = ShinAPIRetriever(k=8, exclude_domains=["example.co.jp"])
32
+ for document in retriever.invoke("育児休業給付金の支給率"):
33
+ print(document.metadata["url"], document.metadata["attribution"], document.page_content)
34
+ ```
35
+
36
+ Each passage is a document: its text is the page content, and its URL, title, publisher, dates, licence and credit line
37
+ are the metadata. Show the attribution where you show the text.
38
+
39
+ Read the [docs](https://docs.shinapi.com).
@@ -0,0 +1,4 @@
1
+ from langchain_shinapi.retrievers import ShinAPIRetriever
2
+ from langchain_shinapi.tools import ShinAPISearch
3
+
4
+ __all__ = ["ShinAPIRetriever", "ShinAPISearch"]
File without changes
@@ -0,0 +1,41 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, Optional
4
+
5
+ from langchain_core.callbacks import CallbackManagerForRetrieverRun
6
+ from langchain_core.documents import Document
7
+ from langchain_core.retrievers import BaseRetriever
8
+ from pydantic import ConfigDict, Field, SecretStr
9
+ from shinapi import SearchResult, ShinAPI
10
+
11
+
12
+ def document_of(result: SearchResult) -> Document:
13
+ metadata = {field: value for field, value in result.items() if field != "text"}
14
+ return Document(page_content=result["text"], metadata=metadata)
15
+
16
+
17
+ class ShinAPIRetriever(BaseRetriever):
18
+ model_config = ConfigDict(arbitrary_types_allowed=True)
19
+
20
+ k: int = Field(default=8, ge=1, le=32)
21
+ exclude_domains: list[str] = Field(default_factory=list)
22
+ exclude_text: list[str] = Field(default_factory=list)
23
+ api_key: Optional[SecretStr] = Field(default=None, exclude=True)
24
+ client: Optional[ShinAPI] = Field(default=None, exclude=True)
25
+
26
+ def model_post_init(self, context: Any) -> None:
27
+ if self.client is None:
28
+ key = self.api_key.get_secret_value() if self.api_key else None
29
+ self.client = ShinAPI(key)
30
+
31
+ def _get_relevant_documents(
32
+ self, query: str, *, run_manager: CallbackManagerForRetrieverRun
33
+ ) -> list[Document]:
34
+ assert self.client is not None
35
+ answer = self.client.search(
36
+ query,
37
+ max_results=self.k,
38
+ exclude_domains=self.exclude_domains,
39
+ exclude_text=self.exclude_text,
40
+ )
41
+ return [document_of(result) for result in answer["results"]]
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from typing import Any, Literal, Optional
5
+
6
+ from langchain_core.callbacks import CallbackManagerForToolRun
7
+ from langchain_core.tools import BaseTool
8
+ from langchain_core.tools.base import ArgsSchema
9
+ from pydantic import ConfigDict, Field, SecretStr
10
+ from shinapi import SEARCH_DESCRIPTION, SEARCH_INPUT, SearchResponse, ShinAPI
11
+
12
+
13
+ class ShinAPISearch(BaseTool):
14
+ model_config = ConfigDict(arbitrary_types_allowed=True)
15
+
16
+ name: str = "shinapi_search"
17
+ description: str = SEARCH_DESCRIPTION
18
+ args_schema: Optional[ArgsSchema] = SEARCH_INPUT
19
+ response_format: Literal["content", "content_and_artifact"] = "content_and_artifact"
20
+ api_key: Optional[SecretStr] = Field(default=None, exclude=True)
21
+ client: Optional[ShinAPI] = Field(default=None, exclude=True)
22
+
23
+ def model_post_init(self, context: Any) -> None:
24
+ if self.client is None:
25
+ key = self.api_key.get_secret_value() if self.api_key else None
26
+ self.client = ShinAPI(key)
27
+
28
+ def _run(
29
+ self,
30
+ query: str,
31
+ max_results: Optional[int] = None,
32
+ exclude_domains: Optional[list[str]] = None,
33
+ exclude_text: Optional[list[str]] = None,
34
+ run_manager: Optional[CallbackManagerForToolRun] = None,
35
+ ) -> tuple[str, SearchResponse]:
36
+ assert self.client is not None
37
+ answer = self.client.search(
38
+ query,
39
+ max_results=max_results,
40
+ exclude_domains=exclude_domains,
41
+ exclude_text=exclude_text,
42
+ )
43
+ return json.dumps(answer, ensure_ascii=False), answer
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "langchain-shinapi"
7
+ version = "0.1.1"
8
+ description = "Search what high-authority Japanese sites say now, as a LangChain tool and retriever. By ShinAPI."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.11"
12
+ keywords = ["langchain", "search", "japan", "japanese", "llm", "rag", "agents"]
13
+ dependencies = ["langchain-core>=1,<2", "shinapi>=0.1"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://shinapi.com"
17
+ Documentation = "https://docs.shinapi.com"
18
+
19
+ [tool.hatch.build.targets.wheel]
20
+ packages = ["langchain_shinapi"]
21
+
22
+ [tool.hatch.build.targets.sdist]
23
+ only-include = ["langchain_shinapi", "README.md", "LICENSE"]