Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# %%capture
|
2 |
+
!pip install gpt4all
|
3 |
+
import gpt4all
|
4 |
+
model = gpt4all.GPT4All("ggml-gpt4all-j-v1.3-groovy.bin")
|
5 |
+
# model.chat_completion() doc: https://docs.gpt4all.io/gpt4all_python.html#gpt4all.gpt4all.GPT4All.chat_completion
|
6 |
+
# other documentation: https://github.com/nomic-ai/gpt4all/blob/main/gpt4all-bindings/python/docs/gpt4all_python.md
|
7 |
+
|
8 |
+
def print_response(prompt: str) -> str:
|
9 |
+
messages = [{'role': 'user', 'content': prompt}]
|
10 |
+
response = model.chat_completion(messages)
|
11 |
+
print(response)
|
12 |
+
# print(response.get('choices',[{'message':{'content':''}}])[0]['message']['content'])
|
13 |
+
|
14 |
+
print_response("""
|
15 |
+
# Templates:
|
16 |
+
|
17 |
+
## dropdown template:
|
18 |
+
```html
|
19 |
+
<select class="custom-control">
|
20 |
+
<option value="">- Please select -</option>
|
21 |
+
<option value="1">1</option>
|
22 |
+
<option value="2">2</option>
|
23 |
+
</select>
|
24 |
+
```
|
25 |
+
|
26 |
+
## radio template:
|
27 |
+
```html
|
28 |
+
<input class="custom-control" type="radio"/>
|
29 |
+
```
|
30 |
+
|
31 |
+
# Task:
|
32 |
+
Use just one of the templates above to write HTML code for a dropdown of the Canadian provinces/territories, with these values:
|
33 |
+
Alberta
|
34 |
+
British Columbia
|
35 |
+
Manitoba
|
36 |
+
New Brunswick
|
37 |
+
Newfoundland and Labrador
|
38 |
+
Northwest Territories
|
39 |
+
Nova Scotia
|
40 |
+
Nunavut
|
41 |
+
Ontario
|
42 |
+
Prince Edward Island
|
43 |
+
Quebec
|
44 |
+
Saskatchewan
|
45 |
+
Yukon
|
46 |
+
""")
|