{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Ingesting GitHub data, please input the following information:\n", "Ingesting GitHub data...\n", "Ingesting files from the repository...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 75/75 [00:43<00:00, 1.73it/s]\n" ] } ], "source": [ "from cura import github_ingestion\n", "from cura import vector_store\n", "\n", "print(\"Ingesting GitHub data, please input the following information:\")\n", "url = \"MarkCodering/mindify-website\"\n", "access_token = input(\"GitHub Access Token: \")\n", "\n", "print(\"Ingesting GitHub data...\")\n", "github_repo_data = github_ingestion.ingest_github_repo(url, access_token)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Storing GitHub data in ChromaDB...\n" ] } ], "source": [ "collection_name = url.replace(\"/\", \"_\")\n", "collection = vector_store.set_up_chromadb(collection_name)\n", "ids = []\n", "for i in range(len(github_repo_data[0])):\n", " ids.append(str(i))\n", " \n", "print(\"Storing GitHub data in ChromaDB...\")\n", "collection.add(ids=ids, documents=github_repo_data[0])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Querying the data from the vector store...\n", "---\n", "// @ts-ignore\n", "const features = [\n", " {\n", " title: \"Learn AI Technologies\",\n", " description:\n", " \"We provide online and in-person training to help you learn the latest generative AI technologies.\",\n", " },\n", " {\n", " title: \"Deploy AI Solutions\",\n", " description:\n", " \"We provide a platform for developers to deploy generative AI solutions in their projects.\",\n", " },\n", " {\n", " title: \"Fast Prototyping and Concept Validation\",\n", " description:\n", " \"We help you quickly prototype and validate your AI concepts to bring them to market faster.\",\n", " },\n", "];\n", "---\n", "\n", "
\n", "

\n", " About Mindify AI\n", "

\n", "

\n", " Mindify is an AI solution company that provides a platform for developers to\n", " learn and deploy generative AI solutions. We deliver online and in-person\n", " training to help you learn the latest AI technologies and deploy them in\n", " your projects. Our mission is to help you bring your AI concepts to market\n", " faster and deliver value to your customers.\n", "

\n", "
\n", "\n", "
\n", " {\n", " features.map((item) => (\n", "
\n", "
\n", "

{item.title}

{\" \"}\n", "

{item.description}

\n", "
\n", "
\n", " ))\n", " }\n", "
\n", "\n" ] } ], "source": [ "# Query the data from the vector store\n", "print(\"Querying the data from the vector store...\")\n", "prompt = \"What is Mindify AI?\"\n", "results = collection.query(\n", " query_texts=[prompt], # Chroma will embed this for you\n", " n_results=2 # how many results to return\n", ")\n", "print(results[\"documents\"][0][0])" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Asking OpenAI the following question: You are a smart and helpful AI programmer and here is the repository I am working on: MarkCodering/mindify-websiteAnd, I wonder if you can help me with the following question with the following question: What is Mindify AI?based on the data in the repository which is available here: ---\n", "// @ts-ignore\n", "const features = [\n", " {\n", " title: \"Learn AI Technologies\",\n", " description:\n", " \"We provide online and in-person training to help you learn the latest generative AI technologies.\",\n", " },\n", " {\n", " title: \"Deploy AI Solutions\",\n", " description:\n", " \"We provide a platform for developers to deploy generative AI solutions in their projects.\",\n", " },\n", " {\n", " title: \"Fast Prototyping and Concept Validation\",\n", " description:\n", " \"We help you quickly prototype and validate your AI concepts to bring them to market faster.\",\n", " },\n", "];\n", "---\n", "\n", "
\n", "

\n", " About Mindify AI\n", "

\n", "

\n", " Mindify is an AI solution company that provides a platform for developers to\n", " learn and deploy generative AI solutions. We deliver online and in-person\n", " training to help you learn the latest AI technologies and deploy them in\n", " your projects. Our mission is to help you bring your AI concepts to market\n", " faster and deliver value to your customers.\n", "

\n", "
\n", "\n", "
\n", " {\n", " features.map((item) => (\n", "
\n", "
\n", "

{item.title}

{\" \"}\n", "

{item.description}

\n", "
\n", "
\n", " ))\n", " }\n", "
\n", "\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n", "To disable this warning, you can either:\n", "\t- Avoid using `tokenizers` before the fork if possible\n", "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n" ] } ], "source": [ "from cura import openai_chat\n", "\n", "question = (\n", " \"You are a smart and helpful AI programmer and here is the repository I am working on: {}\".format(\n", " url\n", " )\n", " + \"And, I wonder if you can help me with the following question with the following question: {}\".format(\n", " prompt\n", " )\n", " + \"based on the data in the repository which is available here: {}\".format(\n", " results[\"documents\"][0][0]\n", " )\n", ")\n", "print(\"Asking OpenAI the following question: {}\".format(question))\n", "\n", "answer = openai_chat.ask_question(question)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Based on the provided data from the repository, Mindify AI is an AI solution company that focuses on providing a platform for developers to learn and deploy generative AI solutions. Here are the key aspects of Mindify AI:\n", "\n", "1. **Learning AI Technologies**: Mindify AI offers both online and in-person training to help individuals and developers learn the latest generative AI technologies.\n", "\n", "2. **Deploying AI Solutions**: The platform allows developers to deploy generative AI solutions in their projects, facilitating the integration of advanced AI capabilities.\n", "\n", "3. **Fast Prototyping and Concept Validation**: Mindify AI assists in quickly prototyping and validating AI concepts, enabling faster time-to-market for AI-driven products and solutions.\n", "\n", "The mission of Mindify AI is to help developers and businesses bring their AI concepts to market more quickly and deliver value to their customers through advanced AI technologies.\n", "\n", "Here is a summary of the features provided by Mindify AI:\n", "- **Learn AI Technologies**: Training programs to learn the latest generative AI technologies.\n", "- **Deploy AI Solutions**: A platform for deploying generative AI solutions in projects.\n", "- **Fast Prototyping and Concept Validation**: Support for rapid prototyping and validation of AI concepts.\n", "\n", "Overall, Mindify AI aims to empower developers and businesses with the knowledge and tools needed to leverage generative AI effectively.\n" ] } ], "source": [ "print(answer.content)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/mark/Documents/Mindify/CURA-alpha/.venv/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7860\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import gradio as gr\n", "\n", "def echo(question):\n", " # Query the collection with the provided question\n", " results = collection.query(\n", " query_texts=[question], # Chroma will embed this for you\n", " n_results=1 # Number of results to return\n", " )\n", " \n", " # Append the retrieved document to the question\n", " question = question + results[\"documents\"][0][0]\n", " \n", " # Use OpenAI's chat to ask the modified question\n", " answer = openai_chat.ask_question(question)\n", " \n", " # Return the content of the answer\n", " return answer.content\n", "\n", "# Define the Gradio interface\n", "iface = gr.Interface(\n", " fn=echo,\n", " inputs=gr.Textbox(lines=2, placeholder=\"Enter your question here...\"),\n", " outputs=gr.Code(label=\"Answer\", language=\"markdown\"),\n", ")\n", "\n", "# Launch the Gradio interface\n", "iface.launch()\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.6" } }, "nbformat": 4, "nbformat_minor": 2 }