개요
통합 세부정보
| Class | Package | Serializable | JS support | Version |
|---|---|---|---|---|
| JinaSearch | langchain-community | ❌ | ❌ |
도구 기능
| Returns artifact | Native async | Return data | Pricing |
|---|---|---|---|
| ❌ | ❌ | URL, Snippet, Title, Page Content | 1M 응답 토큰 무료 |
설정
이 통합은langchain-community 패키지에 포함되어 있으며 버전 0.2.16에 추가되었습니다:
Copy
pip install --quiet -U "langchain-community>=0.2.16"
자격 증명
Copy
import getpass
import os
if not os.environ.get("JINA_API_KEY"):
os.environ["JINA_API_KEY"] = getpass.getpass("Jina API key:\n")
Copy
os.environ["LANGSMITH_TRACING"] = "true"
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass()
인스턴스화
- TODO: Fill in instantiation params
Copy
from langchain_community.tools import JinaSearch
tool = JinaSearch()
호출
인수로 직접 호출하기
Copy
print(tool.invoke({"query": "what is langgraph"})[:1000])
Copy
[{"title": "LangGraph", "link": "https://www.langchain.com/langgraph", "snippet": "<strong>LangGraph</strong> helps teams of all sizes, across all industries, from ambitious startups to established enterprises. \u201cLangChain is streets ahead with what they've put forward with <strong>LangGraph</strong>.", "content": "\n\nControllable cognitive architecture for any task\n------------------------------------------------\n\nLangGraph's flexible API supports diverse control flows \u2013 single agent, multi-agent, hierarchical, sequential \u2013 and robustly handles realistic, complex scenarios.\n\nEnsure reliability with easy-to-add moderation and quality loops that prevent agents from veering off course.\n\n[See the docs](https://langchain-ai.github.io/langgraph/)\n\nDesigned for human-agent collaboration\n--------------------------------------\n\nWith built-in stat
ToolCall로 호출하기
모델이 생성한 ToolCall로 도구를 호출할 수도 있으며, 이 경우 ToolMessage가 반환됩니다:Copy
# 이것은 일반적으로 모델에 의해 생성되지만, 데모 목적으로 직접 도구 호출을 생성합니다.
model_generated_tool_call = {
"args": {"query": "what is langgraph"},
"id": "1",
"name": tool.name,
"type": "tool_call",
}
tool_msg = tool.invoke(model_generated_tool_call)
print(tool_msg.content[:1000])
Copy
[{"title": "LangGraph Tutorial: What Is LangGraph and How to Use It?", "link": "https://www.datacamp.com/tutorial/langgraph-tutorial", "snippet": "<strong>LangGraph</strong> <strong>is</strong> a library within the LangChain ecosystem that provides a framework for defining, coordinating, and executing multiple LLM agents (or chains) in a structured and efficient manner.", "content": "Imagine you're building a complex, multi-agent large language model (LLM) application. It's exciting, but it comes with challenges: managing the state of various agents, coordinating their interactions, and handling errors effectively. This is where LangGraph can help.\n\nLangGraph is a library within the LangChain ecosystem designed to tackle these challenges head-on. LangGraph provides a framework for defining, coordinating, and executing multiple LLM agents (or chains) in a structured manner.\n\nIt simplifies the development process by enabling the creation of cyclical graphs, which are essential for de
체이닝
먼저 도구 호출 모델에 도구를 바인딩한 다음 호출하여 체인에서 도구를 사용할 수 있습니다:Copy
# | output: false
# | echo: false
# !pip install -qU langchain langchain-openai
from langchain.chat_models import init_chat_model
model = init_chat_model(model="gpt-4o", model_provider="openai")
Copy
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableConfig, chain
prompt = ChatPromptTemplate(
[
("system", "You are a helpful assistant."),
("human", "{user_input}"),
("placeholder", "{messages}"),
]
)
model_with_tools = model.bind_tools([tool])
model_chain = prompt | model_with_tools
@chain
def tool_chain(user_input: str, config: RunnableConfig):
input_ = {"user_input": user_input}
ai_msg = model_chain.invoke(input_, config=config)
tool_msgs = tool.batch(ai_msg.tool_calls, config=config)
return model_chain.invoke({**input_, "messages": [ai_msg, *tool_msgs]}, config=config)
tool_chain.invoke("what's langgraph")
Copy
AIMessage(content="LangGraph is a library designed for building stateful, multi-actor applications with language models (LLMs). It is particularly useful for creating agent and multi-agent workflows. Compared to other LLM frameworks, LangGraph offers unique benefits such as cycles, controllability, and persistence. Here are some key points:\n\n1. **Stateful and Multi-Actor Applications**: LangGraph allows for the definition of flows involving cycles, essential for most agentic architectures. This is a significant differentiation from Directed Acyclic Graph (DAG)-based solutions.\n\n2. **Controllability**: The framework offers fine-grained control over both the flow and state of applications, which is crucial for creating reliable agents.\n\n3. **Persistence**: Built-in persistence is available, enabling advanced features like human-in-the-loop workflows and memory.\n\n4. **Human-in-the-Loop**: LangGraph supports interrupting graph execution for human approval or editing of the agent's next planned action.\n\n5. **Streaming Support**: The library can stream outputs as they are produced by each node, including token streaming.\n\n6. **Integration with LangChain**: While it integrates seamlessly with LangChain and LangSmith, LangGraph can also be used independently.\n\n7. **Inspiration and Interface**: LangGraph is inspired by systems like Pregel and Apache Beam, with its public interface drawing inspiration from NetworkX.\n\nLangGraph is designed to handle more complex agent applications that require cycles and state management, making it an ideal choice for developers seeking to build sophisticated LLM-driven applications. For more detailed information, you can visit their [official documentation](https://langchain-ai.github.io/langgraph/).", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 338, 'prompt_tokens': 14774, 'total_tokens': 15112}, 'model_name': 'gpt-4o-2024-05-13', 'system_fingerprint': 'fp_157b3831f5', 'finish_reason': 'stop', 'logprobs': None}, id='run-420d16ed-535c-41c6-8814-2186b42be0f8-0', usage_metadata={'input_tokens': 14774, 'output_tokens': 338, 'total_tokens': 15112})
API 레퍼런스
모든 Jina 기능 및 구성에 대한 자세한 문서는 API 레퍼런스를 참조하세요: python.langchain.com/api_reference/community/tools/langchain_community.tools.jina_search.tool.JinaSearch.htmlConnect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.