Skip to main content
Ctrl+K

🦜🔗 LangChain 0.0.139

Getting Started

  • 入门指南

Modules

  • Models(模型)
    • LLMs (大语言模型)
      • Getting Started
      • 通用功能
        • 如何使用 LLM 的异步 API
        • 如何写一个自定义的LLM包装器
        • How (and why) to use the fake LLM
        • How to cache LLM calls
        • How to serialize LLM classes
        • 如何实现 LLM 和 Chat Model 的流式响应
        • How to track token usage
      • Integrations
        • AI21
        • Aleph Alpha
        • Anthropic
        • Azure OpenAI LLM Example
        • Banana
        • CerebriumAI LLM Example
        • Cohere
        • DeepInfra LLM Example
        • ForefrontAI LLM Example
        • GooseAI LLM Example
        • GPT4All
        • Hugging Face Hub
        • Llama-cpp
        • Manifest
        • Modal
        • OpenAI
        • Petals LLM Example
        • PromptLayer OpenAI
        • Replicate
        • SageMakerEndpoint
        • Self-Hosted Models via Runhouse
        • StochasticAI
        • Writer
      • Reference
    • Chat Models
      • Getting Started
      • How-To Guides
        • How to use few shot examples
        • How to stream responses
      • Integrations
        • Azure
        • OpenAI
        • PromptLayer ChatOpenAI
    • Text Embedding Models
      • Aleph Alpha
      • AzureOpenAI
      • Cohere
      • Fake Embeddings
      • Hugging Face Hub
      • InstructEmbeddings
      • Jina
      • Llama-cpp
      • OpenAI
      • SageMaker Endpoint Embeddings
      • Self Hosted Embeddings
      • TensorflowHub
  • Prompts
    • Prompt Templates
      • Getting Started
      • How-To Guides
        • How to create a custom prompt template
        • How to create a prompt template that uses few shot examples
        • How to work with partial Prompt Templates
        • How to serialize prompts
      • Reference
        • PromptTemplates
        • Example Selector
    • Chat Prompt Template
    • Example Selectors
      • How to create a custom example selector
      • LengthBased ExampleSelector
      • Maximal Marginal Relevance ExampleSelector
      • NGram Overlap ExampleSelector
      • Similarity ExampleSelector
    • Output Parsers
      • Output Parsers
      • CommaSeparatedListOutputParser
      • OutputFixingParser
      • PydanticOutputParser
      • RetryOutputParser
      • Structured Output Parser
  • Indexes
    • Getting Started
    • Document Loaders
      • CoNLL-U
      • Airbyte JSON
      • Apify Dataset
      • AZLyrics
      • Azure Blob Storage Container
      • Azure Blob Storage File
      • BigQuery Loader
      • Bilibili
      • Blackboard
      • College Confidential
      • Copy Paste
      • CSV Loader
      • DataFrame Loader
      • Directory Loader
      • DuckDB Loader
      • Email
      • EPubs
      • EverNote
      • Facebook Chat
      • Figma
      • GCS Directory
      • GCS File Storage
      • Git
      • GitBook
      • Google Drive
      • Gutenberg
      • Hacker News
      • HTML
      • iFixit
      • Images
      • IMSDb
      • Markdown
      • Notebook
      • Notion
      • Notion DB Loader
      • Obsidian
      • PDF
      • PowerPoint
      • ReadTheDocs Documentation
      • Roam
      • s3 Directory
      • s3 File
      • Sitemap Loader
      • Slack (Local Exported Zipfile)
      • Subtitle Files
      • Telegram
      • Unstructured File Loader
      • URL
      • Web Base
      • WhatsApp Chat
      • Word Documents
      • YouTube
    • Text Splitters
      • Getting Started
      • Character Text Splitter
      • Hugging Face Length Function
      • Latex Text Splitter
      • Markdown Text Splitter
      • NLTK Text Splitter
      • Python Code Text Splitter
      • RecursiveCharacterTextSplitter
      • Spacy Text Splitter
      • tiktoken (OpenAI) Length Function
      • TiktokenText Splitter
    • Vectorstores
      • Getting Started
      • AtlasDB
      • Chroma
      • Deep Lake
      • ElasticSearch
      • FAISS
      • Milvus
      • OpenSearch
      • PGVector
      • Pinecone
      • Qdrant
      • Redis
      • Weaviate
      • Zilliz
    • Retrievers
      • ChatGPT Plugin Retriever
      • Databerry
      • ElasticSearch BM25
      • Metal
      • Pinecone Hybrid Search
      • TF-IDF Retriever
      • VectorStore Retriever
      • Weaviate Hybrid Search
  • Memory
    • Getting Started
    • How-To Guides
      • ConversationBufferMemory
      • ConversationBufferWindowMemory
      • Entity Memory
      • Conversation Knowledge Graph Memory
      • ConversationSummaryMemory
      • ConversationSummaryBufferMemory
      • ConversationTokenBufferMemory
      • VectorStore-Backed Memory
      • 如何给 LLM Chain(大语言模型链)添加 Memeory(记忆)
      • How to add memory to a Multi-Input Chain
      • How to add Memory to an Agent
      • 给Agent(代理)添加由数据库支持的消息存储
      • How to customize conversational memory
      • How to create a custom Memory class
      • Motörhead Memory
      • How to use multiple memory classes in the same chain
      • Postgres Chat Message History
      • Redis Chat Message History
  • Chains
    • Getting Started
    • How-To Guides
      • Async API for Chain
      • Loading from LangChainHub
      • LLM Chain
      • Sequential Chains
      • Serialization
      • Transformation Chain
      • Analyze Document
      • Chat Over Documents with Chat History
      • Graph QA
      • Hypothetical Document Embeddings
      • Question Answering with Sources
      • Question Answering
      • Summarization
      • Retrieval Question/Answering
      • Retrieval Question Answering with Sources
      • Vector DB Text Generation
      • API Chains
      • Self-Critique Chain with Constitutional AI
      • BashChain
      • LLMCheckerChain
      • LLM Math
      • LLMRequestsChain
      • LLMSummarizationCheckerChain
      • Moderation
      • OpenAPI Chain
      • PAL
      • SQL Chain example
    • Reference
  • Agents
    • Getting Started
    • Tools
      • Getting Started
      • Defining Custom Tools
      • Multi-Input Tools
      • Apify
      • Bash
      • Bing Search
      • ChatGPT Plugins
      • Google Search
      • Google Serper API
      • Human as a tool
      • IFTTT WebHooks
      • OpenWeatherMap API
      • Python REPL
      • Requests
      • Search Tools
      • SearxNG Search API
      • SerpAPI
      • Wikipedia API
      • Wolfram Alpha
      • Zapier Natural Language Actions API
    • Agents
      • Agent Types
      • Custom Agent
      • Custom LLM Agent
      • Custom LLM Agent (with a ChatModel)
      • Custom MRKL Agent
      • Custom MultiAction Agent
      • Custom Agent with Tool Retrieval
      • Conversation Agent (for Chat Models)
      • Conversation Agent
      • MRKL
      • MRKL Chat
      • ReAct
      • Self Ask With Search
    • Toolkits
      • CSV Agent
      • JSON Agent
      • OpenAPI agents
      • Natural Language APIs
      • Pandas Dataframe Agent
      • Python Agent
      • SQL Database Agent
      • Vectorstore Agent
    • Agent Executors
      • How to combine agents and vectorstores
      • How to use the async API for Agents
      • How to create ChatGPT Clone
      • How to access intermediate steps
      • How to cap the max number of iterations
      • How to use a timeout for the agent
      • How to add SharedMemory to an Agent and its Tools

