Represents a chat session that can handle user interactions.
Methods
Ask a question in the chat.
Parameters:
formatter
InlineAttributionFormatter | None
Whether to stream the response.
source_filter
list[Source] | list[str] | None = None
Provide a list of trusted sources to ground the response. Check Find Sources to learn how to curate a list of trusted sources.You can either provide the list of Source Objects directly from the response of the method find_sources or the list of source IDs.
# Import classes from the bigdata-client Python SDK
from bigdata_client import Bigdata
# Log in to Bigdata
bigdata = Bigdata("YOUR_USERNAME", "YOUR_PASSWORD")
# Create a new chat
chat = bigdata.chat.new("Companies in quantum computing")
# Get source by name
sources = bigdata.knowledge_graph.find_sources("Bloomberg News")
print(sources)
# Ask a question with source filtering, so the response will contain data from your specified trusted sources.
response = chat.ask("Companies involved in quantum computing", source_filter=sources, streaming=True)
print(f"\nQuestion:\n - {response.question}")
print(f"\nAnswer:")
for streamingChatInteraction in response:
print(streamingChatInteraction, end="")
print(f"\nDocuments used to craft the Chat response:\n")
for source in response.sources:
print(f"\tDocument ID: {source.id}")
print(f"\tHeadline: {source.headline}")
print(f"\tURL: {source.url}\n")
The output of the above script will contain:
[Source(id='208421', name='Bloomberg News', volume=None, description='Bloomberg News is an international news agency headquartered in New York,
United States and a division of Bloomberg L.P.', entity_type='SRCE', publication_type='News', language='English', country='US', source_rank='1',
retention=<SourceRetentionPeriod.FIVE_YEARS: '5Y'>, provider_id='MRVR', url='http://www.bloomberg.com')]
- Chat question and answer:
Question:
- Companies involved in quantum computing research
Answer:
Several companies are actively involved in quantum computing research and development:
* **Alphabet Inc.'s Google** is designing quantum computing processors and has developed a quantum chip called Willow. Google is also an investor in quantum startups like QuEra. `:ref[0]` `:ref[0]` `:ref[2]` `:ref[3]`
* **Nvidia Corp.** is collaborating with Google's Quantum AI division, using its Eos supercomputer to accelerate the design of quantum components. `:ref[0]` `:ref[0]`
* **Riverlane**, a startup based in Cambridge, England, and Boston, designs chips to correct errors in quantum computation. `:ref[1]` `:ref[1]`
...
..
.
- And the list of documents used to ground the response, where we see that all of them are from the specified source.
Document ID: 5BF7D46754A1E8B4BFC1D0B10F6F9236
Headline: Nvidia Is Helping Google Design Quantum Computing Processors
URL: https://news.bloomberglaw.com/tech-and-telecom-law/nvidia-is-helping-google-design-quantum-computing-processors
Document ID: F724276362346324C10D6FF0185BF5A6
Headline: Quantum Computing Startup Riverlane Raises $75 Million
URL: None
Document ID: 91C73FC9040D21CCD8BB9571950B5A0D
Headline: Is Quantum Computing Finally Becoming a Reality?: Editorial
URL: https://news.bloomberglaw.com/ip-law/is-quantum-computing-finally-becoming-a-reality-editorial
...
..
.
Return type:
ChatInteraction | StreamingChatInteraction
delete()
Delete the chat.
Fields
Unique identifier for the chat.
Identifier of the user who created the chat.
Datetime when the chat was created.
Datetime when the chat was last updated.