import chromadb import os import gradio as gr client = chromadb.PersistentClient(path="./db1") collection = client.get_or_create_collection("test") def query_episodes(query, n_results): output = """ Podcast Episodes
""" q = collection.query( query_texts=[query], n_results=n_results) for idx in range(n_results): output += """
Episode: {}
Paragraph: {}
{}
""".format(q["metadatas"][0][idx]["title"], q["metadatas"][0][idx]["paragraph"], q["documents"][0][idx]) output += """
""" return output if __name__ == "__main__": description = "With a podcast like the Huberman Lab podcast it can sometimes be overwhelming trying to find the exact content you are looking for. This tool is meant to start you in the right direction depending on the topic you are searching for." article = """For any input or suggestions hit me up on [twitter](https://twitter.com/intent/user?screen_name=_isteph_)!""" examples = [ ["Stretching routine", 3], ["Cold exposure", 5], ["Handling ADHD", 2], ["Eating healthy", 8] ] interface = gr.Interface( fn=query_episodes, inputs=[gr.Textbox(label="Search Query",show_label=True), gr.Slider(value=3, minimum=1, maximum=10, step=1, label="Number of Results")], outputs=[gr.HTML(label="Consolidated Query Results", show_label=True)], title="Huberman Lab Podcast Topic Search", examples=examples, description=description, article=article ) interface.launch()