Dappier는 모든 LLM 또는 Agentic AI를 신뢰할 수 있는 출처의 실시간, 권리가 확보된 독점 데이터에 연결하여 AI를 모든 분야의 전문가로 만듭니다. 우리의 특화된 모델에는 실시간 웹 검색, 뉴스, 스포츠, 금융 주식 시장 데이터, 암호화폐 데이터, 그리고 프리미엄 퍼블리셔의 독점 콘텐츠가 포함됩니다. marketplace.dappier.com의 마켓플레이스에서 다양한 데이터 모델을 탐색해보세요. Dappier는 LangChain과의 원활한 통합을 위해 최적화된 풍부하고, 프롬프트 준비가 완료된, 맥락적으로 관련성 있는 데이터 문자열을 제공합니다. 대화형 AI, 추천 엔진 또는 지능형 검색을 구축하든, Dappier의 LLM 독립적인 RAG 모델은 자체 검색 파이프라인을 구축하고 관리하는 복잡성 없이 검증되고 최신 데이터에 대한 액세스를 보장합니다.

Dappier Tool

이 문서는 Dappier tool 시작하기를 도와드립니다. 모든 DappierRetriever 기능 및 구성에 대한 자세한 문서는 API reference를 참조하세요.

Overview

DappierRealTimeSearchTool과 DappierAIRecommendationTool은 실시간 데이터와 AI 기반 인사이트로 AI 애플리케이션을 강화합니다. 전자는 뉴스, 날씨, 여행, 금융 시장 전반에 걸친 최신 정보에 대한 액세스를 제공하며, 후자는 Dappier의 사전 학습된 RAG 모델과 자연어 API로 구동되는 뉴스, 금융, 스포츠와 같은 다양한 도메인의 사실적이고 프리미엄 콘텐츠로 애플리케이션을 강화합니다.

Setup

이 tool은 langchain-dappier 패키지에 있습니다.
pip install -qU langchain-dappier

Credentials

또한 Dappier 사이트에서 생성할 수 있는 Dappier API 자격 증명을 설정해야 합니다.
import getpass
import os

if not os.environ.get("DAPPIER_API_KEY"):
    os.environ["DAPPIER_API_KEY"] = getpass.getpass("Dappier API key:\n")
개별 쿼리에서 자동화된 추적을 원하시면 아래 주석을 해제하여 LangSmith API 키를 설정할 수도 있습니다:
os.environ["LANGSMITH_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")
os.environ["LANGSMITH_TRACING"] = "true"

DappierRealTimeSearchTool

최신 뉴스, 날씨, 여행, 거래를 포함한 실시간 Google 검색 결과와 polygon.io의 최신 금융 뉴스, 주가, 거래에 액세스하며, 모두 AI 인사이트로 구동되어 정보를 제공합니다.

Instantiation

  • ai_model_id: str 쿼리에 사용할 AI 모델 ID입니다. AI 모델 ID는 항상 “am_” 접두사로 시작합니다. 기본값은 “am_01j06ytn18ejftedz6dyhz2b15”입니다. 여러 AI 모델 ID를 사용할 수 있으며, 다음에서 찾을 수 있습니다: marketplace.dappier.com/marketplace
from langchain_dappier import DappierRealTimeSearchTool

tool = DappierRealTimeSearchTool(
    # ai_model_id="...",     # overwrite default ai_model_id
    # name="...",            # overwrite default tool name
    # description="...",     # overwrite default tool description
    # args_schema=...,       # overwrite default args_schema: BaseModel
)

Invocation

인자와 함께 직접 호출

DappierRealTimeSearchTool은 자연어 쿼리여야 하는 단일 “query” 인자를 받습니다:
tool.invoke({"query": "What happened at the last wimbledon"})
"At the last Wimbledon in 2024, Carlos Alcaraz won the title by defeating Novak Djokovic. This victory marked Alcaraz's fourth Grand Slam title at just 21 years old! 🎉🏆🎾"

ToolCall로 호출

모델이 생성한 ToolCall로 tool을 호출할 수도 있으며, 이 경우 ToolMessage가 반환됩니다:
# This is usually generated by a model, but we'll create a tool call directly for demo purposes.
model_generated_tool_call = {
    "args": {"query": "euro 2024 host nation"},
    "id": "1",
    "name": "dappier",
    "type": "tool_call",
}
tool_msg = tool.invoke(model_generated_tool_call)