Use Cases

  • Personal Assistants (Agents)
  • Question Answering over Docs
  • Chatbots
  • Querying Tabular Data
  • Code Understanding
  • Interacting with APIs
  • Summarization
  • Extraction
  • Evaluation
    • Agent Benchmarking: Search + Calculator
    • Agent VectorDB Question Answering Benchmarking
    • Benchmarking Template
    • Data Augmented Question Answering
    • Using Hugging Face Datasets
    • LLM Math
    • Evaluating an OpenAPI Chain
    • Question Answering Benchmarking: Paul Graham Essay
    • Question Answering Benchmarking: State of the Union Address
    • QA Generation
    • Question Answering
    • SQL Question Answering Benchmarking: Chinook

Reference

  • Installation
  • Integrations
  • API References
    • Prompts
      • PromptTemplates
      • Example Selector
    • Utilities
      • Python REPL
      • SerpAPI
      • SearxNG Search
      • Docstore
      • Text Splitter
      • Embeddings
      • VectorStores
    • Chains
    • Agents

Ecosystem

  • LangChain Ecosystem
    • AI21 Labs
    • Aim
    • Apify
    • AtlasDB
    • Banana
    • CerebriumAI
    • Chroma
    • ClearML Integration
    • Cohere
    • Comet
    • Databerry
    • DeepInfra
    • Deep Lake
    • ForefrontAI
    • Google Search Wrapper
    • Google Serper Wrapper
    • GooseAI
    • GPT4All
    • Graphsignal
    • Hazy Research
    • Helicone
    • Hugging Face
    • Jina
    • Llama.cpp
    • Milvus
    • Modal
    • NLPCloud
    • OpenAI
    • OpenSearch
    • Petals
    • PGVector
    • Pinecone
    • PromptLayer
    • Qdrant
    • Replicate
    • Runhouse
    • RWKV-4
    • SearxNG Search API
    • SerpAPI
    • StochasticAI
    • Unstructured
    • Weights & Biases
    • Weaviate
    • Wolfram Alpha Wrapper
    • Writer
    • Zilliz

Additional Resources

  • LangChainHub
  • Glossary
  • LangChain Gallery
  • Deployments
  • Tracing
  • Discord
  • Production Support
  • .ipynb

Bing Search

Contents

  • Number of results
  • Metadata Results

