Skip to content

Commit 94e752c

Browse files
committed
Address PR feedback
1 parent ba790d8 commit 94e752c

File tree

2 files changed

+119
-119
lines changed

2 files changed

+119
-119
lines changed

docs/anthropic.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,36 +106,36 @@ to run your AI queries:
106106
DB_URL="your connection string"
107107
```
108108
109-
1. Pass your API key as a parameter to your queries:
109+
3. Pass your API key as a parameter to your queries:
110110
111-
```python
112-
import os
113-
from dotenv import load_dotenv
111+
```python
112+
import os
113+
from dotenv import load_dotenv
114114
115-
load_dotenv()
115+
load_dotenv()
116116
117-
ANTHROPIC_API_KEY = os.environ["ANTHROPIC_API_KEY"]
118-
DB_URL = os.environ["DB_URL"]
117+
ANTHROPIC_API_KEY = os.environ["ANTHROPIC_API_KEY"]
118+
DB_URL = os.environ["DB_URL"]
119119
120-
import psycopg2
121-
from psycopg2.extras import Json
120+
import psycopg2
121+
from psycopg2.extras import Json
122122
123-
messages = [{'role': 'user', 'content': 'Name five famous people from Birmingham, Alabama.'}]
123+
messages = [{'role': 'user', 'content': 'Name five famous people from Birmingham, Alabama.'}]
124124
125-
with psycopg2.connect(DB_URL) as conn:
126-
with conn.cursor() as cur:
127-
# pass the API key as a parameter to the query. don't use string manipulations
128-
cur.execute("""
129-
SELECT anthropic_generate
130-
( 'claude-3-5-sonnet-20240620'
131-
, %s
132-
, _api_key=>%s
133-
)
134-
""", (Json(messages), ANTHROPIC_API_KEY))
135-
records = cur.fetchall()
136-
```
137-
138-
Do not use string manipulation to embed the key as a literal in the SQL query.
125+
with psycopg2.connect(DB_URL) as conn:
126+
with conn.cursor() as cur:
127+
# pass the API key as a parameter to the query. don't use string manipulations
128+
cur.execute("""
129+
SELECT anthropic_generate
130+
( 'claude-3-5-sonnet-20240620'
131+
, %s
132+
, _api_key=>%s
133+
)
134+
""", (Json(messages), ANTHROPIC_API_KEY))
135+
records = cur.fetchall()
136+
```
137+
138+
Do not use string manipulation to embed the key as a literal in the SQL query.
139139
140140
## Usage
141141

docs/cohere.md

Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,34 @@ to run your AI queries:
9999
DB_URL="your connection string"
100100
```
101101

102-
1. Pass your API key as a parameter to your queries:
102+
3. Pass your API key as a parameter to your queries:
103103

104-
```python
105-
import os
106-
from dotenv import load_dotenv
104+
```python
105+
import os
106+
from dotenv import load_dotenv
107107
108-
load_dotenv()
108+
load_dotenv()
109109
110-
COHERE_API_KEY = os.environ["COHERE_API_KEY"]
111-
DB_URL = os.environ["DB_URL"]
110+
COHERE_API_KEY = os.environ["COHERE_API_KEY"]
111+
DB_URL = os.environ["DB_URL"]
112112
113-
import psycopg2
113+
import psycopg2
114114
115-
with psycopg2.connect(DB_URL) as conn:
116-
with conn.cursor() as cur:
117-
# pass the API key as a parameter to the query. don't use string manipulations
118-
cur.execute("""
119-
SELECT cohere_chat_complete
120-
( 'command-r-plus'
121-
, 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?'
122-
, _api_key=>%s
123-
, _seed=>42
124-
)->>'text'
125-
""", (COHERE_API_KEY, ))
126-
records = cur.fetchall()
127-
```
128-
129-
Do not use string manipulation to embed the key as a literal in the SQL query.
115+
with psycopg2.connect(DB_URL) as conn:
116+
with conn.cursor() as cur:
117+
# pass the API key as a parameter to the query. don't use string manipulations
118+
cur.execute("""
119+
SELECT cohere_chat_complete
120+
( 'command-r-plus'
121+
, 'How much wood would a woodchuck chuck if a woodchuck could chuck wood?'
122+
, _api_key=>%s
123+
, _seed=>42
124+
)->>'text'
125+
""", (COHERE_API_KEY, ))
126+
records = cur.fetchall()
127+
```
128+
129+
Do not use string manipulation to embed the key as a literal in the SQL query.
130130