# The content is a JSON string of results
print(tool_msg.content[:400])
Euro 2024 is being hosted by Germany! 🇩🇪 The tournament runs from June 14 to July 14, 2024, featuring 24 teams competing across various cities like Berlin and Munich. It's going to be an exciting summer of football! ⚽️🏆

Chaining

먼저 tool-calling model에 바인딩한 다음 호출하여 chain에서 tool을 사용할 수 있습니다:
# | 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", temperature=0)
import datetime

from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableConfig, chain

today = datetime.datetime.today().strftime("%D")
prompt = ChatPromptTemplate(
    [
        ("system", f"You are a helpful assistant. The date today is {today}."),
        ("human", "{user_input}"),
        ("placeholder", "{messages}"),
    ]
)

# specifying tool_choice will force the model to call this tool.
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("who won the last womens singles wimbledon")
AIMessage(content="Barbora Krejčíková won the women's singles title at Wimbledon 2024, defeating Jasmine Paolini in the final with a score of 6–2, 2–6, 6–4. This victory marked her first Wimbledon singles title and her second major singles title overall! 🎉🏆🎾", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 69, 'prompt_tokens': 222, 'total_tokens': 291, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_4691090a87', 'finish_reason': 'stop', 'logprobs': None}, id='run-87a385dd-103b-4344-a3be-2d6fd1dcfdf5-0', usage_metadata={'input_tokens': 222, 'output_tokens': 69, 'total_tokens': 291, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})

DappierAIRecommendationTool

Dappier의 사전 학습된 RAG 모델과 자연어 API로 AI 애플리케이션을 강화하여 뉴스, 금융, 스포츠, 날씨 등과 같은 분야의 프리미엄 콘텐츠 제공업체로부터 사실적이고 최신 응답을 제공합니다.

Instantiation

  • data_model_id: str 추천에 사용할 데이터 모델 ID입니다. 데이터 모델 ID는 항상 “dm_” 접두사로 시작합니다. 기본값은 “dm_01j0pb465keqmatq9k83dthx34”입니다. 여러 데이터 모델 ID를 사용할 수 있으며, Dappier marketplace에서 찾을 수 있습니다.
  • similarity_top_k: int 유사성을 기반으로 검색할 상위 문서의 수입니다. 기본값은 “9”입니다.
  • ref: Optional[str] AI 추천이 표시되어야 하는 사이트 도메인입니다. 기본값은 “None”입니다.
  • num_articles_ref: int 지정된 참조 도메인(“ref”)에서 반환할 최소 기사 수입니다. 나머지 기사는 RAG 모델의 다른 사이트에서 가져옵니다. 기본값은 “0”입니다.
  • search_algorithm: Literal[“most_recent”, “semantic”, “most_recent_semantic”, “trending”] 기사 검색에 사용할 검색 알고리즘입니다. 기본값은 “most_recent”입니다.
from langchain_dappier import DappierAIRecommendationTool

tool = DappierAIRecommendationTool(
    data_model_id="dm_01j0pb465keqmatq9k83dthx34",
    similarity_top_k=3,
    ref="sportsnaut.com",
    num_articles_ref=2,
    search_algorithm="most_recent",
    # name="...",            # overwrite default tool name
    # description="...",     # overwrite default tool description
    # args_schema=...,       # overwrite default args_schema: BaseModel
)

Invocation

인자와 함께 직접 호출

DappierAIRecommendationTool은 자연어 쿼리여야 하는 단일 “query” 인자를 받습니다:
tool.invoke({"query": "latest sports news"})
[{'author': 'Matt Weaver',
  'image_url': 'https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/Screenshot_20250117_021643_Gallery_.jpg?width=428&height=321',
  'pubdate': 'Fri, 17 Jan 2025 08:04:03 +0000',
  'source_url': 'https://sportsnaut.com/chili-bowl-thursday-bell-column/',
  'summary': "The article highlights the thrilling unpredictability of the Chili Bowl Midget Nationals, focusing on the dramatic shifts in fortune for drivers like Christopher Bell, Tanner Thorson, and Karter Sarff during Thursday's events. Key moments included Sarff's unfortunate pull-off and a last-lap crash that allowed Ryan Bernal to capitalize and improve his standing, showcasing the chaotic nature of the race and the importance of strategy and luck.\n\nAs the competition intensifies leading up to Championship Saturday, Bell faces the challenge of racing from a Last Chance Race, reflecting on the excitement and difficulties of the sport. The article emphasizes the emotional highs and lows experienced by racers, with insights from Bell and Bernal on the unpredictable nature of racing. Overall, it captures the camaraderie and passion that define the Chili Bowl, illustrating how each moment contributes to the event's narrative.",
  'title': 'Thursday proves why every lap of Chili Bowl is so consequential'},
 {'author': 'Matt Higgins',
  'image_url': 'https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/Pete-Alonso-24524027_.jpg?width=428&height=321',
  'pubdate': 'Fri, 17 Jan 2025 02:48:42 +0000',
  'source_url': 'https://sportsnaut.com/new-york-mets-news-pete-alonso-rejected-last-ditch-contract-offer/',
  'summary': "The New York Mets are likely parting ways with star first baseman Pete Alonso after failing to finalize a contract agreement. Alonso rejected a last-minute three-year offer worth between $68 and $70 million, leading the Mets to redirect funds towards acquiring a top reliever. With Alonso's free-agent options dwindling, speculation arises about his potential signing with another team for the 2025 season, while the Mets plan to shift Mark Vientos to first base.\n\nIn a strategic move, the Mets are also considering a trade for Toronto Blue Jays' star first baseman Vladimir Guerrero Jr. This potential acquisition aims to enhance the Mets' competitiveness as they reshape their roster. Guerrero's impressive offensive stats make him a valuable target, and discussions are in the early stages. Fans and analysts are keenly watching the situation, as a trade involving such a prominent player could significantly impact both teams.",
  'title': 'MLB insiders reveal New York Mets’ last-ditch contract offer that Pete Alonso rejected'},
 {'author': 'Jim Cerny',
  'image_url': 'https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/NHL-New-York-Rangers-at-Utah-25204492_.jpg?width=428&height=321',
  'pubdate': 'Fri, 17 Jan 2025 05:10:39 +0000',
  'source_url': 'https://www.foreverblueshirts.com/new-york-rangers-news/stirring-5-3-comeback-win-utah-close-road-trip/',
  'summary': "The New York Rangers achieved a thrilling 5-3 comeback victory against the Utah Hockey Club, showcasing their resilience after a prior overtime loss. The Rangers scored three unanswered goals in the third period, with key contributions from Reilly Smith, Chris Kreider, and Artemi Panarin, who sealed the win with an empty-net goal. This victory marked their first win of the season when trailing after two periods and capped off a successful road trip, improving their record to 21-20-3.\n\nIgor Shesterkin's strong performance in goal, along with Arthur Kaliyev's first goal for the team, helped the Rangers overcome an early deficit. The game featured multiple lead changes, highlighting the competitive nature of both teams. As the Rangers prepare for their next game against the Columbus Blue Jackets, they aim to close the gap in the playoff race, with the Blue Jackets currently holding a five-point lead in the Eastern Conference standings.",
  'title': 'Rangers score 3 times in 3rd period for stirring 5-3 comeback win against Utah to close road trip'}]

ToolCall로 호출

모델이 생성한 ToolCall로 tool을 호출할 수도 있으며, 이 경우 ToolMessage가 반환됩니다:
# This is usually generated by a model, but we'll create a tool call directly for demo purposes.
model_generated_tool_call = {
    "args": {"query": "top 3 news articles"},
    "id": "1",
    "name": "dappier",
    "type": "tool_call",
}
tool_msg = tool.invoke(model_generated_tool_call)

# The content is a JSON string of results
print(tool_msg.content[:400])
[{"author": "Matt Johnson", "image_url": "https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/MLB-New-York-Mets-at-Colorado-Rockies-23948644_.jpg?width=428&height=321", "pubdate": "Fri, 17 Jan 2025 13:31:02 +0000", "source_url": "https://sportsnaut.com/new-york-mets-rumors-vladimir-guerrero-jr-news/", "summary": "The New York Mets are refocusing their strategy after failing to extend a contra

API reference

모든 DappierRealTimeSearchTool 기능 및 구성에 대한 자세한 문서는 API reference를 참조하세요
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I