Skip to content

Commit

Permalink
check chapter 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ayulockin committed Sep 20, 2024
1 parent b365bcb commit ee48d15
Showing 1 changed file with 70 additions and 61 deletions.
131 changes: 70 additions & 61 deletions rag-advanced/notebooks/Chapter00.ipynb
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "AhbNjskBiz8K"
},
"source": [
"## Chapter 0: Setup\n",
"\n",
Expand All @@ -32,14 +21,11 @@
"Before you run this colab notebook, head over to this [link to redeem a free Cohere API key](https://docs.google.com/forms/d/e/1FAIpQLSc9x4nV8_nSQvJnaINO1j9NIa2IUbAJqrKeSllNNCCbMFmCxw/viewform?usp=sf_link).\n",
"\n",
"Alternatively if you have a Cohere API key feel free to proceed. :)"
],
"metadata": {
"id": "AhbNjskBiz8K"
}
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"id": "iGijEKPshesT"
},
Expand All @@ -50,93 +36,116 @@
},
{
"cell_type": "markdown",
"metadata": {
"id": "FaJZ6oqVjmtn"
},
"source": [
"## 1. Setup Weave\n",
"\n",
"\n",
"The code cell below will prompt you to put in a W&B API key. You can get your API key by heading over to https://wandb.ai/authorize."
],
"metadata": {
"id": "FaJZ6oqVjmtn"
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4tBZWxORipYd"
},
"outputs": [],
"source": [
"# import weave\n",
"import weave\n",
"\n",
"# initialize weave client\n",
"weave_client = weave.init(\"rag-course\")"
],
"metadata": {
"id": "4tBZWxORipYd"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "xNciXxUilcPA"
},
"source": [
"## 2. Setup Cohere\n",
"\n",
"The code cell below will prompt you to put in a Cohere API key."
],
"metadata": {
"id": "xNciXxUilcPA"
}
]
},
{
"cell_type": "code",
"source": [
"import getpass\n",
"import os\n",
"\n",
"os.environ[\"COHERE_API_KEY\"] = getpass.getpass(\"Please enter your COHERE_API_KEY\")"
],
"execution_count": 3,
"metadata": {
"id": "7HRFKWdMlB3V"
},
"execution_count": null,
"outputs": []
"outputs": [],
"source": [
"import cohere\n",
"import getpass\n",
"\n",
"cohere_client = cohere.ClientV2(\n",
" api_key=getpass.getpass(\"Please enter your COHERE_API_KEY\")\n",
")"
]
},
{
"cell_type": "markdown",
"source": [
"## A simple-turn chat with Cohere's command-r-plus"
],
"metadata": {
"id": "KvC2r8ZEnjbO"
}
},
"source": [
"## A simple-turn chat with Cohere's command-r-plus"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "jPlVCfh7nXcH"
},
"outputs": [],
"source": [
"import cohere\n",
"\n",
"cohere_client = cohere.Client(api_key=os.environ[\"COHERE_API_KEY\"])\n",
"\n",
"response = cohere_client.chat(\n",
" message=\"What is retrieval augmented generation (RAG)?\",\n",
" messages=[\n",
" {\"role\": \"user\", \"content\": \"What is retrieval augmented generation (RAG)?\"}\n",
" ],\n",
" model=\"command-r-plus\",\n",
" temperature=0.1,\n",
" max_tokens=2000,\n",
")"
],
"metadata": {
"id": "jPlVCfh7nXcH"
},
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
"source": [
"Let's head over to the weave URL to check out the generated response."
],
"metadata": {
"id": "SbA4GRvzqQNv"
}
},
"source": [
"Let's head over to the weave URL to check out the generated response."
]
}
]
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit ee48d15

Please sign in to comment.