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 | "id": "b02n_zJ_hl3d" |
| #7 | }, |
| #8 | "source": [ |
| #9 | "## Cookbook for using OpenAI with Embedchain" |
| #10 | ] |
| #11 | }, |
| #12 | { |
| #13 | "cell_type": "markdown", |
| #14 | "metadata": { |
| #15 | "id": "gyJ6ui2vhtMY" |
| #16 | }, |
| #17 | "source": [ |
| #18 | "### Step-1: Install embedchain package" |
| #19 | ] |
| #20 | }, |
| #21 | { |
| #22 | "cell_type": "code", |
| #23 | "execution_count": null, |
| #24 | "metadata": { |
| #25 | "colab": { |
| #26 | "base_uri": "https://localhost:8080/", |
| #27 | "height": 1000 |
| #28 | }, |
| #29 | "id": "-NbXjAdlh0vJ", |
| #30 | "outputId": "6c630676-c7fc-4054-dc94-c613de58a037" |
| #31 | }, |
| #32 | "outputs": [], |
| #33 | "source": [ |
| #34 | "!pip install embedchain" |
| #35 | ] |
| #36 | }, |
| #37 | { |
| #38 | "cell_type": "markdown", |
| #39 | "metadata": { |
| #40 | "id": "nGnpSYAAh2bQ" |
| #41 | }, |
| #42 | "source": [ |
| #43 | "### Step-2: Set OpenAI environment variables\n", |
| #44 | "\n", |
| #45 | "You can find this env variable on your [OpenAI dashboard](https://platform.openai.com/account/api-keys)." |
| #46 | ] |
| #47 | }, |
| #48 | { |
| #49 | "cell_type": "code", |
| #50 | "execution_count": null, |
| #51 | "metadata": { |
| #52 | "id": "0fBdQ9GAiRvK" |
| #53 | }, |
| #54 | "outputs": [], |
| #55 | "source": [ |
| #56 | "import os\n", |
| #57 | "from embedchain import App\n", |
| #58 | "\n", |
| #59 | "os.environ[\"OPENAI_API_KEY\"] = \"sk-xxx\"" |
| #60 | ] |
| #61 | }, |
| #62 | { |
| #63 | "cell_type": "markdown", |
| #64 | "metadata": { |
| #65 | "id": "PGt6uPLIi1CS" |
| #66 | }, |
| #67 | "source": [ |
| #68 | "### Step-3 Create embedchain app and define your config" |
| #69 | ] |
| #70 | }, |
| #71 | { |
| #72 | "cell_type": "code", |
| #73 | "execution_count": null, |
| #74 | "metadata": { |
| #75 | "id": "Amzxk3m-i3tD" |
| #76 | }, |
| #77 | "outputs": [], |
| #78 | "source": [ |
| #79 | "app = App.from_config(config={\n", |
| #80 | " \"llm\": {\n", |
| #81 | " \"provider\": \"openai\",\n", |
| #82 | " \"config\": {\n", |
| #83 | " \"model\": \"gpt-4o-mini\",\n", |
| #84 | " \"temperature\": 0.5,\n", |
| #85 | " \"max_tokens\": 1000,\n", |
| #86 | " \"top_p\": 1,\n", |
| #87 | " \"stream\": False\n", |
| #88 | " }\n", |
| #89 | " },\n", |
| #90 | " \"embedder\": {\n", |
| #91 | " \"provider\": \"openai\",\n", |
| #92 | " \"config\": {\n", |
| #93 | " \"model\": \"text-embedding-ada-002\"\n", |
| #94 | " }\n", |
| #95 | " }\n", |
| #96 | "})" |
| #97 | ] |
| #98 | }, |
| #99 | { |
| #100 | "cell_type": "markdown", |
| #101 | "metadata": { |
| #102 | "id": "XNXv4yZwi7ef" |
| #103 | }, |
| #104 | "source": [ |
| #105 | "### Step-4: Add data sources to your app" |
| #106 | ] |
| #107 | }, |
| #108 | { |
| #109 | "cell_type": "code", |
| #110 | "execution_count": null, |
| #111 | "metadata": { |
| #112 | "id": "Sn_0rx9QjIY9" |
| #113 | }, |
| #114 | "outputs": [], |
| #115 | "source": [ |
| #116 | "app.add(\"https://www.forbes.com/profile/elon-musk\")" |
| #117 | ] |
| #118 | }, |
| #119 | { |
| #120 | "cell_type": "markdown", |
| #121 | "metadata": { |
| #122 | "id": "_7W6fDeAjMAP" |
| #123 | }, |
| #124 | "source": [ |
| #125 | "### Step-5: All set. Now start asking questions related to your data" |
| #126 | ] |
| #127 | }, |
| #128 | { |
| #129 | "cell_type": "code", |
| #130 | "execution_count": null, |
| #131 | "metadata": { |
| #132 | "id": "cvIK7dWRjN_f" |
| #133 | }, |
| #134 | "outputs": [], |
| #135 | "source": [ |
| #136 | "while(True):\n", |
| #137 | " question = input(\"Enter question: \")\n", |
| #138 | " if question in ['q', 'exit', 'quit']:\n", |
| #139 | " break\n", |
| #140 | " answer = app.query(question)\n", |
| #141 | " print(answer)" |
| #142 | ] |
| #143 | } |
| #144 | ], |
| #145 | "metadata": { |
| #146 | "colab": { |
| #147 | "provenance": [] |
| #148 | }, |
| #149 | "kernelspec": { |
| #150 | "display_name": "Python 3", |
| #151 | "name": "python3" |
| #152 | }, |
| #153 | "language_info": { |
| #154 | "name": "python", |
| #155 | "version": "3.11.6" |
| #156 | } |
| #157 | }, |
| #158 | "nbformat": 4, |
| #159 | "nbformat_minor": 0 |
| #160 | } |
| #161 |