Package: tychos
Tychos Python LibraryThe Tychos Python library provides convenient access to the Tychos API from
applications written in the Python language. The Tychos API allows you to query live, hosted vector datasets in your LLM application without needing to manage your own vector database / embedding pipelines.To see the Tychos API in action, you can test out ourPubMed Demo App.InstallationYou don't need this source code unless you want to modify the package. If you just
want to use the package, just run:pipinstalltychosInstall from source with:pythonsetup.pyinstallRequirementsPython 2.7+ or Python 3.6+RequestsUsageThe library needs to be configured with your account's secret key which is
available via theTychos Website. Either set the TYCHOS_API_KEY environment variable before using the library:importtychosexportTYCHOS_API_KEY='sk_a9adj...'Or initialize the VectorDataStore using an API key:importtychosdata_store=tychos.VectorDataStore(api_key="sk_a9adj...")Query live vector datasets# initialize data storedata_store=tychos.VectorDataStore()# list available datasetsdatasets=data_store.list()# get name of the first dataset's idprint(datasets['data'][0]['name'])# query a single dataset from the data store objectquery_results=data_store.query(name="pub-med-abstracts",# dataset index can be a string or an arrayquery_string="What is the latest research on molecular peptides",# search stringlimit=5,# number of results)# query multiple datasets and return the global top resultsquery_results=data_store.query(name=["arxiv-abstracts","pub-med-abstracts"],# dataset index can be a string or an arrayquery_string="What is the latest research on molecular peptides",# search stringlimit=5,# number of results (across all datasets queried))# print the metadata associated with the first resultprint(query_results[0]['payload'])Filter queries on metadata fieldsYou can filter queries of individual datasets by passing a query_filter dict that specifies the field, operator and condition to apply. The following operators are currently available:OperatorChecks if the field value is...$eqequal tothe specified value$nenot equal tothe specified value$inwithinthe specified array$ninnot withinthe specified arrayExample queries using filters:# filter PubMed query on articles within a particular journalquery_results=data_store.query(name="pub-med-abstracts",query_string="What is the latest research on molecular peptides",query_filter={"Journal":{"$eq":"New England Journal of Medicine"}}limit=5,)# filter ArXiv query on papers written by LeCun, Hinton and Bengioquery_results=data_store.query(name="arxiv-abstracts",query_string="What is the latest research on molecular peptides",query_filter={"authors":{"$in":["LeCun","Hinton","Bengio"]}}limit=5,)See the datasets table below for the metadata fields available on each. We are working on adding additional query operators and fields (e.g., date ranges). As we expand datasets, we also plan to make available a set of general filters (e.g., date, author, type) for queries across multiple datasets.Command-line interfaceThis library additionally provides a tychos command-line utility to make it easy to interact with the API from your terminal. Run tychos-cli -h for usage.tychos-cliquery--api-key<YOUR-API-KEY>--namepub-med-abstracts--query-string<"Your query string">--limit5Datasets availableWe currently support a range of pre-print, research, and patent datasets and have plans to add additional sources in the coming weeks. If there's a particular dataset you'd like to incorporate into your LLM application, feel free toreach outor raise a GitHub issue.Vector datasetsDatasetNameSizeSyncsMetadata FieldsPubMed (source)pub-med-abstracts35.5M documentsDaily at 07:00 UTCAll fields:PMID, PMCID, Title, Abstract, Authors, Abstract_URL, PMC_URL, Journal, Publication DateQuery filterable:Authors, JournalUS Patents (source)us-patents6.9M patentsQuarterly at 07:00 UTC (1st of Quarter)All fields:patent_id, title, summary, claims, patent_url, inventors, classification, type, assignees, location, date_filed, date_granted, termQuery filterable:coming soon!ArXiv (source)arxiv-abstracts2.3M documentsWeekly at 07:00 UTC (Sunday)All fields:id, doi, paper_title, abstract, authors, categories, abstract_url, full_text_url, journal, pub_date, update_dateQuery filterable:authors, categories, journalBioRxiv (source)biorxiv285.5K documentsMonthly at 07:00 UTC (Sunday)All fields:doi, title, abstract, authors, category, jatsxml, author_corresponding, author_corresponding_institution, date, date_timestamp, license, published, typeQuery filterable:authors, category, date_timestampMedRxiv (source)medrxiv58.2K documentsMonthly at 07:00 UTC (Sunday)All fields:doi, title, abstract, authors, category, jatsxml, author_corresponding, author_corresponding_institution, date, date_timestamp, license, published, typeQuery filterable:authors, category, date_timestampFeedback and supportIf you'd like to provide feedback, run into issues, or need support using embeddings, feel free toreach outor raise a GitHub issue.