### Local Development Setup Source: https://github.com/lastmile-ai/aiconfig/blob/main/gradio-notebook/README-dev.md Installs project dependencies and starts the development server for the Gradio Workbook frontend. ```bash cd gradioworkbook pip install -r requirements.txt cd frontend && yarn && yarn dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/aiconfig-docs/README.md Run this command to install all project dependencies. ```bash yarn ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/src/aiconfig/eval/batch_eval_examples/travel/travel_eval.ipynb Output from the package manager showing the installation of required utilities and libraries. ```bash Collecting lastmile-utils Using cached lastmile_utils-0.0.21-py3-none-any.whl.metadata (901 bytes) Collecting black==23.11.0 (from lastmile-utils) Using cached black-23.11.0-cp310-cp310-macosx_11_0_arm64.whl.metadata (66 kB) Collecting chardet==5.2.0 (from lastmile-utils) Using cached chardet-5.2.0-py3-none-any.whl.metadata (3.4 kB) Collecting flake8==6.1.0 (from lastmile-utils) Using cached flake8-6.1.0-py2.py3-none-any.whl.metadata (3.8 kB) Collecting isort==5.12.0 (from lastmile-utils) Using cached isort-5.12.0-py3-none-any.whl (91 kB) Collecting jsoncomment==0.4.2 (from lastmile-utils) Using cached jsoncomment-0.4.2-py3-none-any.whl (6.8 kB) Collecting pandas==2.1.2 (from lastmile-utils) Using cached pandas-2.1.2-cp310-cp310-macosx_11_0_arm64.whl.metadata (18 kB) Collecting pydantic==2.4.2 (from lastmile-utils) Using cached pydantic-2.4.2-py3-none-any.whl.metadata (158 kB) Collecting pylint==3.0.2 (from lastmile-utils) Using cached pylint-3.0.2-py3-none-any.whl.metadata (12 kB) Collecting pyright==1.1.335 (from lastmile-utils) Using cached pyright-1.1.335-py3-none-any.whl.metadata (5.7 kB) Collecting pytest==7.4.3 (from lastmile-utils) Using cached pytest-7.4.3-py3-none-any.whl.metadata (7.9 kB) Collecting python-dotenv==1.0.0 (from lastmile-utils) Using cached python_dotenv-1.0.0-py3-none-any.whl (19 kB) Collecting result==0.16.0 (from lastmile-utils) Using cached result-0.16.0-py3-none-any.whl.metadata (857 bytes) Collecting autoflake==2.2.1 (from lastmile-utils) Using cached autoflake-2.2.1-py3-none-any.whl.metadata (7.3 kB) Collecting pyflakes>=3.0.0 (from autoflake==2.2.1->lastmile-utils) Using cached pyflakes-3.2.0-py2.py3-none-any.whl.metadata (3.5 kB) Collecting tomli>=2.0.1 (from autoflake==2.2.1->lastmile-utils) Using cached tomli-2.0.1-py3-none-any.whl (12 kB) Collecting click>=8.0.0 (from black==23.11.0->lastmile-utils) Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB) Collecting mypy-extensions>=0.4.3 (from black==23.11.0->lastmile-utils) Using cached mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB) Collecting packaging>=22.0 (from black==23.11.0->lastmile-utils) Using cached packaging-23.2-py3-none-any.whl.metadata (3.2 kB) Collecting pathspec>=0.9.0 (from black==23.11.0->lastmile-utils) Using cached pathspec-0.12.1-py3-none-any.whl.metadata (21 kB) Collecting platformdirs>=2 (from black==23.11.0->lastmile-utils) Using cached platformdirs-4.1.0-py3-none-any.whl.metadata (11 kB) Collecting typing-extensions>=4.0.1 (from black==23.11.0->lastmile-utils) Using cached typing_extensions-4.9.0-py3-none-any.whl.metadata (3.0 kB) Collecting mccabe<0.8.0,>=0.7.0 (from flake8==6.1.0->lastmile-utils) Using cached mccabe-0.7.0-py2.py3-none-any.whl (7.3 kB) Collecting pycodestyle<2.12.0,>=2.11.0 (from flake8==6.1.0->lastmile-utils) Using cached pycodestyle-2.11.1-py2.py3-none-any.whl.metadata (4.5 kB) Collecting pyflakes>=3.0.0 (from autoflake==2.2.1->lastmile-utils) Using cached pyflakes-3.1.0-py2.py3-none-any.whl.metadata (3.5 kB) Collecting json-spec (from jsoncomment==0.4.2->lastmile-utils) Using cached json_spec-0.11.0-py3-none-any.whl (41 kB) Collecting numpy<2,>=1.22.4 (from pandas==2.1.2->lastmile-utils) Using cached numpy-1.26.3-cp310-cp310-macosx_11_0_arm64.whl.metadata (61 kB) Collecting python-dateutil>=2.8.2 (from pandas==2.1.2->lastmile-utils) Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB) Collecting pytz>=2020.1 (from pandas==2.1.2->lastmile-utils) Using cached pytz-2023.3.post1-py2.py3-none-any.whl.metadata (22 kB) Collecting tzdata>=2022.1 (from pandas==2.1.2->lastmile-utils) Using cached tzdata-2023.4-py2.py3-none-any.whl.metadata (1.4 kB) Collecting annotated-types>=0.4.0 (from pydantic==2.4.2->lastmile-utils) Using cached annotated_types-0.6.0-py3-none-any.whl.metadata (12 kB) Collecting pydantic-core==2.10.1 (from pydantic==2.4.2->lastmile-utils) Using cached pydantic_core-2.10.1-cp310-cp310-macosx_11_0_arm64.whl.metadata (6.5 kB) Collecting astroid<=3.1.0-dev0,>=3.0.1 (from pylint==3.0.2->lastmile-utils) Using cached astroid-3.0.2-py3-none-any.whl.metadata (4.5 kB) Collecting tomlkit>=0.10.1 (from pylint==3.0.2->lastmile-utils) Using cached tomlkit-0.12.3-py3-none-any.whl.metadata (2.7 kB) Collecting dill>=0.2 (from pylint==3.0.2->lastmile-utils) Using cached dill-0.3.7-py3-none-any.whl.metadata (9.9 kB) Collecting nodeenv>=1.6.0 (from pyright==1.1.335->lastmile-utils) Using cached nodeenv-1.8.0-py2.py3-none-any.whl.metadata (21 kB) Collecting iniconfig (from pytest==7.4.3->lastmile-utils) Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB) ``` -------------------------------- ### Install Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Function-Calling-OpenAI/typescript/README.md Navigate to the cookbook directory and install project dependencies using yarn. ```bash cd aiconfig/cookbooks/Function-Calling-OpenAI/typescript && yarn ``` -------------------------------- ### Install Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/RAG-with-ChromaDB/RAG_with_AIConfig.ipynb Install the required packages for AIConfig and ChromaDB. ```python !pip install python-aiconfig !pip install chromadb ``` -------------------------------- ### Install and Configure Environment Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Create-AIConfig-Programmatically/create_aiconfig_programmatically.ipynb Install the required package and load the OpenAI API key from a .env file. ```python !pip install python-aiconfig # Create ~/.env file with this line: export OPENAI_API_KEY= # You can get your key from https://platform.openai.com/api-keys import openai import dotenv import os dotenv.load_dotenv() openai.api_key = os.getenv("OPENAI_API_KEY") ``` -------------------------------- ### Install and Configure Environment Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/demo/aiconfig_demo.ipynb Installs the required package and initializes the OpenAI API key from environment variables. ```python #1 install the package %pip install python-aiconfig from dotenv import load_dotenv import openai import os load_dotenv() openai.api_key = os.getenv("OPENAI_API_KEY") ``` -------------------------------- ### Install Lastmile Utilities and List Packages Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/src/aiconfig/eval/examples/travel/travel_eval.ipynb Installs the lastmile-utils package and verifies its installation by listing installed packages. Ensure the installed version matches or exceeds the one specified in aiconfig/python/requirements.txt. ```python # Package installs & environment setup !pip3 install lastmile-utils --force # If you see errors, no worries you can generally ignore. Just make sure that the # following output matches with the version specified in the # aiconfig/python/requirements.txt file (or is a higher version) !pip3 list | grep lastmile-utils ``` -------------------------------- ### Install Yarn Source: https://github.com/lastmile-ai/aiconfig/blob/main/gradio-notebook/README-dev.md Installs yarn globally using npm. Ensure Node.js is installed first. ```bash sudo npm install --global yarn ``` -------------------------------- ### RAG Query Output Example Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/RAG-with-Model-Graded-Eval-v2/rag_demo.ipynb Example output showing the initial query being processed. This indicates the system is starting the retrieval process. ```text Output:\nQuerying for: What was the price of flour sold in Boston? ``` -------------------------------- ### Install Published Extension Source: https://github.com/lastmile-ai/aiconfig/blob/main/extensions/HuggingFace/python/README.md Standard installation command for the published Hugging Face extension. ```bash pip3 install aiconfig-extension-hugging-face ``` -------------------------------- ### Install and Link Extension for Local Development Source: https://github.com/lastmile-ai/aiconfig/blob/main/extensions/HuggingFace/python/README.md Commands to build and install the extension from source for local development environments. ```bash pip3 install build && cd python && python -m build && pip3 install dist/*.whl ``` ```bash pip3 install -e . ``` ```bash pip3 uninstall aiconfig-extension-hugging-face && pip3 install aiconfig-extension-hugging-face ``` -------------------------------- ### Start Local Development Server Source: https://github.com/lastmile-ai/aiconfig/blob/main/aiconfig-docs/README.md Starts a local development server that reflects changes live without requiring a restart. ```bash yarn start ``` -------------------------------- ### Install and Configure Environment Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Getting-Started/getting_started.ipynb Installs the python-aiconfig package and initializes the OpenAI API key from a .env file. ```python !pip install python-aiconfig # Create .env file at aiconfig/.env containing the following line: # OPENAI_API_KEY= # You can get your key from https://platform.openai.com/api-keys import openai import dotenv import os dotenv.load_dotenv() openai.api_key = os.getenv("OPENAI_API_KEY") ``` -------------------------------- ### Install AIConfig (Python/Node.js) Source: https://context7.com/lastmile-ai/aiconfig/llms.txt Install the AIConfig framework using pip for Python or npm for Node.js. ```bash # Python installation pip install python-aiconfig ``` ```bash # Node.js installation npm install aiconfig ``` -------------------------------- ### Install and Configure AIConfig Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Function-Calling-OpenAI/python/Function_Calling_with_OpenAI.ipynb Install the required package and initialize the OpenAI API key from an environment file. ```python # Install AIConfig package !pip3 install python-aiconfig # Create .env file at aiconfig/.env containing the following line: # OPENAI_API_KEY= # You can get your key from https://platform.openai.com/api-keys import openai import dotenv import os dotenv.load_dotenv() openai.api_key = os.getenv("OPENAI_API_KEY") ``` -------------------------------- ### Execute Llama example script Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/llama/typescript/README.md Run the example TypeScript file using ts-node. ```bash npx ts-node ask-llama.ts ``` -------------------------------- ### Install Node.js AIConfig Source: https://github.com/lastmile-ai/aiconfig/blob/main/README.md Install the Node.js package for AIConfig using npm or yarn. ```bash npm install aiconfig ``` ```bash yarn add aiconfig ``` -------------------------------- ### Install AIConfig with npm Source: https://github.com/lastmile-ai/aiconfig/blob/main/aiconfig-docs/docs/getting-started.md Use this command to install the Node.js AIConfig package using npm. ```bash npm install aiconfig ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/RAG-with-Model-Graded-Eval-v2/rag_demo.ipynb Use these commands to install the required python-aiconfig and chromadb packages, and load environment variables. ```python %pip install python-aiconfig==1.1.27 %pip install chromadb import dotenv dotenv.load_dotenv() ``` -------------------------------- ### Install Groq Extension for AIConfig Source: https://github.com/lastmile-ai/aiconfig/blob/main/extensions/Groq/README.md Install the Groq extension using pip. This enables AIConfig to interact with Groq models. ```bash pip3 install aiconfig-extension-groq ``` -------------------------------- ### Install AIConfig and Set Up OpenAI API Key Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/OpenAI-ChatCompletion-AIConfigWrapper/openai_wrapper.ipynb Install the AIConfig package and configure your OpenAI API key using a .env file. Ensure you have the necessary environment variables set. ```python # Install AIConfig package !pip3 install python-aiconfig # Create ~/.env file with this line: export OPENAI_API_KEY= # You can get your key from https://platform.openai.com/api-keys import openai import dotenv import os dotenv.load_dotenv() openai.api_key = os.getenv("OPENAI_API_KEY") ``` -------------------------------- ### Example RAG Queries Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/RAG-with-Model-Graded-Eval-v2/rag_demo.ipynb A list of example queries to be used with the RAG system. Uncomment specific queries to test different scenarios. ```python queries = [\n "What was the price of flour sold in Boston?",\n "When and why did the british Blockade happen?",\n "What happened during the burning of the Assembly houses in Canada in 1812?",\n \n # "What are some of the most important events in US history?" \n # "What happ the American declaration of war against England in 1812",\n # "What happened during the burning of the Assembly houses in Canada in 1812?",\n "Elaborate on Napoleon",\n # "The close alliance between Great Britain and Russia",\n # "The loss of the Bank of the United States",\n # "The loss of the Massachusetts and Connecticut banks",\n # "The Battle of the Thames in 1813",\n # "The campaigns of General Dearborn and General Wilkinson",\n # "The blockades and conflicts with British ships, including the battles of Chesapeake and Argus",\n # "Privateering by the US during the war",\n # "The last embargo implemented by the US in an attempt to obtain concessions from England",\n # "The involvement of Russia and England in the war",\n # "The financial challenges faced by the US Treasury",\n # "The changing attitudes and perceptions of the British press towards the US during the war",\n # "The opposition to the war by Federalists, particularly in Massachusetts.",\n] ``` -------------------------------- ### Initialize ChromaDB and Query Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/RAG-with-ChromaDB/RAG_with_AIConfig.ipynb Create a collection of curriculum documents and perform a similarity search. ```python # import ChromaDB and set up the Chroma client import chromadb chroma_client = chromadb.Client() # Create a collection of curriculums collection = chroma_client.create_collection(name="curriculum") # Add documents for a math curriculum, physics curriculum, and a chemistry curriculum collection.add( documents=["math", "physics", "chemistry"], metadatas=[ { "source": """Subject: Mathematics Course 1: Number Sense and Operations - Place value - Number patterns and relationships - Addition, subtraction, multiplication, and division - Problem-solving techniques Course 2: Algebra - Variables and expressions - Equations and inequalities - Patterns and functions""" }, { "source": """Subject: Physics Course 1: Introduction to Physics - Scientific method and inquiry skills - Measurement and scientific notation - Physical quantities and units Course 2: Motion and Forces - Position, distance, and displacement - Speed, - velocity, and acceleration - Newton's laws of motion""" }, { "source": """Subject: Chemistry Course 1: Introduction to Chemistry - Matter and its properties - Atoms, elements, and compounds - Chemical symbols and formulas""" } ], ids=["id1", "id2", "id3"] ) # Query the vector database for the closest context to the student question context = collection.query( query_texts=["What is the sum of the first 103 numbers"], n_results=1 ) print(context) ``` -------------------------------- ### Get Output Text by Prompt Name (TypeScript) Source: https://context7.com/lastmile-ai/aiconfig/llms.txt Retrieve the text content of a prompt's output using the prompt name. This example also demonstrates how to get the latest output object associated with a specific prompt. ```typescript import { AIConfigRuntime } from "aiconfig"; async function getOutput() { const config = AIConfigRuntime.load("travel.aiconfig.json"); await config.run("get_activities"); // Get output text by prompt name const text = config.getOutputText("get_activities"); console.log(`Activities:\n${text}`); // Get latest output const latestOutput = config.getLatestOutput("get_activities"); console.log("Latest output:", latestOutput); } getOutput(); ``` -------------------------------- ### Get Output Text by Prompt Name (Python) Source: https://context7.com/lastmile-ai/aiconfig/llms.txt Retrieve the text content of a prompt's output after running inference. This example shows how to get the output text using the prompt name and also by specifying a particular output object. ```python from aiconfig import AIConfigRuntime, InferenceOptions import asyncio config = AIConfigRuntime.load("travel.aiconfig.json") async def get_output(): await config.run("get_activities", options=InferenceOptions(stream=True)) # Get output text by prompt name text = config.get_output_text("get_activities") print(f"Activities:\n{text}") # Get output text with specific output object prompt = config.get_prompt("get_activities") if prompt.outputs: latest_output = prompt.outputs[-1] text = config.get_output_text(prompt, latest_output) print(f"Latest output:\n{text}") asyncio.run(get_output()) ``` -------------------------------- ### Install and Verify AIConfig Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/src/aiconfig/eval/batch_eval_examples/travel/travel_eval.ipynb Installs the required lastmile-utils package and verifies the installed version. ```python !pip3 install lastmile-utils --force !pip3 list | grep lastmile-utils ``` -------------------------------- ### Initialize and Define Book Recommendation Prompt Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Function-Calling-OpenAI/python/Function_Calling_with_OpenAI.ipynb Initializes AIConfigRuntime and defines a prompt for book recommendations, including OpenAI function definitions for listing, searching, and getting book details. ```python config = AIConfigRuntime.create(name="Book Finder", description="Use OpenAI function calling to help recommend books") model = "gpt-3.5-turbo" data = { "model": model, "messages": [ { "role": "system", "content": "Please use our book database, which you can access using functions to answer the following questions." }, { "role": "user", "content": "I really enjoyed reading {{book}}, could you recommend me a book that is similar and tell me why?" } ], "functions": [ { "name": "list", "description": "list queries books by genre, and returns a list of names of books", "parameters": { "type": "object", "properties": { "genre": { "type": "string", "enum": [ "mystery", "nonfiction", "memoir", "romance", "historical" ] } } } }, { "name": "search", "description": "search queries books by their name and returns a list of book names and their ids", "parameters": { "type": "object", "properties": { "name": { "type": "string" } } } }, { "name": "get", "description": "get returns a book's detailed information based on the id of the book. Note that this does not accept names, and only IDs, which you can get by using search.", "parameters": { "type": "object", "properties": { "id": { "type": "string" } } } } ] } new_prompts = await config.serialize(model, data, prompt_name="recommend_book", params={"book": "To Kill a Mockingbird"}) config.add_prompt(prompt_name="recommend_book", prompt_data=new_prompts[0]) ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/README_dev.md Install the necessary Python packages for development and testing. The `-e` flag installs the package in editable mode, reflecting local changes. ```bash pip install -r requirements.txt ``` ```bash pip install -e . ``` ```bash pip install -r requirements-dev.txt ``` -------------------------------- ### Start AIConfig Editor Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/src/aiconfig/editor/README.md Launch the editor server pointing to a specific configuration file. ```bash aiconfig edit --aiconfig-path=/my/path' ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/src/aiconfig/editor/README.md Install the local python package in editable mode. ```bash pip3 install -e ./python alias aiconfig="python3 -m 'aiconfig.scripts.aiconfig_cli'" ``` -------------------------------- ### Initialize AIConfigRuntime Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Create-AIConfig-Programmatically/create_aiconfig_programmatically.ipynb Create a new AIConfigRuntime instance with a specified name and description. ```python from aiconfig import AIConfigRuntime new_config = AIConfigRuntime.create("create_programmatically_demo", "This is a demo of creating a config programmatically") ``` -------------------------------- ### Install LlamaModelParser Extension Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/llama/python/README.md Install the required AIConfig packages via pip. ```bash pip install python-aiconfig aiconfig-extension-llama ``` -------------------------------- ### Install AIConfig package Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Anyscale/Function_Calling_with_Mixtral.ipynb Install the necessary Python package to use AIConfig. ```python # Install AIConfig package !pip3 install python-aiconfig ``` -------------------------------- ### Install AIConfig CLI Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/src/aiconfig/editor/README.md Install the package and set a shell alias for easier access. ```bash pip3 install python-aiconfig; alias aiconfig="python3 -m 'aiconfig.scripts.aiconfig_cli'" ``` -------------------------------- ### Activate Development Environment Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/src/aiconfig/editor/README.md Switch to the configured development environment. ```bash conda activate my_environment_name ``` -------------------------------- ### CLI Example for RAG Query Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/RAG-with-Model-Graded-Eval-v2/rag_demo.ipynb Demonstrates how to run the RAG query functionality from the command line. Replace placeholders with actual values. ```bash !python rag.py query "In July, flour sold at Boston for _?" -k=10 --chroma-collection-name us_history_volume_7 ``` -------------------------------- ### Deploy Website (Using SSH) Source: https://github.com/lastmile-ai/aiconfig/blob/main/aiconfig-docs/README.md Builds the website and deploys it using SSH. Assumes SSH is configured for deployment. ```bash USE_SSH=true yarn deploy ``` -------------------------------- ### Install Python AIConfig Source: https://github.com/lastmile-ai/aiconfig/blob/main/README.md Install the Python package for AIConfig using pip or poetry. ```bash pip3 install python-aiconfig ``` ```bash poetry add python-aiconfig ``` -------------------------------- ### Run AIConfig Prompts with Python SDK Source: https://github.com/lastmile-ai/aiconfig/blob/main/README.md Load an AIConfig file, set up streaming options, and run a prompt with dependencies. This example demonstrates how to execute the 'gen_itinerary' prompt and save the updated configuration with outputs. ```python # load your AIConfig from aiconfig import AIConfigRuntime, InferenceOptions import asyncio config = AIConfigRuntime.load("travel.aiconfig.json") # setup streaming inference_options = InferenceOptions(stream=True) # run a prompt async def gen_nyc_itinerary(): gen_itinerary_response = await config.run("gen_itinerary", params = {"order_by" : "location"}, options=inference_options, run_with_dependencies=True) asyncio.run(gen_nyc_itinerary()) # save the aiconfig to disk and serialize outputs from the model run config.save('updated_travel.aiconfig.json', include_outputs=True) ``` -------------------------------- ### ChromaDB Output Logs Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/RAG-with-ChromaDB/RAG_with_AIConfig.ipynb Example output logs from the ChromaDB initialization and query process. ```text Output: /root/.cache/chroma/onnx_models/all-MiniLM-L6-v2/onnx.tar.gz: 100%|██████████| 79.3M/79.3M [00:01<00:00, 47.6MiB/s] ``` ```text Output: {'ids': [['id1']], 'distances': [[1.5048770904541016]], 'metadatas': [[{'source': 'Subject: Mathematics\n\n Course 1: Number Sense and Operations\n - Place value\n - Number patterns and relationships\n - Addition, subtraction, multiplication, and division\n - Problem-solving techniques\n\n Course 2: Algebra\n - Variables and expressions\n - Equations and inequalities\n - Patterns and functions'}]], 'embeddings': None, 'documents': [['math']], 'uris': None, 'data': None} ``` -------------------------------- ### Start AIConfig Editor Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Gradio/README.md Use this command to launch the AIConfig editor with specified configuration and parser paths. Ensure you are in the correct directory after cloning the repository. ```bash aiconfig_path=./cookbooks/Gradio/huggingface.aiconfig.json parsers_path=./cookbooks/Gradio/aiconfig_model_registry.py aiconfig edit --aiconfig-path=$aiconfig_path --parsers-module-path=$parsers_path ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/RAG-with-MongoDB/mongodb_aiconfig_rag.ipynb Install the necessary libraries for MongoDB, PDF processing, LangChain, and AIConfig. ```python # Install python dependencies. Run Once. # MongoDB reccomends `python -m pip install "pymongo[srv]"==3.11` or whatever version of python you are using %pip install pymongo %pip install pypdf %pip install langchain %pip install langchain_community %pip install langchain_openai %pip install python-aiconfig ``` -------------------------------- ### Create an AIConfig Source: https://github.com/lastmile-ai/aiconfig/blob/main/python/README.md Use `AIConfigRuntime.create` to initialize a new AIConfig with a name and description. ```python config = AIConfigRuntime.create("aiconfig name", "description") ``` -------------------------------- ### Install LlamaModelParser dependencies Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/llama/typescript/README.md Install the required AIConfig and Llama extension packages via yarn. ```bash yarn add aiconfig yarn add aiconfig-extension-llama ``` -------------------------------- ### Install AIConfig with Yarn Source: https://github.com/lastmile-ai/aiconfig/blob/main/aiconfig-docs/docs/getting-started.md Use this command to install the Node.js AIConfig package using yarn. ```bash yarn add aiconfig ``` -------------------------------- ### Setup Streaming Source: https://github.com/lastmile-ai/aiconfig/blob/main/aiconfig-docs/docs/getting-started.md Configure inference options to enable streaming responses from the model. ```python inference_options = InferenceOptions(stream=True) ``` ```typescript async function travelWithGPT() { const aiConfig = AIConfigRuntime.load( path.join(__dirname, "travel.aiconfig.json") ); const options: InferenceOptions = { callbacks: { streamCallback: (data: any, _acc: any, _idx: any) => { // Write streamed content to console process.stdout.write(data?.content || "\n"); }, }, }; } travelWithGPT(); ``` -------------------------------- ### Execute recommend_book prompt Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Anyscale/Function_Calling_with_Mixtral.ipynb Runs a prompt with specified parameters and inference options. ```python params = {"book":"Where the Crawdads Sing"} inference_options = InferenceOptions(stream=False) completion = await config.run("recommend_book", params, options=inference_options) print(completion) ``` -------------------------------- ### Install AIConfig with Poetry Source: https://github.com/lastmile-ai/aiconfig/blob/main/aiconfig-docs/docs/getting-started.md Use this command to install the python AIConfig package using poetry. ```bash poetry add python-aiconfig ``` -------------------------------- ### Execute Prompt with Parameters Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Basic-Prompt-Routing/assistant.ipynb Run a specific prompt within the configuration using provided parameters and retrieve the output text. ```python # Run a single prompt (with streaming). params = {"student_question": math_question} await config.run("router", params) topic = config.get_output_text("router") dest_prompt = topic.lower() dest_prompt ``` -------------------------------- ### Install AIConfig with Pip Source: https://github.com/lastmile-ai/aiconfig/blob/main/aiconfig-docs/docs/getting-started.md Use this command to install the python AIConfig package using pip. ```bash pip install --user python-aiconfig ``` -------------------------------- ### Load and Run Gemini Prompts Source: https://github.com/lastmile-ai/aiconfig/blob/main/cookbooks/Gemini/Gemini.ipynb Load an existing AIConfig file and prepare it for execution with inference options. ```python # Load the config you just created from aiconfig import CallbackManager, InferenceOptions aiconfig = AIConfigRuntime.load("gemini_demo.aiconfig.json") aiconfig.callback_manager = CallbackManager([]) # Skip Logging, Google Colab forwards logs to stdout inference_options = InferenceOptions(stream=True) ``` ```python # Config.run() handles the complex things for you ```