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 | "id": "63ab5e89", |
| #6 | "metadata": {}, |
| #7 | "source": [ |
| #8 | "## Cookbook for using Azure OpenAI with Embedchain" |
| #9 | ] |
| #10 | }, |
| #11 | { |
| #12 | "cell_type": "markdown", |
| #13 | "id": "e32a0265", |
| #14 | "metadata": {}, |
| #15 | "source": [ |
| #16 | "### Step-1: Install embedchain package" |
| #17 | ] |
| #18 | }, |
| #19 | { |
| #20 | "cell_type": "code", |
| #21 | "execution_count": null, |
| #22 | "id": "b80ff15a", |
| #23 | "metadata": {}, |
| #24 | "outputs": [], |
| #25 | "source": [ |
| #26 | "!pip install embedchain" |
| #27 | ] |
| #28 | }, |
| #29 | { |
| #30 | "cell_type": "markdown", |
| #31 | "id": "ac982a56", |
| #32 | "metadata": {}, |
| #33 | "source": [ |
| #34 | "### Step-2: Set Azure OpenAI related environment variables\n", |
| #35 | "\n", |
| #36 | "You can find these env variables on your Azure OpenAI dashboard." |
| #37 | ] |
| #38 | }, |
| #39 | { |
| #40 | "cell_type": "code", |
| #41 | "execution_count": null, |
| #42 | "id": "e0a36133", |
| #43 | "metadata": {}, |
| #44 | "outputs": [], |
| #45 | "source": [ |
| #46 | "import os\n", |
| #47 | "from embedchain import App\n", |
| #48 | "\n", |
| #49 | "os.environ[\"OPENAI_API_TYPE\"] = \"azure\"\n", |
| #50 | "os.environ[\"OPENAI_API_BASE\"] = \"https://xxx.openai.azure.com/\"\n", |
| #51 | "os.environ[\"OPENAI_API_KEY\"] = \"xxx\"\n", |
| #52 | "os.environ[\"OPENAI_API_VERSION\"] = \"xxx\"" |
| #53 | ] |
| #54 | }, |
| #55 | { |
| #56 | "cell_type": "markdown", |
| #57 | "id": "7d7b554e", |
| #58 | "metadata": {}, |
| #59 | "source": [ |
| #60 | "### Step-3: Define your llm and embedding model config" |
| #61 | ] |
| #62 | }, |
| #63 | { |
| #64 | "cell_type": "code", |
| #65 | "execution_count": null, |
| #66 | "id": "b9f52fc5", |
| #67 | "metadata": {}, |
| #68 | "outputs": [], |
| #69 | "source": [ |
| #70 | "config = \"\"\"\n", |
| #71 | "llm:\n", |
| #72 | " provider: azure_openai\n", |
| #73 | " model: gpt-35-turbo\n", |
| #74 | " config:\n", |
| #75 | " deployment_name: ec_openai_azure\n", |
| #76 | " temperature: 0.5\n", |
| #77 | " max_tokens: 1000\n", |
| #78 | " top_p: 1\n", |
| #79 | " stream: false\n", |
| #80 | "\n", |
| #81 | "embedder:\n", |
| #82 | " provider: azure_openai\n", |
| #83 | " config:\n", |
| #84 | " model: text-embedding-ada-002\n", |
| #85 | " deployment_name: ec_embeddings_ada_002\n", |
| #86 | "\"\"\"\n", |
| #87 | "\n", |
| #88 | "# Write the multi-line string to a YAML file\n", |
| #89 | "with open('azure_openai.yaml', 'w') as file:\n", |
| #90 | " file.write(config)" |
| #91 | ] |
| #92 | }, |
| #93 | { |
| #94 | "cell_type": "markdown", |
| #95 | "id": "98a11130", |
| #96 | "metadata": {}, |
| #97 | "source": [ |
| #98 | "### Step-4 Create embedchain app based on the config" |
| #99 | ] |
| #100 | }, |
| #101 | { |
| #102 | "cell_type": "code", |
| #103 | "execution_count": null, |
| #104 | "id": "1ee9bdd9", |
| #105 | "metadata": {}, |
| #106 | "outputs": [], |
| #107 | "source": [ |
| #108 | "app = App.from_config(config_path=\"azure_openai.yaml\")" |
| #109 | ] |
| #110 | }, |
| #111 | { |
| #112 | "cell_type": "markdown", |
| #113 | "id": "554dc97b", |
| #114 | "metadata": {}, |
| #115 | "source": [ |
| #116 | "### Step-5: Add data sources to your app" |
| #117 | ] |
| #118 | }, |
| #119 | { |
| #120 | "cell_type": "code", |
| #121 | "execution_count": null, |
| #122 | "id": "686ae765", |
| #123 | "metadata": {}, |
| #124 | "outputs": [], |
| #125 | "source": [ |
| #126 | "app.add(\"https://www.forbes.com/profile/elon-musk\")" |
| #127 | ] |
| #128 | }, |
| #129 | { |
| #130 | "cell_type": "markdown", |
| #131 | "id": "ccc7d421", |
| #132 | "metadata": {}, |
| #133 | "source": [ |
| #134 | "### Step-6: All set. Now start asking questions related to your data" |
| #135 | ] |
| #136 | }, |
| #137 | { |
| #138 | "cell_type": "code", |
| #139 | "execution_count": null, |
| #140 | "id": "27868a7d", |
| #141 | "metadata": {}, |
| #142 | "outputs": [], |
| #143 | "source": [ |
| #144 | "while(True):\n", |
| #145 | " question = input(\"Enter question: \")\n", |
| #146 | " if question in ['q', 'exit', 'quit']:\n", |
| #147 | " break\n", |
| #148 | " answer = app.query(question)\n", |
| #149 | " print(answer)" |
| #150 | ] |
| #151 | } |
| #152 | ], |
| #153 | "metadata": { |
| #154 | "kernelspec": { |
| #155 | "display_name": "Python 3 (ipykernel)", |
| #156 | "language": "python", |
| #157 | "name": "python3" |
| #158 | }, |
| #159 | "language_info": { |
| #160 | "codemirror_mode": { |
| #161 | "name": "ipython", |
| #162 | "version": 3 |
| #163 | }, |
| #164 | "file_extension": ".py", |
| #165 | "mimetype": "text/x-python", |
| #166 | "name": "python", |
| #167 | "nbconvert_exporter": "python", |
| #168 | "pygments_lexer": "ipython3", |
| #169 | "version": "3.11.4" |
| #170 | } |
| #171 | }, |
| #172 | "nbformat": 4, |
| #173 | "nbformat_minor": 5 |
| #174 | } |
| #175 |