'result': 'created',       'status': 201}]}# Note text indexes retain the ability to use add_texts despite different field names in documents# this is because the page_content_builder callback lets you handle these document fields as requireddef get_content(res):    """Helper to format Marqo's documents into text to be used as page_content"""    if "text" in res:        return res["text"]    return res["Description"]docsearch = Marqo(client, index_name, page_content_builder=get_content)docsearch.add_texts(["This is a document that is about elephants"])    ['9986cc72-adcd-4080-9d74-265c173a9ec3']query = "modern communications devices"doc_results = docsearch.similarity_search(query)print(doc_results[0].page_content)    A smartphone is a portable computer device that combines mobile telephone functions and computing functions into one unit.query = "elephants"doc_results = docsearch.similarity_search(query, page_content_builder=get_content)print(doc_results[0].page_content)    This is a document that is about elephantsWeighted Queries‚ÄãWe also expose marqos weighted queries which are a powerful way to compose complex semantic searches.query = {"communications devices": 1.0}doc_results = docsearch.similarity_search(query)print(doc_results[0].page_content)    A smartphone is a portable computer device that combines mobile telephone functions and computing functions into one unit.query = {"communications devices": 1.0, "technology post 2000": -1.0}doc_results = docsearch.similarity_search(query)print(doc_results[0].page_content)    A telephone is a telecommunications device that permits two or more users toconduct a conversation when they are too far apart to be easily heard directly.Question Answering with SourcesThis section shows how to use Marqo as part of a RetrievalQAWithSourcesChain. Marqo will perform the searches for information in the sources.from langchain.chains import RetrievalQAWithSourcesChainfrom langchain.llms import OpenAIimport osimport
This notebook shows how to use functionality related to the Marqo vectorstore.
This notebook shows how to use functionality related to the Marqo vectorstore. ->: 'result': 'created',       'status': 201}]}# Note text indexes retain the ability to use add_texts despite different field names in documents# this is because the page_content_builder callback lets you handle these document fields as requireddef get_content(res):    """Helper to format Marqo's documents into text to be used as page_content"""    if "text" in res:        return res["text"]    return res["Description"]docsearch = Marqo(client, index_name, page_content_builder=get_content)docsearch.add_texts(["This is a document that is about elephants"])    ['9986cc72-adcd-4080-9d74-265c173a9ec3']query = "modern communications devices"doc_results = docsearch.similarity_search(query)print(doc_results[0].page_content)    A smartphone is a portable computer device that combines mobile telephone functions and computing functions into one unit.query = "elephants"doc_results = docsearch.similarity_search(query, page_content_builder=get_content)print(doc_results[0].page_content)    This is a document that is about elephantsWeighted Queries‚ÄãWe also expose marqos weighted queries which are a powerful way to compose complex semantic searches.query = {"communications devices": 1.0}doc_results = docsearch.similarity_search(query)print(doc_results[0].page_content)    A smartphone is a portable computer device that combines mobile telephone functions and computing functions into one unit.query = {"communications devices": 1.0, "technology post 2000": -1.0}doc_results = docsearch.similarity_search(query)print(doc_results[0].page_content)    A telephone is a telecommunications device that permits two or more users toconduct a conversation when they are too far apart to be easily heard directly.Question Answering with SourcesThis section shows how to use Marqo as part of a RetrievalQAWithSourcesChain. Marqo will perform the searches for information in the sources.from langchain.chains import RetrievalQAWithSourcesChainfrom langchain.llms import OpenAIimport osimport