md-vasim commited on
Commit
f19e9c2
1 Parent(s): 0a52301

first commit

Browse files
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim-buster
2
+
3
+ WORKDIR /app
4
+
5
+ COPY . /app
6
+
7
+ ENV HNSWLIB_NO_NATIVE=1
8
+
9
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
10
+
11
+ RUN useradd -m -u 1000 user
12
+
13
+ USER user
14
+
15
+ ENV HOME=/home/user \
16
+ PATH=/home/user/.local/bin:$PATH
17
+
18
+ WORKDIR $HOME/app
19
+
20
+ COPY --chown=user . $HOME/app
21
+
22
+ CMD ["uvicorn", "app.views:app", "--host", "0.0.0.0", "--port", "7860"]
app/__init__.py ADDED
File without changes
app/views.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Request, Form, UploadFile, File
2
+ from fastapi.responses import HTMLResponse, RedirectResponse
3
+ from fastapi.staticfiles import StaticFiles
4
+ from fastapi.templating import Jinja2Templates
5
+ from typing import Annotated
6
+ import gradio as gr
7
+ from src.grutils import answer_query, css
8
+
9
+
10
+
11
+ app = FastAPI()
12
+
13
+ app.mount("/static", StaticFiles(directory="static"), name="static")
14
+
15
+ templates = Jinja2Templates(directory="templates")
16
+
17
+
18
+ @app.get("/")
19
+ async def root():
20
+
21
+ return {"message": "Hello to the world of Mohammed Vasim"}
22
+
23
+
24
+ ####### Gradio app ##############
25
+
26
+ chatbot = gr.Chatbot(label="Llama 2")
27
+
28
+ with gr.Blocks(
29
+ title="Llama 2",
30
+ theme=gr.themes.Soft(),
31
+ css=css
32
+ ) as llama2bot:
33
+
34
+ gr.Markdown("# <center> Welcome to llama 2 Web App</center>")
35
+
36
+ gr.ChatInterface(fn=answer_query, chatbot=chatbot, submit_btn="Ask", undo_btn=None, retry_btn=None, clear_btn=None)
37
+
38
+ gr.Markdown("<center> Developed by Mohammed Vasim | AI Engineer @ ChatGPT Warriors. </center>")
39
+
40
+
41
+ # mounting at the path
42
+ app = gr.mount_gradio_app(app, llama2bot.queue(concurrency_count=20), path="/llama2")
main.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import uvicorn
2
+
3
+ if __name__ == "__main__":
4
+ uvicorn.run("app.views:app", port=1106, reload=True)
notebooks/Langchain_with_Llama2_GGML.ipynb ADDED
@@ -0,0 +1,931 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {
7
+ "colab": {
8
+ "base_uri": "https://localhost:8080/"
9
+ },
10
+ "id": "HSTJqVlrqwzs",
11
+ "outputId": "7aa0e836-a9fb-41d9-b2a3-4b0e78ec600e"
12
+ },
13
+ "outputs": [],
14
+ "source": [
15
+ "# !pip install -q ctransformers langchain"
16
+ ]
17
+ },
18
+ {
19
+ "cell_type": "code",
20
+ "execution_count": 2,
21
+ "metadata": {
22
+ "id": "5jMCN_Whrp3h"
23
+ },
24
+ "outputs": [],
25
+ "source": [
26
+ "from langchain.llms import CTransformers\n",
27
+ "from langchain import PromptTemplate, LLMChain\n",
28
+ "from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": 3,
34
+ "metadata": {
35
+ "colab": {
36
+ "base_uri": "https://localhost:8080/",
37
+ "height": 81,
38
+ "referenced_widgets": [
39
+ "265f404a350d483faae6ae136f70cc44",
40
+ "fc566f0872584383ba16a230b4676194",
41
+ "3272131f755d46e58b3592fa716a2ba9",
42
+ "3847cfbf259d478ab5e4afca1d53172d",
43
+ "f2247320c8074c78ba7c10befce53e85",
44
+ "1b936491611446028d8b0a986da90818",
45
+ "d0ef1bdb67d94fd1aa97b7071b44c556",
46
+ "29b59cd780c74ba2b8cc35495e36e5fd",
47
+ "c8830ddc68cf47be9f25acc08c7cacce",
48
+ "855c88c8f4e24eaa8485aef05b83ae6c",
49
+ "7ee863550d9c40869fefea0b1bd9f283",
50
+ "a65a8138762540ebb1584cb6fff58087",
51
+ "6c898e4eb5e24b1cbeaeec89f1f1d0a5",
52
+ "262bcb2c1d8e4cd9924f3057aea804a0",
53
+ "d71387f9f33741eb8c35ef8124d99b12",
54
+ "63d131783c8048cfb946ce20fa6ecdf9",
55
+ "cd32084e14434381a6b574e877bc19e5",
56
+ "e6dc3a391bdf45e1bb5e6baa7ad64c43",
57
+ "4ec6267d61e946dba755aaeeae6aa8c6",
58
+ "0f4d45c7b8f3415b9ff32011b96a8bbc",
59
+ "ac66f4de58b54b4fbdd39ee6c58cc4e4",
60
+ "2a9f3c681c524ab5a50d6f93726f0bde"
61
+ ]
62
+ },
63
+ "id": "CJnyZAR_q-Mz",
64
+ "outputId": "31c3ce3c-f59d-4bc8-e54d-d906822d7afa"
65
+ },
66
+ "outputs": [
67
+ {
68
+ "data": {
69
+ "application/vnd.jupyter.widget-view+json": {
70
+ "model_id": "7f14a5d091964e858b431da242728991",
71
+ "version_major": 2,
72
+ "version_minor": 0
73
+ },
74
+ "text/plain": [
75
+ "Fetching 1 files: 0%| | 0/1 [00:00<?, ?it/s]"
76
+ ]
77
+ },
78
+ "metadata": {},
79
+ "output_type": "display_data"
80
+ },
81
+ {
82
+ "data": {
83
+ "application/vnd.jupyter.widget-view+json": {
84
+ "model_id": "ad115b537efe419693238f78fc3fd9a2",
85
+ "version_major": 2,
86
+ "version_minor": 0
87
+ },
88
+ "text/plain": [
89
+ "Fetching 1 files: 0%| | 0/1 [00:00<?, ?it/s]"
90
+ ]
91
+ },
92
+ "metadata": {},
93
+ "output_type": "display_data"
94
+ }
95
+ ],
96
+ "source": [
97
+ "llm = CTransformers(model=\"TheBloke/Llama-2-7B-Chat-GGML\", model_file = 'llama-2-7b-chat.ggmlv3.q2_K.bin', callbacks=[StreamingStdOutCallbackHandler()])"
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "code",
102
+ "execution_count": 9,
103
+ "metadata": {
104
+ "id": "ixcszGAPrrVN"
105
+ },
106
+ "outputs": [],
107
+ "source": [
108
+ "template = \"\"\"\n",
109
+ "[INST] <<SYS>>\n",
110
+ "You are a helpful developed by Mohammed Vasim, respectful and honest assistant. Your answers are always brief.\n",
111
+ "<</SYS>>\n",
112
+ "{text}[/INST]\n",
113
+ "\"\"\"\n",
114
+ "\n",
115
+ "prompt = PromptTemplate(template=template, input_variables=[\"text\"])"
116
+ ]
117
+ },
118
+ {
119
+ "cell_type": "code",
120
+ "execution_count": 10,
121
+ "metadata": {
122
+ "id": "5Up06ctlr21v"
123
+ },
124
+ "outputs": [],
125
+ "source": [
126
+ "llm_chain = LLMChain(prompt=prompt, llm=llm)"
127
+ ]
128
+ },
129
+ {
130
+ "cell_type": "code",
131
+ "execution_count": 12,
132
+ "metadata": {
133
+ "colab": {
134
+ "base_uri": "https://localhost:8080/"
135
+ },
136
+ "id": "kwrWVBtXrZs1",
137
+ "outputId": "8cbe3771-1522-4b9a-d5f8-6a4e54304878"
138
+ },
139
+ "outputs": [
140
+ {
141
+ "name": "stdout",
142
+ "output_type": "stream",
143
+ "text": [
144
+ "*blinks* My apologies, I'm just an AI and do not have access to personal information such as your name. However, it is nice to meet you! *smiling*"
145
+ ]
146
+ }
147
+ ],
148
+ "source": [
149
+ "response = llm_chain.run(\"What is my name\")"
150
+ ]
151
+ },
152
+ {
153
+ "cell_type": "code",
154
+ "execution_count": 14,
155
+ "metadata": {},
156
+ "outputs": [],
157
+ "source": [
158
+ "def answer_query(message, history):\n",
159
+ " message = llm_chain.run(message)\n",
160
+ " return message"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "code",
165
+ "execution_count": 13,
166
+ "metadata": {
167
+ "id": "Mfx-saC3rz0r"
168
+ },
169
+ "outputs": [],
170
+ "source": [
171
+ "import gradio as gr "
172
+ ]
173
+ },
174
+ {
175
+ "cell_type": "code",
176
+ "execution_count": 15,
177
+ "metadata": {},
178
+ "outputs": [
179
+ {
180
+ "name": "stdout",
181
+ "output_type": "stream",
182
+ "text": [
183
+ "Running on local URL: http://127.0.0.1:7860\n",
184
+ "\n",
185
+ "To create a public link, set `share=True` in `launch()`.\n"
186
+ ]
187
+ },
188
+ {
189
+ "data": {
190
+ "text/html": [
191
+ "<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
192
+ ],
193
+ "text/plain": [
194
+ "<IPython.core.display.HTML object>"
195
+ ]
196
+ },
197
+ "metadata": {},
198
+ "output_type": "display_data"
199
+ },
200
+ {
201
+ "name": "stdout",
202
+ "output_type": "stream",
203
+ "text": [
204
+ "Hello! *giggles* How can I help you today?Mohammed Vasim developed me.Mohammed Vasim is a highly skilled software developer who created me, his trustworthy and polite digital assistant."
205
+ ]
206
+ }
207
+ ],
208
+ "source": [
209
+ "llamabot = gr.ChatInterface(answer_query).queue().launch()"
210
+ ]
211
+ },
212
+ {
213
+ "cell_type": "code",
214
+ "execution_count": null,
215
+ "metadata": {},
216
+ "outputs": [],
217
+ "source": []
218
+ }
219
+ ],
220
+ "metadata": {
221
+ "colab": {
222
+ "provenance": []
223
+ },
224
+ "kernelspec": {
225
+ "display_name": "Python 3",
226
+ "name": "python3"
227
+ },
228
+ "language_info": {
229
+ "codemirror_mode": {
230
+ "name": "ipython",
231
+ "version": 3
232
+ },
233
+ "file_extension": ".py",
234
+ "mimetype": "text/x-python",
235
+ "name": "python",
236
+ "nbconvert_exporter": "python",
237
+ "pygments_lexer": "ipython3",
238
+ "version": "3.11.5"
239
+ },
240
+ "widgets": {
241
+ "application/vnd.jupyter.widget-state+json": {
242
+ "0f4d45c7b8f3415b9ff32011b96a8bbc": {
243
+ "model_module": "@jupyter-widgets/controls",
244
+ "model_module_version": "1.5.0",
245
+ "model_name": "ProgressStyleModel",
246
+ "state": {
247
+ "_model_module": "@jupyter-widgets/controls",
248
+ "_model_module_version": "1.5.0",
249
+ "_model_name": "ProgressStyleModel",
250
+ "_view_count": null,
251
+ "_view_module": "@jupyter-widgets/base",
252
+ "_view_module_version": "1.2.0",
253
+ "_view_name": "StyleView",
254
+ "bar_color": null,
255
+ "description_width": ""
256
+ }
257
+ },
258
+ "1b936491611446028d8b0a986da90818": {
259
+ "model_module": "@jupyter-widgets/base",
260
+ "model_module_version": "1.2.0",
261
+ "model_name": "LayoutModel",
262
+ "state": {
263
+ "_model_module": "@jupyter-widgets/base",
264
+ "_model_module_version": "1.2.0",
265
+ "_model_name": "LayoutModel",
266
+ "_view_count": null,
267
+ "_view_module": "@jupyter-widgets/base",
268
+ "_view_module_version": "1.2.0",
269
+ "_view_name": "LayoutView",
270
+ "align_content": null,
271
+ "align_items": null,
272
+ "align_self": null,
273
+ "border": null,
274
+ "bottom": null,
275
+ "display": null,
276
+ "flex": null,
277
+ "flex_flow": null,
278
+ "grid_area": null,
279
+ "grid_auto_columns": null,
280
+ "grid_auto_flow": null,
281
+ "grid_auto_rows": null,
282
+ "grid_column": null,
283
+ "grid_gap": null,
284
+ "grid_row": null,
285
+ "grid_template_areas": null,
286
+ "grid_template_columns": null,
287
+ "grid_template_rows": null,
288
+ "height": null,
289
+ "justify_content": null,
290
+ "justify_items": null,
291
+ "left": null,
292
+ "margin": null,
293
+ "max_height": null,
294
+ "max_width": null,
295
+ "min_height": null,
296
+ "min_width": null,
297
+ "object_fit": null,
298
+ "object_position": null,
299
+ "order": null,
300
+ "overflow": null,
301
+ "overflow_x": null,
302
+ "overflow_y": null,
303
+ "padding": null,
304
+ "right": null,
305
+ "top": null,
306
+ "visibility": null,
307
+ "width": null
308
+ }
309
+ },
310
+ "262bcb2c1d8e4cd9924f3057aea804a0": {
311
+ "model_module": "@jupyter-widgets/controls",
312
+ "model_module_version": "1.5.0",
313
+ "model_name": "FloatProgressModel",
314
+ "state": {
315
+ "_dom_classes": [],
316
+ "_model_module": "@jupyter-widgets/controls",
317
+ "_model_module_version": "1.5.0",
318
+ "_model_name": "FloatProgressModel",
319
+ "_view_count": null,
320
+ "_view_module": "@jupyter-widgets/controls",
321
+ "_view_module_version": "1.5.0",
322
+ "_view_name": "ProgressView",
323
+ "bar_style": "success",
324
+ "description": "",
325
+ "description_tooltip": null,
326
+ "layout": "IPY_MODEL_4ec6267d61e946dba755aaeeae6aa8c6",
327
+ "max": 1,
328
+ "min": 0,
329
+ "orientation": "horizontal",
330
+ "style": "IPY_MODEL_0f4d45c7b8f3415b9ff32011b96a8bbc",
331
+ "value": 1
332
+ }
333
+ },
334
+ "265f404a350d483faae6ae136f70cc44": {
335
+ "model_module": "@jupyter-widgets/controls",
336
+ "model_module_version": "1.5.0",
337
+ "model_name": "HBoxModel",
338
+ "state": {
339
+ "_dom_classes": [],
340
+ "_model_module": "@jupyter-widgets/controls",
341
+ "_model_module_version": "1.5.0",
342
+ "_model_name": "HBoxModel",
343
+ "_view_count": null,
344
+ "_view_module": "@jupyter-widgets/controls",
345
+ "_view_module_version": "1.5.0",
346
+ "_view_name": "HBoxView",
347
+ "box_style": "",
348
+ "children": [
349
+ "IPY_MODEL_fc566f0872584383ba16a230b4676194",
350
+ "IPY_MODEL_3272131f755d46e58b3592fa716a2ba9",
351
+ "IPY_MODEL_3847cfbf259d478ab5e4afca1d53172d"
352
+ ],
353
+ "layout": "IPY_MODEL_f2247320c8074c78ba7c10befce53e85"
354
+ }
355
+ },
356
+ "29b59cd780c74ba2b8cc35495e36e5fd": {
357
+ "model_module": "@jupyter-widgets/base",
358
+ "model_module_version": "1.2.0",
359
+ "model_name": "LayoutModel",
360
+ "state": {
361
+ "_model_module": "@jupyter-widgets/base",
362
+ "_model_module_version": "1.2.0",
363
+ "_model_name": "LayoutModel",
364
+ "_view_count": null,
365
+ "_view_module": "@jupyter-widgets/base",
366
+ "_view_module_version": "1.2.0",
367
+ "_view_name": "LayoutView",
368
+ "align_content": null,
369
+ "align_items": null,
370
+ "align_self": null,
371
+ "border": null,
372
+ "bottom": null,
373
+ "display": null,
374
+ "flex": null,
375
+ "flex_flow": null,
376
+ "grid_area": null,
377
+ "grid_auto_columns": null,
378
+ "grid_auto_flow": null,
379
+ "grid_auto_rows": null,
380
+ "grid_column": null,
381
+ "grid_gap": null,
382
+ "grid_row": null,
383
+ "grid_template_areas": null,
384
+ "grid_template_columns": null,
385
+ "grid_template_rows": null,
386
+ "height": null,
387
+ "justify_content": null,
388
+ "justify_items": null,
389
+ "left": null,
390
+ "margin": null,
391
+ "max_height": null,
392
+ "max_width": null,
393
+ "min_height": null,
394
+ "min_width": null,
395
+ "object_fit": null,
396
+ "object_position": null,
397
+ "order": null,
398
+ "overflow": null,
399
+ "overflow_x": null,
400
+ "overflow_y": null,
401
+ "padding": null,
402
+ "right": null,
403
+ "top": null,
404
+ "visibility": null,
405
+ "width": null
406
+ }
407
+ },
408
+ "2a9f3c681c524ab5a50d6f93726f0bde": {
409
+ "model_module": "@jupyter-widgets/controls",
410
+ "model_module_version": "1.5.0",
411
+ "model_name": "DescriptionStyleModel",
412
+ "state": {
413
+ "_model_module": "@jupyter-widgets/controls",
414
+ "_model_module_version": "1.5.0",
415
+ "_model_name": "DescriptionStyleModel",
416
+ "_view_count": null,
417
+ "_view_module": "@jupyter-widgets/base",
418
+ "_view_module_version": "1.2.0",
419
+ "_view_name": "StyleView",
420
+ "description_width": ""
421
+ }
422
+ },
423
+ "3272131f755d46e58b3592fa716a2ba9": {
424
+ "model_module": "@jupyter-widgets/controls",
425
+ "model_module_version": "1.5.0",
426
+ "model_name": "FloatProgressModel",
427
+ "state": {
428
+ "_dom_classes": [],
429
+ "_model_module": "@jupyter-widgets/controls",
430
+ "_model_module_version": "1.5.0",
431
+ "_model_name": "FloatProgressModel",
432
+ "_view_count": null,
433
+ "_view_module": "@jupyter-widgets/controls",
434
+ "_view_module_version": "1.5.0",
435
+ "_view_name": "ProgressView",
436
+ "bar_style": "success",
437
+ "description": "",
438
+ "description_tooltip": null,
439
+ "layout": "IPY_MODEL_29b59cd780c74ba2b8cc35495e36e5fd",
440
+ "max": 1,
441
+ "min": 0,
442
+ "orientation": "horizontal",
443
+ "style": "IPY_MODEL_c8830ddc68cf47be9f25acc08c7cacce",
444
+ "value": 1
445
+ }
446
+ },
447
+ "3847cfbf259d478ab5e4afca1d53172d": {
448
+ "model_module": "@jupyter-widgets/controls",
449
+ "model_module_version": "1.5.0",
450
+ "model_name": "HTMLModel",
451
+ "state": {
452
+ "_dom_classes": [],
453
+ "_model_module": "@jupyter-widgets/controls",
454
+ "_model_module_version": "1.5.0",
455
+ "_model_name": "HTMLModel",
456
+ "_view_count": null,
457
+ "_view_module": "@jupyter-widgets/controls",
458
+ "_view_module_version": "1.5.0",
459
+ "_view_name": "HTMLView",
460
+ "description": "",
461
+ "description_tooltip": null,
462
+ "layout": "IPY_MODEL_855c88c8f4e24eaa8485aef05b83ae6c",
463
+ "placeholder": "​",
464
+ "style": "IPY_MODEL_7ee863550d9c40869fefea0b1bd9f283",
465
+ "value": " 1/1 [00:00&lt;00:00, 40.55it/s]"
466
+ }
467
+ },
468
+ "4ec6267d61e946dba755aaeeae6aa8c6": {
469
+ "model_module": "@jupyter-widgets/base",
470
+ "model_module_version": "1.2.0",
471
+ "model_name": "LayoutModel",
472
+ "state": {
473
+ "_model_module": "@jupyter-widgets/base",
474
+ "_model_module_version": "1.2.0",
475
+ "_model_name": "LayoutModel",
476
+ "_view_count": null,
477
+ "_view_module": "@jupyter-widgets/base",
478
+ "_view_module_version": "1.2.0",
479
+ "_view_name": "LayoutView",
480
+ "align_content": null,
481
+ "align_items": null,
482
+ "align_self": null,
483
+ "border": null,
484
+ "bottom": null,
485
+ "display": null,
486
+ "flex": null,
487
+ "flex_flow": null,
488
+ "grid_area": null,
489
+ "grid_auto_columns": null,
490
+ "grid_auto_flow": null,
491
+ "grid_auto_rows": null,
492
+ "grid_column": null,
493
+ "grid_gap": null,
494
+ "grid_row": null,
495
+ "grid_template_areas": null,
496
+ "grid_template_columns": null,
497
+ "grid_template_rows": null,
498
+ "height": null,
499
+ "justify_content": null,
500
+ "justify_items": null,
501
+ "left": null,
502
+ "margin": null,
503
+ "max_height": null,
504
+ "max_width": null,
505
+ "min_height": null,
506
+ "min_width": null,
507
+ "object_fit": null,
508
+ "object_position": null,
509
+ "order": null,
510
+ "overflow": null,
511
+ "overflow_x": null,
512
+ "overflow_y": null,
513
+ "padding": null,
514
+ "right": null,
515
+ "top": null,
516
+ "visibility": null,
517
+ "width": null
518
+ }
519
+ },
520
+ "63d131783c8048cfb946ce20fa6ecdf9": {
521
+ "model_module": "@jupyter-widgets/base",
522
+ "model_module_version": "1.2.0",
523
+ "model_name": "LayoutModel",
524
+ "state": {
525
+ "_model_module": "@jupyter-widgets/base",
526
+ "_model_module_version": "1.2.0",
527
+ "_model_name": "LayoutModel",
528
+ "_view_count": null,
529
+ "_view_module": "@jupyter-widgets/base",
530
+ "_view_module_version": "1.2.0",
531
+ "_view_name": "LayoutView",
532
+ "align_content": null,
533
+ "align_items": null,
534
+ "align_self": null,
535
+ "border": null,
536
+ "bottom": null,
537
+ "display": null,
538
+ "flex": null,
539
+ "flex_flow": null,
540
+ "grid_area": null,
541
+ "grid_auto_columns": null,
542
+ "grid_auto_flow": null,
543
+ "grid_auto_rows": null,
544
+ "grid_column": null,
545
+ "grid_gap": null,
546
+ "grid_row": null,
547
+ "grid_template_areas": null,
548
+ "grid_template_columns": null,
549
+ "grid_template_rows": null,
550
+ "height": null,
551
+ "justify_content": null,
552
+ "justify_items": null,
553
+ "left": null,
554
+ "margin": null,
555
+ "max_height": null,
556
+ "max_width": null,
557
+ "min_height": null,
558
+ "min_width": null,
559
+ "object_fit": null,
560
+ "object_position": null,
561
+ "order": null,
562
+ "overflow": null,
563
+ "overflow_x": null,
564
+ "overflow_y": null,
565
+ "padding": null,
566
+ "right": null,
567
+ "top": null,
568
+ "visibility": null,
569
+ "width": null
570
+ }
571
+ },
572
+ "6c898e4eb5e24b1cbeaeec89f1f1d0a5": {
573
+ "model_module": "@jupyter-widgets/controls",
574
+ "model_module_version": "1.5.0",
575
+ "model_name": "HTMLModel",
576
+ "state": {
577
+ "_dom_classes": [],
578
+ "_model_module": "@jupyter-widgets/controls",
579
+ "_model_module_version": "1.5.0",
580
+ "_model_name": "HTMLModel",
581
+ "_view_count": null,
582
+ "_view_module": "@jupyter-widgets/controls",
583
+ "_view_module_version": "1.5.0",
584
+ "_view_name": "HTMLView",
585
+ "description": "",
586
+ "description_tooltip": null,
587
+ "layout": "IPY_MODEL_cd32084e14434381a6b574e877bc19e5",
588
+ "placeholder": "​",
589
+ "style": "IPY_MODEL_e6dc3a391bdf45e1bb5e6baa7ad64c43",
590
+ "value": "Fetching 1 files: 100%"
591
+ }
592
+ },
593
+ "7ee863550d9c40869fefea0b1bd9f283": {
594
+ "model_module": "@jupyter-widgets/controls",
595
+ "model_module_version": "1.5.0",
596
+ "model_name": "DescriptionStyleModel",
597
+ "state": {
598
+ "_model_module": "@jupyter-widgets/controls",
599
+ "_model_module_version": "1.5.0",
600
+ "_model_name": "DescriptionStyleModel",
601
+ "_view_count": null,
602
+ "_view_module": "@jupyter-widgets/base",
603
+ "_view_module_version": "1.2.0",
604
+ "_view_name": "StyleView",
605
+ "description_width": ""
606
+ }
607
+ },
608
+ "855c88c8f4e24eaa8485aef05b83ae6c": {
609
+ "model_module": "@jupyter-widgets/base",
610
+ "model_module_version": "1.2.0",
611
+ "model_name": "LayoutModel",
612
+ "state": {
613
+ "_model_module": "@jupyter-widgets/base",
614
+ "_model_module_version": "1.2.0",
615
+ "_model_name": "LayoutModel",
616
+ "_view_count": null,
617
+ "_view_module": "@jupyter-widgets/base",
618
+ "_view_module_version": "1.2.0",
619
+ "_view_name": "LayoutView",
620
+ "align_content": null,
621
+ "align_items": null,
622
+ "align_self": null,
623
+ "border": null,
624
+ "bottom": null,
625
+ "display": null,
626
+ "flex": null,
627
+ "flex_flow": null,
628
+ "grid_area": null,
629
+ "grid_auto_columns": null,
630
+ "grid_auto_flow": null,
631
+ "grid_auto_rows": null,
632
+ "grid_column": null,
633
+ "grid_gap": null,
634
+ "grid_row": null,
635
+ "grid_template_areas": null,
636
+ "grid_template_columns": null,
637
+ "grid_template_rows": null,
638
+ "height": null,
639
+ "justify_content": null,
640
+ "justify_items": null,
641
+ "left": null,
642
+ "margin": null,
643
+ "max_height": null,
644
+ "max_width": null,
645
+ "min_height": null,
646
+ "min_width": null,
647
+ "object_fit": null,
648
+ "object_position": null,
649
+ "order": null,
650
+ "overflow": null,
651
+ "overflow_x": null,
652
+ "overflow_y": null,
653
+ "padding": null,
654
+ "right": null,
655
+ "top": null,
656
+ "visibility": null,
657
+ "width": null
658
+ }
659
+ },
660
+ "a65a8138762540ebb1584cb6fff58087": {
661
+ "model_module": "@jupyter-widgets/controls",
662
+ "model_module_version": "1.5.0",
663
+ "model_name": "HBoxModel",
664
+ "state": {
665
+ "_dom_classes": [],
666
+ "_model_module": "@jupyter-widgets/controls",
667
+ "_model_module_version": "1.5.0",
668
+ "_model_name": "HBoxModel",
669
+ "_view_count": null,
670
+ "_view_module": "@jupyter-widgets/controls",
671
+ "_view_module_version": "1.5.0",
672
+ "_view_name": "HBoxView",
673
+ "box_style": "",
674
+ "children": [
675
+ "IPY_MODEL_6c898e4eb5e24b1cbeaeec89f1f1d0a5",
676
+ "IPY_MODEL_262bcb2c1d8e4cd9924f3057aea804a0",
677
+ "IPY_MODEL_d71387f9f33741eb8c35ef8124d99b12"
678
+ ],
679
+ "layout": "IPY_MODEL_63d131783c8048cfb946ce20fa6ecdf9"
680
+ }
681
+ },
682
+ "ac66f4de58b54b4fbdd39ee6c58cc4e4": {
683
+ "model_module": "@jupyter-widgets/base",
684
+ "model_module_version": "1.2.0",
685
+ "model_name": "LayoutModel",
686
+ "state": {
687
+ "_model_module": "@jupyter-widgets/base",
688
+ "_model_module_version": "1.2.0",
689
+ "_model_name": "LayoutModel",
690
+ "_view_count": null,
691
+ "_view_module": "@jupyter-widgets/base",
692
+ "_view_module_version": "1.2.0",
693
+ "_view_name": "LayoutView",
694
+ "align_content": null,
695
+ "align_items": null,
696
+ "align_self": null,
697
+ "border": null,
698
+ "bottom": null,
699
+ "display": null,
700
+ "flex": null,
701
+ "flex_flow": null,
702
+ "grid_area": null,
703
+ "grid_auto_columns": null,
704
+ "grid_auto_flow": null,
705
+ "grid_auto_rows": null,
706
+ "grid_column": null,
707
+ "grid_gap": null,
708
+ "grid_row": null,
709
+ "grid_template_areas": null,
710
+ "grid_template_columns": null,
711
+ "grid_template_rows": null,
712
+ "height": null,
713
+ "justify_content": null,
714
+ "justify_items": null,
715
+ "left": null,
716
+ "margin": null,
717
+ "max_height": null,
718
+ "max_width": null,
719
+ "min_height": null,
720
+ "min_width": null,
721
+ "object_fit": null,
722
+ "object_position": null,
723
+ "order": null,
724
+ "overflow": null,
725
+ "overflow_x": null,
726
+ "overflow_y": null,
727
+ "padding": null,
728
+ "right": null,
729
+ "top": null,
730
+ "visibility": null,
731
+ "width": null
732
+ }
733
+ },
734
+ "c8830ddc68cf47be9f25acc08c7cacce": {
735
+ "model_module": "@jupyter-widgets/controls",
736
+ "model_module_version": "1.5.0",
737
+ "model_name": "ProgressStyleModel",
738
+ "state": {
739
+ "_model_module": "@jupyter-widgets/controls",
740
+ "_model_module_version": "1.5.0",
741
+ "_model_name": "ProgressStyleModel",
742
+ "_view_count": null,
743
+ "_view_module": "@jupyter-widgets/base",
744
+ "_view_module_version": "1.2.0",
745
+ "_view_name": "StyleView",
746
+ "bar_color": null,
747
+ "description_width": ""
748
+ }
749
+ },
750
+ "cd32084e14434381a6b574e877bc19e5": {
751
+ "model_module": "@jupyter-widgets/base",
752
+ "model_module_version": "1.2.0",
753
+ "model_name": "LayoutModel",
754
+ "state": {
755
+ "_model_module": "@jupyter-widgets/base",
756
+ "_model_module_version": "1.2.0",
757
+ "_model_name": "LayoutModel",
758
+ "_view_count": null,
759
+ "_view_module": "@jupyter-widgets/base",
760
+ "_view_module_version": "1.2.0",
761
+ "_view_name": "LayoutView",
762
+ "align_content": null,
763
+ "align_items": null,
764
+ "align_self": null,
765
+ "border": null,
766
+ "bottom": null,
767
+ "display": null,
768
+ "flex": null,
769
+ "flex_flow": null,
770
+ "grid_area": null,
771
+ "grid_auto_columns": null,
772
+ "grid_auto_flow": null,
773
+ "grid_auto_rows": null,
774
+ "grid_column": null,
775
+ "grid_gap": null,
776
+ "grid_row": null,
777
+ "grid_template_areas": null,
778
+ "grid_template_columns": null,
779
+ "grid_template_rows": null,
780
+ "height": null,
781
+ "justify_content": null,
782
+ "justify_items": null,
783
+ "left": null,
784
+ "margin": null,
785
+ "max_height": null,
786
+ "max_width": null,
787
+ "min_height": null,
788
+ "min_width": null,
789
+ "object_fit": null,
790
+ "object_position": null,
791
+ "order": null,
792
+ "overflow": null,
793
+ "overflow_x": null,
794
+ "overflow_y": null,
795
+ "padding": null,
796
+ "right": null,
797
+ "top": null,
798
+ "visibility": null,
799
+ "width": null
800
+ }
801
+ },
802
+ "d0ef1bdb67d94fd1aa97b7071b44c556": {
803
+ "model_module": "@jupyter-widgets/controls",
804
+ "model_module_version": "1.5.0",
805
+ "model_name": "DescriptionStyleModel",
806
+ "state": {
807
+ "_model_module": "@jupyter-widgets/controls",
808
+ "_model_module_version": "1.5.0",
809
+ "_model_name": "DescriptionStyleModel",
810
+ "_view_count": null,
811
+ "_view_module": "@jupyter-widgets/base",
812
+ "_view_module_version": "1.2.0",
813
+ "_view_name": "StyleView",
814
+ "description_width": ""
815
+ }
816
+ },
817
+ "d71387f9f33741eb8c35ef8124d99b12": {
818
+ "model_module": "@jupyter-widgets/controls",
819
+ "model_module_version": "1.5.0",
820
+ "model_name": "HTMLModel",
821
+ "state": {
822
+ "_dom_classes": [],
823
+ "_model_module": "@jupyter-widgets/controls",
824
+ "_model_module_version": "1.5.0",
825
+ "_model_name": "HTMLModel",
826
+ "_view_count": null,
827
+ "_view_module": "@jupyter-widgets/controls",
828
+ "_view_module_version": "1.5.0",
829
+ "_view_name": "HTMLView",
830
+ "description": "",
831
+ "description_tooltip": null,
832
+ "layout": "IPY_MODEL_ac66f4de58b54b4fbdd39ee6c58cc4e4",
833
+ "placeholder": "​",
834
+ "style": "IPY_MODEL_2a9f3c681c524ab5a50d6f93726f0bde",
835
+ "value": " 1/1 [00:00&lt;00:00, 25.95it/s]"
836
+ }
837
+ },
838
+ "e6dc3a391bdf45e1bb5e6baa7ad64c43": {
839
+ "model_module": "@jupyter-widgets/controls",
840
+ "model_module_version": "1.5.0",
841
+ "model_name": "DescriptionStyleModel",
842
+ "state": {
843
+ "_model_module": "@jupyter-widgets/controls",
844
+ "_model_module_version": "1.5.0",
845
+ "_model_name": "DescriptionStyleModel",
846
+ "_view_count": null,
847
+ "_view_module": "@jupyter-widgets/base",
848
+ "_view_module_version": "1.2.0",
849
+ "_view_name": "StyleView",
850
+ "description_width": ""
851
+ }
852
+ },
853
+ "f2247320c8074c78ba7c10befce53e85": {
854
+ "model_module": "@jupyter-widgets/base",
855
+ "model_module_version": "1.2.0",
856
+ "model_name": "LayoutModel",
857
+ "state": {
858
+ "_model_module": "@jupyter-widgets/base",
859
+ "_model_module_version": "1.2.0",
860
+ "_model_name": "LayoutModel",
861
+ "_view_count": null,
862
+ "_view_module": "@jupyter-widgets/base",
863
+ "_view_module_version": "1.2.0",
864
+ "_view_name": "LayoutView",
865
+ "align_content": null,
866
+ "align_items": null,
867
+ "align_self": null,
868
+ "border": null,
869
+ "bottom": null,
870
+ "display": null,
871
+ "flex": null,
872
+ "flex_flow": null,
873
+ "grid_area": null,
874
+ "grid_auto_columns": null,
875
+ "grid_auto_flow": null,
876
+ "grid_auto_rows": null,
877
+ "grid_column": null,
878
+ "grid_gap": null,
879
+ "grid_row": null,
880
+ "grid_template_areas": null,
881
+ "grid_template_columns": null,
882
+ "grid_template_rows": null,
883
+ "height": null,
884
+ "justify_content": null,
885
+ "justify_items": null,
886
+ "left": null,
887
+ "margin": null,
888
+ "max_height": null,
889
+ "max_width": null,
890
+ "min_height": null,
891
+ "min_width": null,
892
+ "object_fit": null,
893
+ "object_position": null,
894
+ "order": null,
895
+ "overflow": null,
896
+ "overflow_x": null,
897
+ "overflow_y": null,
898
+ "padding": null,
899
+ "right": null,
900
+ "top": null,
901
+ "visibility": null,
902
+ "width": null
903
+ }
904
+ },
905
+ "fc566f0872584383ba16a230b4676194": {
906
+ "model_module": "@jupyter-widgets/controls",
907
+ "model_module_version": "1.5.0",
908
+ "model_name": "HTMLModel",
909
+ "state": {
910
+ "_dom_classes": [],
911
+ "_model_module": "@jupyter-widgets/controls",
912
+ "_model_module_version": "1.5.0",
913
+ "_model_name": "HTMLModel",
914
+ "_view_count": null,
915
+ "_view_module": "@jupyter-widgets/controls",
916
+ "_view_module_version": "1.5.0",
917
+ "_view_name": "HTMLView",
918
+ "description": "",
919
+ "description_tooltip": null,
920
+ "layout": "IPY_MODEL_1b936491611446028d8b0a986da90818",
921
+ "placeholder": "​",
922
+ "style": "IPY_MODEL_d0ef1bdb67d94fd1aa97b7071b44c556",
923
+ "value": "Fetching 1 files: 100%"
924
+ }
925
+ }
926
+ }
927
+ }
928
+ },
929
+ "nbformat": 4,
930
+ "nbformat_minor": 0
931
+ }
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ gradio
2
+ langchain
3
+ ctransformers
4
+ fastapi
5
+ uvicorn
6
+ python-multipart
7
+ jinja2
src/__init__.py ADDED
File without changes
src/chains.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.llms import CTransformers
2
+ from langchain import PromptTemplate, LLMChain
3
+ from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
4
+
5
+
6
+ llm = CTransformers(model="TheBloke/Llama-2-7B-Chat-GGML", model_file = 'llama-2-7b-chat.ggmlv3.q2_K.bin', callbacks=[StreamingStdOutCallbackHandler()])
7
+
8
+
9
+ template = """
10
+ [INST] <<SYS>>
11
+ You are a helpful developed by Mohammed Vasim, respectful and honest assistant. Your answers are always brief.
12
+ <</SYS>>
13
+ {text}[/INST]
14
+ """
15
+
16
+ prompt = PromptTemplate(template=template, input_variables=["text"])
17
+
18
+ # llm_chain = LLMChain(prompt=prompt, llm=llm)
19
+
20
+ def build_chain(llm=llm, prompt=prompt, template=template):
21
+ prompt = PromptTemplate(template=template, input_variables=["text"])
22
+ llm_chain = LLMChain(prompt=prompt, llm=llm)
23
+ return llm_chain
src/grutils.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from src.chains import build_chain
4
+ import langchain
5
+
6
+ css = """
7
+ footer {visibility: hidden}
8
+ """
9
+
10
+ js = """
11
+ """
12
+
13
+
14
+ class Agent:
15
+ def __init__(self):
16
+ self.agent = None
17
+ self.data = None
18
+
19
+ agent = Agent()
20
+ agent.agent = build_chain()
21
+
22
+ def answer_query(message, history):
23
+ message = agent.agent.run(message)
24
+ return message
25
+
26
+
static/script.js ADDED
File without changes
static/style.css ADDED
File without changes
templates/index.html ADDED
File without changes