Spaces:
Sleeping
Sleeping
Upload chatbot_trial1.ipynb
Browse files- chatbot_trial1.ipynb +109 -0
chatbot_trial1.ipynb
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"Requirement already satisfied: streamlit in c:\\programdata\\anaconda3\\lib\\site-packages (1.38.0)Note: you may need to restart the kernel to use updated packages.\n",
|
13 |
+
"\n",
|
14 |
+
"Requirement already satisfied: requests in c:\\programdata\\anaconda3\\lib\\site-packages (2.24.0)\n",
|
15 |
+
"Requirement already satisfied: protobuf<6,>=3.20 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (5.28.1)\n",
|
16 |
+
"Requirement already satisfied: pydeck<1,>=0.8.0b4 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (0.9.1)\n",
|
17 |
+
"Requirement already satisfied: pillow<11,>=7.1.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (8.0.1)\n",
|
18 |
+
"Requirement already satisfied: tornado<7,>=6.0.3 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (6.0.4)\n",
|
19 |
+
"Requirement already satisfied: tenacity<9,>=8.1.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (8.5.0)\n",
|
20 |
+
"Requirement already satisfied: packaging<25,>=20 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (24.1)\n",
|
21 |
+
"Requirement already satisfied: cachetools<6,>=4.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (5.0.0)\n",
|
22 |
+
"Requirement already satisfied: pandas<3,>=1.3.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (2.0.3)\n",
|
23 |
+
"Requirement already satisfied: click<9,>=7.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (7.1.2)\n",
|
24 |
+
"Requirement already satisfied: blinker<2,>=1.0.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (1.8.2)\n",
|
25 |
+
"Requirement already satisfied: pyarrow>=7.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (17.0.0)\n",
|
26 |
+
"Requirement already satisfied: typing-extensions<5,>=4.3.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (4.12.2)\n",
|
27 |
+
"Requirement already satisfied: watchdog<5,>=2.1.5; platform_system != \"Darwin\" in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (4.0.2)\n",
|
28 |
+
"Requirement already satisfied: altair<6,>=4.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (5.4.1)\n",
|
29 |
+
"Requirement already satisfied: numpy<3,>=1.20 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (1.22.3)\n",
|
30 |
+
"Requirement already satisfied: rich<14,>=10.14.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (13.8.1)\n",
|
31 |
+
"Requirement already satisfied: toml<2,>=0.10.1 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (0.10.1)\n",
|
32 |
+
"Requirement already satisfied: gitpython!=3.1.19,<4,>=3.0.7 in c:\\programdata\\anaconda3\\lib\\site-packages (from streamlit) (3.1.43)\n",
|
33 |
+
"Requirement already satisfied: certifi>=2017.4.17 in c:\\programdata\\anaconda3\\lib\\site-packages (from requests) (2020.6.20)\n",
|
34 |
+
"Requirement already satisfied: idna<3,>=2.5 in c:\\programdata\\anaconda3\\lib\\site-packages (from requests) (2.10)\n",
|
35 |
+
"Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\\programdata\\anaconda3\\lib\\site-packages (from requests) (1.25.11)\n",
|
36 |
+
"Requirement already satisfied: chardet<4,>=3.0.2 in c:\\programdata\\anaconda3\\lib\\site-packages (from requests) (3.0.4)\n",
|
37 |
+
"Requirement already satisfied: jinja2>=2.10.1 in c:\\programdata\\anaconda3\\lib\\site-packages (from pydeck<1,>=0.8.0b4->streamlit) (2.11.2)\n",
|
38 |
+
"Requirement already satisfied: tzdata>=2022.1 in c:\\programdata\\anaconda3\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2024.1)\n",
|
39 |
+
"Requirement already satisfied: pytz>=2020.1 in c:\\programdata\\anaconda3\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2020.1)\n",
|
40 |
+
"Requirement already satisfied: python-dateutil>=2.8.2 in c:\\programdata\\anaconda3\\lib\\site-packages (from pandas<3,>=1.3.0->streamlit) (2.9.0.post0)\n",
|
41 |
+
"Requirement already satisfied: narwhals>=1.5.2 in c:\\programdata\\anaconda3\\lib\\site-packages (from altair<6,>=4.0->streamlit) (1.8.0)\n",
|
42 |
+
"Requirement already satisfied: jsonschema>=3.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from altair<6,>=4.0->streamlit) (3.2.0)\n",
|
43 |
+
"Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from rich<14,>=10.14.0->streamlit) (2.18.0)\n",
|
44 |
+
"Requirement already satisfied: markdown-it-py>=2.2.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from rich<14,>=10.14.0->streamlit) (3.0.0)\n",
|
45 |
+
"Requirement already satisfied: gitdb<5,>=4.0.1 in c:\\programdata\\anaconda3\\lib\\site-packages (from gitpython!=3.1.19,<4,>=3.0.7->streamlit) (4.0.11)\n",
|
46 |
+
"Requirement already satisfied: MarkupSafe>=0.23 in c:\\programdata\\anaconda3\\lib\\site-packages (from jinja2>=2.10.1->pydeck<1,>=0.8.0b4->streamlit) (1.1.1)\n",
|
47 |
+
"Requirement already satisfied: six>=1.5 in c:\\programdata\\anaconda3\\lib\\site-packages (from python-dateutil>=2.8.2->pandas<3,>=1.3.0->streamlit) (1.15.0)\n",
|
48 |
+
"Requirement already satisfied: attrs>=17.4.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (20.3.0)\n",
|
49 |
+
"Requirement already satisfied: setuptools in c:\\programdata\\anaconda3\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (50.3.1.post20201107)\n",
|
50 |
+
"Requirement already satisfied: pyrsistent>=0.14.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from jsonschema>=3.0->altair<6,>=4.0->streamlit) (0.17.3)\n",
|
51 |
+
"Requirement already satisfied: mdurl~=0.1 in c:\\programdata\\anaconda3\\lib\\site-packages (from markdown-it-py>=2.2.0->rich<14,>=10.14.0->streamlit) (0.1.2)\n",
|
52 |
+
"Requirement already satisfied: smmap<6,>=3.0.1 in c:\\programdata\\anaconda3\\lib\\site-packages (from gitdb<5,>=4.0.1->gitpython!=3.1.19,<4,>=3.0.7->streamlit) (5.0.1)\n"
|
53 |
+
]
|
54 |
+
}
|
55 |
+
],
|
56 |
+
"source": [
|
57 |
+
"pip install streamlit requests"
|
58 |
+
]
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"cell_type": "code",
|
62 |
+
"execution_count": 5,
|
63 |
+
"metadata": {},
|
64 |
+
"outputs": [],
|
65 |
+
"source": [
|
66 |
+
"import requests\n",
|
67 |
+
"\n",
|
68 |
+
"def get_groq_response(prompt, api_key):\n",
|
69 |
+
" url = \"https://api.groq.com/inference\" # Replace with actual Groq API endpoint\n",
|
70 |
+
" headers = {\"Authorization\": f\"Bearer {api_key}\", \"Content-Type\": \"application/json\"}\n",
|
71 |
+
" data = {\"input\": prompt}\n",
|
72 |
+
" \n",
|
73 |
+
" response = requests.post(url, headers=headers, json=data)\n",
|
74 |
+
" if response.status_code == 200:\n",
|
75 |
+
" return response.json().get(\"output\", \"No response\")\n",
|
76 |
+
" else:\n",
|
77 |
+
" return f\"Error: {response.status_code}, {response.text}\"\n"
|
78 |
+
]
|
79 |
+
},
|
80 |
+
{
|
81 |
+
"cell_type": "code",
|
82 |
+
"execution_count": null,
|
83 |
+
"metadata": {},
|
84 |
+
"outputs": [],
|
85 |
+
"source": []
|
86 |
+
}
|
87 |
+
],
|
88 |
+
"metadata": {
|
89 |
+
"kernelspec": {
|
90 |
+
"display_name": "Python 3",
|
91 |
+
"language": "python",
|
92 |
+
"name": "python3"
|
93 |
+
},
|
94 |
+
"language_info": {
|
95 |
+
"codemirror_mode": {
|
96 |
+
"name": "ipython",
|
97 |
+
"version": 3
|
98 |
+
},
|
99 |
+
"file_extension": ".py",
|
100 |
+
"mimetype": "text/x-python",
|
101 |
+
"name": "python",
|
102 |
+
"nbconvert_exporter": "python",
|
103 |
+
"pygments_lexer": "ipython3",
|
104 |
+
"version": "3.8.5"
|
105 |
+
}
|
106 |
+
},
|
107 |
+
"nbformat": 4,
|
108 |
+
"nbformat_minor": 4
|
109 |
+
}
|