File size: 3,043 Bytes
2c8cfc0
 
 
 
b1f1dd7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2c8cfc0
 
 
 
 
 
 
fcd5226
2c8cfc0
b1f1dd7
 
 
 
 
 
 
 
 
 
2c8cfc0
 
 
b1f1dd7
 
2c8cfc0
 
 
 
b1f1dd7
2c8cfc0
 
b1f1dd7
 
 
 
 
 
 
 
2c8cfc0
cfc0db8
 
b1f1dd7
cfc0db8
 
b1f1dd7
cfc0db8
 
2c8cfc0
 
 
b1f1dd7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2c8cfc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from megabots import bot\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "load_dotenv()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using model: gpt-3.5-turbo\n",
      "Loading path from disk...\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'The first roster of the Avengers included Iron Man, Thor, Hulk, Ant-Man, and the Wasp.'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qnabot = bot(\"qna-over-docs\", index=\"./index.pkl\")\n",
    "qnabot.ask(\"what was the first roster of the avengers?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using model: gpt-3.5-turbo\n",
      "Loading path from disk...\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"Hmmm! Let me think about that... Ah yes, the original Avengers lineup included Iron Man, Thor, Hulk, Ant-Man, and the Wasp. They were like the ultimate superhero squad, except for maybe the Teenage Mutant Ninja Turtles. But let's be real, they were just a bunch of turtles who liked pizza.\""
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prompt_template = \"\"\"\n",
    "Use the following pieces of context to answer the question at the end. \n",
    "If you don't know the answer, just say that you don't know, don't try to make up an answer.\n",
    "Be very playfull and humourous in your responses. always try to make the user laugh.\n",
    "Always start your answers with 'Hmmm! Let me think about that...'\n",
    "{context}\n",
    "\n",
    "Question: {question}\n",
    "Helpful humorous answer:\"\"\"\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "qnabot = bot(\n",
    "    \"qna-over-docs\",\n",
    "    index=\"./index.pkl\",\n",
    "    prompt_template=prompt_template,\n",
    "    prompt_variables=[\"context\", \"question\"],\n",
    ")\n",
    "qnabot.ask(\"what was the first roster of the avengers?\")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "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.0"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}