.search() enables you to uncover the most pertinent context by performing a semantic search across your data sources based on a given query. Refer to the function signature below:
Refer to the following example on how to use the search api:
Code example
Copy
Ask AI
from embedchain import App# Initialize appapp = App()# Add data sourceapp.add("https://www.forbes.com/profile/elon-musk")# Get relevant context using semantic searchcontext = app.search("What is the net worth of Elon?", num_documents=2)print(context)# Context:# [# {# 'context': 'Elon Musk PROFILEElon MuskCEO, Tesla$221.9BReal Time Net Worth ...',# 'metadata': {# 'source': 'https://www.forbes.com/profile/elon-musk',# 'document_id': 'some_document_id',# 'score': 0.404,# }# },# {# 'context': 'company, which is now called X.Wealth HistoryHOVER TO REVEAL NET WORTH ...',# 'metadata': {# 'source': 'https://www.forbes.com/profile/elon-musk',# 'document_id': 'some_document_id',# 'score': 0.435,# }# }# ]