liveBook · Manning

Connector

As explained in Data Analysis with LLMs

An integration component that enables a language model to access external data sources such as web search services or databases.

A connector lets a language model access external data, such as web search or databases. By grounding answers in retrieved information, it can reduce unsupported claims and expose sources readers can check. section 8.2

Connectors can be used in two practical ways:

  • Toggle the web connector in Cohere’s interface to compare answers to factual questions with web access on or off. section 8.2.1
  • Pass a list of connectors to Cohere’s Python chat call; the example uses the web-search connector. section 8.2.2

Check an answer against web results

Ask where Steve Jobs was born. The response includes an answer, search queries, retrieved snippets, and URLs, so you can check whether the sources support the answer. section 8.2.2

Listing 8.2 Answering questions using Cohere’s Python library
import argparse
import cohere

if __name__ == '__main__':
    
    parser = argparse.ArgumentParser()
    parser.add_argument('ai_key', type=str, help='Cohere access key')
    parser.add_argument('question', type=str, help='Answer this question')
    args = parser.parse_args()
    
    client = cohere.Client(args.ai_key)  #1
     #2
    prompt = f'Answer this question: {args.question}'
    result = client.chat(prompt, connectors=[{'id': 'web-search'}])
     #3
    print(f'Answer: result.text')
    print(f'Web searches: result.search_results')
    print(f'Web results: result.documents')

See a Python example that passes the web-search connector and prints the answer and retrieved sources. section 8.2.2

How Data Analysis with LLMs covers it

How deep it goes
Explains interface toggles, Python connector lists, and returned sources, but not connector internals.
Examples
Uses web search for factual questions and a Python example asking where Steve Jobs was born.
What it assumes
Uses a Cohere account for the interface or an API access key for the Python example.
What you can do after
Apply it via Cohere’s interface or Python chat call, then inspect retrieved sources to check an answer.
How it connects
Links connectors to grounding, hallucinations, and retrieval-augmented generation.

Also explained in

Compare how 7 books explain connector →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.