Skip to content

Commit db934fd

Browse files
committed
Iterate
1 parent 83ad1b6 commit db934fd

File tree

4 files changed

+181
-5
lines changed

4 files changed

+181
-5
lines changed

.github/actions/post-merge-additions/process-additions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
print(notebook)
1212

1313
pc = Pinecone()
14-
idx = pc.Index(name='arjun-project') # TODO: adjust for arjun project
1514

1615
# TODO: add embeddings related to new notebook

.github/actions/post-merge-deletions/process-deletions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@
88

99
pc = Pinecone()
1010

11-
idx = pc.Index(name='arjun-project') # TODO: adjust for arjun project
12-
1311
# TODO: remove embeddings related to deleted notebook

.github/actions/post-merge-modifications/process-modifications.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212

1313
pc = Pinecone()
1414

15-
idx = pc.Index(name='arjun-project') # TODO: adjust for arjun project
16-
1715
# TODO: update embeddings to reflect new contents of notebook
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"id": "IpHsLVa0mAJe"
7+
},
8+
"source": [
9+
"# Pinecone Assistant Getting Started\n",
10+
"\n",
11+
"Welcome to the getting started Notebook for [Pinecone assistant](https://www.pinecone.io/blog/pinecone-assistant/)!"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": null,
17+
"metadata": {
18+
"id": "v6cdZP0ylfC5"
19+
},
20+
"outputs": [],
21+
"source": [
22+
"# Install Pinecone notebook utilities including the Pinecone Connect widget\n",
23+
"!pip install pinecone==6.0.2"
24+
]
25+
},
26+
{
27+
"cell_type": "code",
28+
"execution_count": null,
29+
"metadata": {
30+
"id": "HO8ass1Qmdgq"
31+
},
32+
"outputs": [],
33+
"source": [
34+
"import os\n",
35+
"\n",
36+
"if not os.environ.get(\"PINECONE_API_KEY\"):\n",
37+
" from pinecone_notebooks.colab import Authenticate\n",
38+
" Authenticate()"
39+
]
40+
},
41+
{
42+
"cell_type": "markdown",
43+
"metadata": {
44+
"id": "lixB5GGnmAHv"
45+
},
46+
"source": []
47+
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": null,
51+
"metadata": {
52+
"id": "unDcuyR2EaJr"
53+
},
54+
"outputs": [],
55+
"source": [
56+
"from google.colab import userdata\n",
57+
"from pinecone import Pinecone\n",
58+
"\n",
59+
"pc = Pinecone(api_key=os.environ.get('PINECONE_API_KEY') or userdata.get('PINECONE_API_KEY'))\n",
60+
"\n",
61+
"assistant_name = 'HelloPineconeAssistant'\n",
62+
"\n",
63+
"metadata = {\"author\": \"Jane Doe\", \"version\": \"1.0\"}\n",
64+
"\n",
65+
"assistant = pc.assistant.create_assistant(\n",
66+
" assistant_name=assistant_name,\n",
67+
" metadata=metadata,\n",
68+
" timeout=30 # Wait 30 seconds for assistant creation to complete.\n",
69+
")"
70+
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": null,
75+
"metadata": {
76+
"id": "HJ5fxLvY97yF"
77+
},
78+
"outputs": [],
79+
"source": [
80+
"# Get assistant status\n",
81+
"assistant_status = pc.assistant.describe_assistant(assistant_name=assistant_name)\n",
82+
"assistant_status"
83+
]
84+
},
85+
{
86+
"cell_type": "markdown",
87+
"metadata": {
88+
"id": "nIyz6gYqAbHn"
89+
},
90+
"source": [
91+
"Upload the toys.txt file from the repository to Google Colab:\n",
92+
"\n",
93+
"1. Click the folder icon in Google Colab's left rail <--\n",
94+
"2. Click the upload button and use the file picker to select `toys.txt` from the subdirectory of https://github.com/pinecone-io/examples that contains this notebook\n",
95+
"3. Run the next cell to upload the toys.txt file to your Pinecone assistant\n"
96+
]
97+
},
98+
{
99+
"cell_type": "code",
100+
"execution_count": null,
101+
"metadata": {
102+
"id": "CVixRBQfEKpo"
103+
},
104+
"outputs": [],
105+
"source": [
106+
"import os\n",
107+
"\n",
108+
"# Target our existing Pinecone Assistant\n",
109+
"assistant = pc.assistant.Assistant(\n",
110+
" assistant_name=assistant_name,\n",
111+
")\n",
112+
"\n",
113+
"file_path = '/content/toys.txt'\n",
114+
"\n",
115+
"# Upload the file\n",
116+
"if os.path.exists(file_path):\n",
117+
" response = assistant.upload_file(\n",
118+
" file_path=file_path,\n",
119+
" timeout=None\n",
120+
" )\n",
121+
" print(f\"Uploaded {file_path}\")\n",
122+
" print(\"Response:\", response)\n",
123+
"else:\n",
124+
" print(f\"File not found: {file_path}\")"
125+
]
126+
},
127+
{
128+
"cell_type": "code",
129+
"execution_count": null,
130+
"metadata": {
131+
"id": "fqYUFoZ8N487"
132+
},
133+
"outputs": [],
134+
"source": [
135+
"# List uploaded files our assistant is aware of\n",
136+
"files = assistant.list_files()\n",
137+
"files"
138+
]
139+
},
140+
{
141+
"cell_type": "code",
142+
"execution_count": null,
143+
"metadata": {
144+
"id": "iKLZtk7BOomq"
145+
},
146+
"outputs": [],
147+
"source": [
148+
"# Chat with your Pinecone assistant, which automatically references\n",
149+
"# your uploaded documents in its responses\n",
150+
"from pinecone_plugins.assistant.models.chat import Message\n",
151+
"chat_context = [Message(content='Which toys teach STEM skills?')]\n",
152+
"response = assistant.chat_completions(messages=chat_context)\n",
153+
"print(response)"
154+
]
155+
},
156+
{
157+
"cell_type": "code",
158+
"execution_count": null,
159+
"metadata": {
160+
"id": "GQKf1l3rOFhy"
161+
},
162+
"outputs": [],
163+
"source": []
164+
}
165+
],
166+
"metadata": {
167+
"colab": {
168+
"private_outputs": true,
169+
"provenance": []
170+
},
171+
"kernelspec": {
172+
"display_name": "Python 3",
173+
"name": "python3"
174+
},
175+
"language_info": {
176+
"name": "python"
177+
}
178+
},
179+
"nbformat": 4,
180+
"nbformat_minor": 0
181+
}

0 commit comments

Comments
 (0)