131131
## Usage
132132

@@ -144,78 +144,78 @@ This section shows you how to use AI directly from your database using SQL.
144144

145145
### cohere_list_models
146146

147-
List the models supported by the Cohere platform.
148-
149-
```sql
150-
select *
151-
from cohere_list_models()
152-
;
153-
```
154-
155-
Results:
156-
157-
```text
158-
name | endpoints | finetuned | context_length | tokenizer_url | default_endpoints
159-
-------------------------------+---------------------------+-----------+----------------+--------------------------------------------------------------------------------------------+-------------------
160-
embed-english-light-v2.0 | {embed,classify} | f | 512 | | {}
161-
embed-english-v2.0 | {embed,classify} | f | 512 | | {}
162-
command-r | {generate,chat,summarize} | f | 128000 | https://storage.googleapis.com/cohere-public/tokenizers/command-r.json | {}
163-
embed-multilingual-light-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-light-v3.0.json | {}
164-
command-nightly | {generate,chat,summarize} | f | 128000 | https://storage.googleapis.com/cohere-public/tokenizers/command-nightly.json | {}
165-
command-r-plus | {generate,chat,summarize} | f | 128000 | https://storage.googleapis.com/cohere-public/tokenizers/command-r-plus.json | {chat}
166-
embed-multilingual-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-v3.0.json | {}
167-
embed-multilingual-v2.0 | {embed,classify} | f | 256 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-v2.0.json | {}
168-
c4ai-aya-23 | {generate,chat} | f | 8192 | https://storage.googleapis.com/cohere-public/tokenizers/c4ai-aya-23.json | {}
169-
command-light-nightly | {generate,summarize,chat} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/command-light-nightly.json | {}
170-
rerank-multilingual-v2.0 | {rerank} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/rerank-multilingual-v2.0.json | {}
171-
embed-english-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-english-v3.0.json | {}
172-
command | {generate,summarize,chat} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/command.json | {generate}
173-
rerank-multilingual-v3.0 | {rerank} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/rerank-multilingual-v3.0.json | {}
174-
rerank-english-v2.0 | {rerank} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/rerank-english-v2.0.json | {}
175-
command-light | {generate,summarize,chat} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/command-light.json | {}
176-
rerank-english-v3.0 | {rerank} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/rerank-english-v3.0.json | {}
177-
embed-english-light-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-english-light-v3.0.json | {}
178-
(18 rows)
179-
```
180-
181-
List the models on the Cohere platform that support a particular endpoint.
182-
183-
```sql
184-
select *
185-
from cohere_list_models(_endpoint=>'embed')
186-
;
187-
```
188-
189-
Results
190-
191-
```text
192-
name | endpoints | finetuned | context_length | tokenizer_url | default_endpoints
193-
-------------------------------+------------------+-----------+----------------+--------------------------------------------------------------------------------------------+-------------------
194-
embed-english-light-v2.0 | {embed,classify} | f | 512 | | {}
195-
embed-english-v2.0 | {embed,classify} | f | 512 | | {}
196-
embed-multilingual-light-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-light-v3.0.json | {}
197-
embed-multilingual-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-v3.0.json | {}
198-
embed-multilingual-v2.0 | {embed,classify} | f | 256 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-v2.0.json | {}
199-
embed-english-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-english-v3.0.json | {}
200-
embed-english-light-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-english-light-v3.0.json | {}
201-
(7 rows)
202-
```
203-
204-
List the default model for a given endpoint.
205-
206-
```sql
207-
select *
208-
from cohere_list_models(_endpoint=>'generate', _default_only=>true);
209-
```
210-
211-
Results
212-
213-
```text
214-
name | endpoints | finetuned | context_length | tokenizer_url | default_endpoints
215-
---------+---------------------------+-----------+----------------+----------------------------------------------------------------------+-------------------
216-
command | {generate,summarize,chat} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/command.json | {generate}
217-
(1 row)
218-
```
147+
* List the models supported by the Cohere platform.
148+
149+
```sql
150+
select *
151+
from cohere_list_models()
152+
;
153+
```
154+
155+
Results:
156+
157+
```text
158+
name | endpoints | finetuned | context_length | tokenizer_url | default_endpoints
159+
-------------------------------+---------------------------+-----------+----------------+--------------------------------------------------------------------------------------------+-------------------
160+
embed-english-light-v2.0 | {embed,classify} | f | 512 | | {}
161+
embed-english-v2.0 | {embed,classify} | f | 512 | | {}
162+
command-r | {generate,chat,summarize} | f | 128000 | https://storage.googleapis.com/cohere-public/tokenizers/command-r.json | {}
163+
embed-multilingual-light-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-light-v3.0.json | {}
164+
command-nightly | {generate,chat,summarize} | f | 128000 | https://storage.googleapis.com/cohere-public/tokenizers/command-nightly.json | {}
165+
command-r-plus | {generate,chat,summarize} | f | 128000 | https://storage.googleapis.com/cohere-public/tokenizers/command-r-plus.json | {chat}
166+
embed-multilingual-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-v3.0.json | {}
167+
embed-multilingual-v2.0 | {embed,classify} | f | 256 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-v2.0.json | {}
168+
c4ai-aya-23 | {generate,chat} | f | 8192 | https://storage.googleapis.com/cohere-public/tokenizers/c4ai-aya-23.json | {}
169+
command-light-nightly | {generate,summarize,chat} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/command-light-nightly.json | {}
170+
rerank-multilingual-v2.0 | {rerank} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/rerank-multilingual-v2.0.json | {}
171+
embed-english-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-english-v3.0.json | {}
172+
command | {generate,summarize,chat} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/command.json | {generate}
173+
rerank-multilingual-v3.0 | {rerank} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/rerank-multilingual-v3.0.json | {}
174+
rerank-english-v2.0 | {rerank} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/rerank-english-v2.0.json | {}
175+
command-light | {generate,summarize,chat} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/command-light.json | {}
176+
rerank-english-v3.0 | {rerank} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/rerank-english-v3.0.json | {}
177+
embed-english-light-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-english-light-v3.0.json | {}
178+
(18 rows)
179+
```
180+
181+
* List the models on the Cohere platform that support a particular endpoint.
182+
183+
```sql
184+
select *
185+
from cohere_list_models(_endpoint=>'embed')
186+
;
187+
```
188+
189+
Results
190+
191+
```text
192+
name | endpoints | finetuned | context_length | tokenizer_url | default_endpoints
193+
-------------------------------+------------------+-----------+----------------+--------------------------------------------------------------------------------------------+-------------------
194+
embed-english-light-v2.0 | {embed,classify} | f | 512 | | {}
195+
embed-english-v2.0 | {embed,classify} | f | 512 | | {}
196+
embed-multilingual-light-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-light-v3.0.json | {}
197+
embed-multilingual-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-v3.0.json | {}
198+
embed-multilingual-v2.0 | {embed,classify} | f | 256 | https://storage.googleapis.com/cohere-public/tokenizers/embed-multilingual-v2.0.json | {}
199+
embed-english-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-english-v3.0.json | {}
200+
embed-english-light-v3.0 | {embed,classify} | f | 512 | https://storage.googleapis.com/cohere-public/tokenizers/embed-english-light-v3.0.json | {}
201+
(7 rows)
202+
```
203+
204+
* List the default model for a given endpoint.
205+
206+
```sql
207+
select *
208+
from cohere_list_models(_endpoint=>'generate', _default_only=>true);
209+
```
210+
211+
Results
212+
213+
```text
214+
name | endpoints | finetuned | context_length | tokenizer_url | default_endpoints
215+
---------+---------------------------+-----------+----------------+----------------------------------------------------------------------+-------------------
216+
command | {generate,summarize,chat} | f | 4096 | https://storage.googleapis.com/cohere-public/tokenizers/command.json | {generate}
217+
(1 row)
218+
```
219219
220220
### cohere_tokenize
221221

0 commit comments

Comments
 (0)