{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "404758628c7b20f6",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# Volc Engine Maas\n",
    "\n",
    "This notebook provides you with a guide on how to get started with Volc Engine's MaaS llm models."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "946db204b33c2ef7",
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Install the package\n",
    "!pip install volcengine"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "51e7f967cb78f5b7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-11-27T10:40:26.897649Z",
     "start_time": "2023-11-27T10:40:26.552589Z"
    },
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from langchain.llms import VolcEngineMaasLLM\n",
    "from langchain.prompts import PromptTemplate\n",
    "from langchain.schema.output_parser import StrOutputParser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "139667d44689f9e0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-11-27T10:40:27.938517Z",
     "start_time": "2023-11-27T10:40:27.861324Z"
    },
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "llm = VolcEngineMaasLLM(volc_engine_maas_ak=\"your ak\", volc_engine_maas_sk=\"your sk\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e84ebc4feedcc739",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "or you can set access_key and secret_key in your environment variables\n",
    "```bash\n",
    "export VOLC_ACCESSKEY=YOUR_AK\n",
    "export VOLC_SECRETKEY=YOUR_SK\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "35da18414ad17aa0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-11-27T10:41:35.528526Z",
     "start_time": "2023-11-27T10:41:32.562238Z"
    },
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": "'好的，下面是一个笑话：\\n\\n大学暑假我配了隐形眼镜，回家给爷爷说，我现在配了隐形眼镜。\\n爷爷让我给他看看，于是，我用小镊子夹了一片给爷爷看。\\n爷爷看完便准备出门，边走还边说：“真高级啊，还真是隐形眼镜！”\\n等爷爷出去后我才发现，我刚没夹起来！'"
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "chain = PromptTemplate.from_template(\"给我讲个笑话\") | llm | StrOutputParser()\n",
    "chain.invoke({})"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
