mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-09 19:35:20 +03:00
6.5 KiB
6.5 KiB
In [ ]:
from langchain.utilities.dataforseo_api_search import DataForSeoAPIWrapperIn [ ]:
import os
os.environ["DATAFORSEO_LOGIN"] = "your_api_access_username"
os.environ["DATAFORSEO_PASSWORD"] = "your_api_access_password"
wrapper = DataForSeoAPIWrapper()In [ ]:
wrapper.run("Weather in Los Angeles")In [ ]:
json_wrapper = DataForSeoAPIWrapper(
json_result_types=["organic", "knowledge_graph", "answer_box"],
json_result_fields=["type", "title", "description", "text"],
top_count=3,
)In [ ]:
json_wrapper.results("Bill Gates")In [ ]:
customized_wrapper = DataForSeoAPIWrapper(
top_count=10,
json_result_types=["organic", "local_pack"],
json_result_fields=["title", "description", "type"],
params={"location_name": "Germany", "language_code": "en"},
)
customized_wrapper.results("coffee near me")In [ ]:
customized_wrapper = DataForSeoAPIWrapper(
top_count=10,
json_result_types=["organic", "local_pack"],
json_result_fields=["title", "description", "type"],
params={"location_name": "Germany", "language_code": "en", "se_name": "bing"},
)
customized_wrapper.results("coffee near me")In [ ]:
maps_search = DataForSeoAPIWrapper(
top_count=10,
json_result_fields=["title", "value", "address", "rating", "type"],
params={
"location_coordinate": "52.512,13.36,12z",
"language_code": "en",
"se_type": "maps",
},
)
maps_search.results("coffee near me")In [ ]:
from langchain.agents import Tool
search = DataForSeoAPIWrapper(
top_count=3,
json_result_types=["organic"],
json_result_fields=["title", "description", "type"],
)
tool = Tool(
name="google-search-answer",
description="My new answer tool",
func=search.run,
)
json_tool = Tool(
name="google-search-json",
description="My new json tool",
func=search.results,
)