Bing Search#

This notebook goes over how to use the bing search component.

First, you need to set up the proper API keys and environment variables. To set it up, follow the instructions found here.

Then we will need to set some environment variables.

import os
os.environ["BING_SUBSCRIPTION_KEY"] = ""
os.environ["BING_SEARCH_URL"] = ""
from langchain.utilities import BingSearchAPIWrapper
search = BingSearchAPIWrapper()
search.run("python")
'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentials, JMESPath result parsing, lazy initialization, network-less unit tests, and more. Building an open-source and cross-platform Azure CLI with <b>Python</b> by Dan Taylor. <b>Python</b> releases by version number: Release version Release date Click for more. <b>Python</b> 3.11.1 Dec. 6, 2022 Download Release Notes. <b>Python</b> 3.10.9 Dec. 6, 2022 Download Release Notes. <b>Python</b> 3.9.16 Dec. 6, 2022 Download Release Notes. <b>Python</b> 3.8.16 Dec. 6, 2022 Download Release Notes. <b>Python</b> 3.7.16 Dec. 6, 2022 Download Release Notes. In this lesson, we will look at the += operator in <b>Python</b> and see how it works with several simple examples.. The operator ‘+=’ is a shorthand for the addition assignment operator.It adds two values and assigns the sum to a variable (left operand). W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, <b>Python</b>, SQL, Java, and many, many more. This tutorial introduces the reader informally to the basic concepts and features of the <b>Python</b> language and system. It helps to have a <b>Python</b> interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well. For a description of standard objects and modules, see The <b>Python</b> Standard ... <b>Python</b> is a general-purpose, versatile, and powerful programming language. It&#39;s a great first language because <b>Python</b> code is concise and easy to read. Whatever you want to do, <b>python</b> can do it. From web development to machine learning to data science, <b>Python</b> is the language for you. To install <b>Python</b> using the Microsoft Store: Go to your Start menu (lower left Windows icon), type &quot;Microsoft Store&quot;, select the link to open the store. Once the store is open, select Search from the upper-right menu and enter &quot;<b>Python</b>&quot;. Select which version of <b>Python</b> you would like to use from the results under Apps. Under the “<b>Python</b> Releases for Mac OS X” heading, click the link for the Latest <b>Python</b> 3 Release - <b>Python</b> 3.x.x. As of this writing, the latest version was <b>Python</b> 3.8.4. Scroll to the bottom and click macOS 64-bit installer to start the download. When the installer is finished downloading, move on to the next step. Step 2: Run the Installer'

Number of results#

You can use the k parameter to set the number of results

search = BingSearchAPIWrapper(k=1)
search.run("python")
'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentials, JMESPath result parsing, lazy initialization, network-less unit tests, and more. Building an open-source and cross-platform Azure CLI with <b>Python</b> by Dan Taylor.'

Metadata Results#

Run query through BingSearch and return snippet, title, and link metadata.

  • Snippet: The description of the result.

  • Title: The title of the result.

  • Link: The link to the result.

search = BingSearchAPIWrapper()
search.results("apples", 5)
[{'snippet': 'Lady Alice. Pink Lady <b>apples</b> aren’t the only lady in the apple family. Lady Alice <b>apples</b> were discovered growing, thanks to bees pollinating, in Washington. They are smaller and slightly more stout in appearance than other varieties. Their skin color appears to have red and yellow stripes running from stem to butt.',
  'title': '25 Types of Apples - Jessica Gavin',
  'link': 'https://www.jessicagavin.com/types-of-apples/'},
 {'snippet': '<b>Apples</b> can do a lot for you, thanks to plant chemicals called flavonoids. And they have pectin, a fiber that breaks down in your gut. If you take off the apple’s skin before eating it, you won ...',
  'title': 'Apples: Nutrition &amp; Health Benefits - WebMD',
  'link': 'https://www.webmd.com/food-recipes/benefits-apples'},
 {'snippet': '<b>Apples</b> boast many vitamins and minerals, though not in high amounts. However, <b>apples</b> are usually a good source of vitamin C. Vitamin C. Also called ascorbic acid, this vitamin is a common ...',
  'title': 'Apples 101: Nutrition Facts and Health Benefits',
  'link': 'https://www.healthline.com/nutrition/foods/apples'},
 {'snippet': 'Weight management. The fibers in <b>apples</b> can slow digestion, helping one to feel greater satisfaction after eating. After following three large prospective cohorts of 133,468 men and women for 24 years, researchers found that higher intakes of fiber-rich fruits with a low glycemic load, particularly <b>apples</b> and pears, were associated with the least amount of weight gain over time.',
  'title': 'Apples | The Nutrition Source | Harvard T.H. Chan School of Public Health',
  'link': 'https://www.hsph.harvard.edu/nutritionsource/food-features/apples/'}]

previous

Bash

next

ChatGPT Plugins

Contents
  • Number of results
  • Metadata Results

By Harrison Chase

© Copyright 2023, Harrison Chase.

Last updated on Apr 18, 2023.