Skip to content
Snippets Groups Projects
Unverified Commit 5c3a0191 authored by Jerry Liu's avatar Jerry Liu Committed by GitHub
Browse files

update pinecone nb default env (#309)

parent 85e0bcb7
Branches
No related tags found
No related merge requests found
%% Cell type:markdown id:307804a3-c02b-4a57-ac0d-172c30ddc851 tags: %% Cell type:markdown id:307804a3-c02b-4a57-ac0d-172c30ddc851 tags:
# Pinecone Index Demo # Pinecone Index Demo
%% Cell type:markdown id:f7010b1d-d1bb-4f08-9309-a328bb4ea396 tags: %% Cell type:markdown id:f7010b1d-d1bb-4f08-9309-a328bb4ea396 tags:
#### Creating a Pinecone Index #### Creating a Pinecone Index
%% Cell type:code id:0ce3143d-198c-4dd2-8e5a-c5cdf94f017a tags: %% Cell type:code id:0ce3143d-198c-4dd2-8e5a-c5cdf94f017a tags:
``` python ``` python
import pinecone import pinecone
``` ```
%% Cell type:code id:4ad14111-0bbb-4c62-906d-6d6253e0cdee tags: %% Cell type:code id:4ad14111-0bbb-4c62-906d-6d6253e0cdee tags:
``` python ``` python
api_key = "api_key" api_key = "api_key"
pinecone.init(api_key=api_key, environment="us-west1-gcp") pinecone.init(api_key=api_key, environment="us-east1-gcp")
``` ```
%% Cell type:code id:c2c90087-bdd9-4ca4-b06b-2af883559f88 tags: %% Cell type:code id:c2c90087-bdd9-4ca4-b06b-2af883559f88 tags:
``` python ``` python
# dimensions are for text-embedding-ada-002 # dimensions are for text-embedding-ada-002
pinecone.create_index("quickstart", dimension=1536, metric="euclidean", pod_type="p1") pinecone.create_index("quickstart", dimension=1536, metric="euclidean", pod_type="p1")
``` ```
%% Cell type:code id:667f3cb3-ce18-48d5-b9aa-bfc1a1f0f0f6 tags: %% Cell type:code id:667f3cb3-ce18-48d5-b9aa-bfc1a1f0f0f6 tags:
``` python ``` python
index = pinecone.Index("quickstart") index = pinecone.Index("quickstart")
``` ```
%% Cell type:markdown id:8ee4473a-094f-4d0a-a825-e1213db07240 tags: %% Cell type:markdown id:8ee4473a-094f-4d0a-a825-e1213db07240 tags:
#### Load documents, build the GPTPineconeIndex #### Load documents, build the GPTPineconeIndex
%% Cell type:code id:0a2bcc07 tags: %% Cell type:code id:0a2bcc07 tags:
``` python ``` python
from gpt_index import GPTPineconeIndex, SimpleDirectoryReader from gpt_index import GPTPineconeIndex, SimpleDirectoryReader
from IPython.display import Markdown, display from IPython.display import Markdown, display
``` ```
%% Cell type:code id:68cbd239-880e-41a3-98d8-dbb3fab55431 tags: %% Cell type:code id:68cbd239-880e-41a3-98d8-dbb3fab55431 tags:
``` python ``` python
# load documents # load documents
documents = SimpleDirectoryReader('../paul_graham_essay/data').load_data() documents = SimpleDirectoryReader('../paul_graham_essay/data').load_data()
``` ```
%% Cell type:code id:ba1558b3 tags: %% Cell type:code id:ba1558b3 tags:
``` python ``` python
index = GPTPineconeIndex(documents, pinecone_index=index) index = GPTPineconeIndex(documents, pinecone_index=index)
``` ```
%% Cell type:markdown id:04304299-fc3e-40a0-8600-f50c3292767e tags: %% Cell type:markdown id:04304299-fc3e-40a0-8600-f50c3292767e tags:
#### Query Index #### Query Index
%% Cell type:code id:35369eda tags: %% Cell type:code id:35369eda tags:
``` python ``` python
# try verbose=True for more detailed outputs # try verbose=True for more detailed outputs
response = index.query("What did the author do growing up?", verbose=True) response = index.query("What did the author do growing up?", verbose=True)
``` ```
%% Cell type:code id:bedbb693-725f-478f-be26-fa7180ea38b2 tags: %% Cell type:code id:bedbb693-725f-478f-be26-fa7180ea38b2 tags:
``` python ``` python
display(Markdown(f"<b>{response}</b>")) display(Markdown(f"<b>{response}</b>"))
``` ```
%% Output %% Output
<b> <b>
The author grew up writing short stories and programming on an IBM 1401. He also nagged his father to buy him a TRS-80 microcomputer, which he used to write simple games, a program to predict how high his model rockets would fly, and a word processor. He studied philosophy in college, but found it boring and switched to AI. He reverse-engineered SHRDLU for his undergraduate thesis and wrote a book about Lisp hacking while in grad school. He also worked on teaching himself Lisp, which he used to create a SHRDLU clone for his thesis. During the first year of grad school, he realized that AI, as practiced at the time, was a hoax and that there was an unbridgeable gap between what these programs could do and actually understanding natural language. He looked around to see what he could salvage from the wreckage of his plans, and there was Lisp. He decided to focus on Lisp and wrote a book about Lisp hacking, On Lisp, which was published in 1993. He also wanted to build things, so he pursued a career in Computer Science, an uneasy alliance between two halves, theory and systems.</b> The author grew up writing short stories and programming on an IBM 1401. He also nagged his father to buy him a TRS-80 microcomputer, which he used to write simple games, a program to predict how high his model rockets would fly, and a word processor. He studied philosophy in college, but found it boring and switched to AI. He reverse-engineered SHRDLU for his undergraduate thesis and wrote a book about Lisp hacking while in grad school. He also worked on teaching himself Lisp, which he used to create a SHRDLU clone for his thesis. During the first year of grad school, he realized that AI, as practiced at the time, was a hoax and that there was an unbridgeable gap between what these programs could do and actually understanding natural language. He looked around to see what he could salvage from the wreckage of his plans, and there was Lisp. He decided to focus on Lisp and wrote a book about Lisp hacking, On Lisp, which was published in 1993. He also wanted to build things, so he pursued a career in Computer Science, an uneasy alliance between two halves, theory and systems.</b>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment