repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | { |
| #2 | "cells": [ |
| #3 | { |
| #4 | "cell_type": "markdown", |
| #5 | "metadata": {}, |
| #6 | "source": [ |
| #7 | "# Cookbook for using Clarifai LLM and Embedders with Embedchain" |
| #8 | ] |
| #9 | }, |
| #10 | { |
| #11 | "cell_type": "markdown", |
| #12 | "metadata": {}, |
| #13 | "source": [ |
| #14 | "## Step-1: Install embedchain-clarifai package" |
| #15 | ] |
| #16 | }, |
| #17 | { |
| #18 | "cell_type": "code", |
| #19 | "execution_count": null, |
| #20 | "metadata": {}, |
| #21 | "outputs": [], |
| #22 | "source": [ |
| #23 | "!pip install embedchain[clarifai]" |
| #24 | ] |
| #25 | }, |
| #26 | { |
| #27 | "cell_type": "markdown", |
| #28 | "metadata": {}, |
| #29 | "source": [ |
| #30 | "## Step-2: Set Clarifai PAT as env variable.\n", |
| #31 | "Sign-up to [Clarifai](https://clarifai.com/signup?utm_source=clarifai_home&utm_medium=direct&) platform and you can obtain `CLARIFAI_PAT` by following this [link](https://docs.clarifai.com/clarifai-basics/authentication/personal-access-tokens/).\n", |
| #32 | "\n", |
| #33 | "optionally you can also pass `api_key` in config of llm/embedder class." |
| #34 | ] |
| #35 | }, |
| #36 | { |
| #37 | "cell_type": "code", |
| #38 | "execution_count": null, |
| #39 | "metadata": {}, |
| #40 | "outputs": [], |
| #41 | "source": [ |
| #42 | "import os\n", |
| #43 | "from embedchain import App\n", |
| #44 | "\n", |
| #45 | "os.environ[\"CLARIFAI_PAT\"]=\"xxx\"" |
| #46 | ] |
| #47 | }, |
| #48 | { |
| #49 | "cell_type": "markdown", |
| #50 | "metadata": {}, |
| #51 | "source": [ |
| #52 | "## Step-3 Create embedchain app using clarifai LLM and embedder and define your config.\n", |
| #53 | "\n", |
| #54 | "Browse through Clarifai community page to get the URL of different [LLM](https://clarifai.com/explore/models?page=1&perPage=24&filterData=%5B%7B%22field%22%3A%22use_cases%22%2C%22value%22%3A%5B%22llm%22%5D%7D%5D) and [embedding](https://clarifai.com/explore/models?page=1&perPage=24&filterData=%5B%7B%22field%22%3A%22input_fields%22%2C%22value%22%3A%5B%22text%22%5D%7D%2C%7B%22field%22%3A%22output_fields%22%2C%22value%22%3A%5B%22embeddings%22%5D%7D%5D) models available." |
| #55 | ] |
| #56 | }, |
| #57 | { |
| #58 | "cell_type": "code", |
| #59 | "execution_count": null, |
| #60 | "metadata": {}, |
| #61 | "outputs": [], |
| #62 | "source": [ |
| #63 | "# Use model_kwargs to pass all model specific parameters for inference.\n", |
| #64 | "app = App.from_config(config={\n", |
| #65 | " \"llm\": {\n", |
| #66 | " \"provider\": \"clarifai\",\n", |
| #67 | " \"config\": {\n", |
| #68 | " \"model\": \"https://clarifai.com/mistralai/completion/models/mistral-7B-Instruct\",\n", |
| #69 | " \"model_kwargs\": {\n", |
| #70 | " \"temperature\": 0.5,\n", |
| #71 | " \"max_tokens\": 1000\n", |
| #72 | " }\n", |
| #73 | " }\n", |
| #74 | " },\n", |
| #75 | " \"embedder\": {\n", |
| #76 | " \"provider\": \"clarifai\",\n", |
| #77 | " \"config\": {\n", |
| #78 | " \"model\": \"https://clarifai.com/openai/embed/models/text-embedding-ada\",\n", |
| #79 | " }\n", |
| #80 | "}\n", |
| #81 | "})" |
| #82 | ] |
| #83 | }, |
| #84 | { |
| #85 | "cell_type": "markdown", |
| #86 | "metadata": {}, |
| #87 | "source": [ |
| #88 | "## Step-4: Add data sources to your app" |
| #89 | ] |
| #90 | }, |
| #91 | { |
| #92 | "cell_type": "code", |
| #93 | "execution_count": null, |
| #94 | "metadata": {}, |
| #95 | "outputs": [], |
| #96 | "source": [ |
| #97 | "app.add(\"https://www.forbes.com/profile/elon-musk\")" |
| #98 | ] |
| #99 | }, |
| #100 | { |
| #101 | "cell_type": "markdown", |
| #102 | "metadata": {}, |
| #103 | "source": [ |
| #104 | "## Step-5: All set. Now start asking questions related to your data" |
| #105 | ] |
| #106 | }, |
| #107 | { |
| #108 | "cell_type": "code", |
| #109 | "execution_count": null, |
| #110 | "metadata": {}, |
| #111 | "outputs": [], |
| #112 | "source": [ |
| #113 | "while(True):\n", |
| #114 | " question = input(\"Enter question: \")\n", |
| #115 | " if question in ['q', 'exit', 'quit']:\n", |
| #116 | " break\n", |
| #117 | " answer = app.query(question)\n", |
| #118 | " print(answer)" |
| #119 | ] |
| #120 | } |
| #121 | ], |
| #122 | "metadata": { |
| #123 | "kernelspec": { |
| #124 | "display_name": "v1", |
| #125 | "language": "python", |
| #126 | "name": "python3" |
| #127 | }, |
| #128 | "language_info": { |
| #129 | "name": "python", |
| #130 | "version": "3.9.10" |
| #131 | } |
| #132 | }, |
| #133 | "nbformat": 4, |
| #134 | "nbformat_minor": 2 |
| #135 | } |
| #136 |