Skip to content

Commit

Permalink
fixing docs for pii and curl (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardan-bkennedy authored Jun 22, 2024
1 parent aab0ccb commit 93e9f75
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion fern/docs/pages/quick_start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Chat();

<CodeBlock title="cURL">
```bash
curl -il -X POST https://api.predictionguard.com/chat/completions \
curl -i -X POST https://api.predictionguard.com/chat/completions \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{ \
Expand Down
10 changes: 5 additions & 5 deletions fern/docs/pages/reference/PII.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ your preference or requirements, select the appropriate method for your applicat

prompt := "Hello, my name is John Doe and my SSN is 111-22-3333."

resp, err := cln.ReplacePI(ctx, prompt, client.ReplaceMethods.Mask)
resp, err := cln.ReplacePII(ctx, prompt, client.ReplaceMethods.Mask)
if err != nil {
return fmt.Errorf("ERROR: %w", err)
}
Expand Down Expand Up @@ -124,11 +124,11 @@ your preference or requirements, select the appropriate method for your applicat

const client = new pg.Client('https://api.predictionguard.com', process.env.PGKEY);

async function ReplacePI() {
async function ReplacePII() {
const replaceMethod = pg.ReplaceMethods.Mask;
const prompt = `Hello, my name is John Doe and my SSN is 111-22-3333.`;

var [result, err] = await client.ReplacePI(replaceMethod, prompt);
var [result, err] = await client.ReplacePII(replaceMethod, prompt);
if (err != null) {
console.log('ERROR:' + err.error);
return;
Expand All @@ -137,13 +137,13 @@ your preference or requirements, select the appropriate method for your applicat
console.log('RESULT:' + result.checks[0].new_prompt);
}

ReplacePI();
ReplacePII();
```
</CodeBlock>

<CodeBlock title="cURL">
```bash
curl -X POST https://api.predictionguard.com/PII \
curl -i -X POST https://api.predictionguard.com/PII \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/reference/chat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ your application.

<CodeBlock title="cURL">
```bash
curl -il -X POST https://api.predictionguard.com/chat/completions \
curl -i -X POST https://api.predictionguard.com/chat/completions \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/reference/chat_sse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ method for your application.

<CodeBlock title="cURL">
```bash
curl -il -X POST https://api.predictionguard.com/chat/completions \
curl -i -X POST https://api.predictionguard.com/chat/completions \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/reference/chat_vision.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ images that are base64 encoded represented by a data uri.
}
EOF

curl -il -X POST https://api.predictionguard.com/chat/completions \
curl -i -X POST https://api.predictionguard.com/chat/completions \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d @input.json
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/reference/completions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ on your preference or requirements, select the appropriate method for your appli

<CodeBlock title="cURL">
```bash
curl -il -X POST https://api.predictionguard.com/completions \
curl -i -X POST https://api.predictionguard.com/completions \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{
Expand Down
22 changes: 16 additions & 6 deletions fern/docs/pages/reference/embeddings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,30 @@ encoded in a base64 string.
```rust
extern crate prediction_guard as pg_client;

use pg_client::{client, embedding, models};
use pg_client::{client, embedding, image, models};

#[tokio::main]
async fn main() {
let pg_env = client::PgEnvironment::from_env().expect("env keys");

let img_str = match image::encode(
"https://farm4.staticflickr.com/3300/3497460990_11dfb95dd1_z.jpg".to_string(),
)
.await
{
Ok(s) => Some(s),
Err(_) => None,
};

let clt = client::Client::new(pg_env).expect("client value");

// Embedding request can contain text or an image. The image should be base64 encoded.
// Embedding request can contain text and/or an image. The image should be base64 encoded.
let req = embedding::Request::new(
models::Model::BridgetowerLargeItmMlmItc,
Some("Tell me a joke.".to_string()),
IMAGE.to_string(),
);
Some("skyline with a flying horse".to_string()),
img_str,
)
.await;

let result = clt.embedding(&req).await.expect("error from embeddings");

Expand Down Expand Up @@ -185,7 +195,7 @@ encoded in a base64 string.
}
EOF
curl -il -X POST https://api.predictionguard.com/embeddings \
curl -i -X POST https://api.predictionguard.com/embeddings \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d @input.json
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/reference/factuality.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ for your application.

<CodeBlock title="cURL">
```bash
curl -X POST https://api.predictionguard.com/factuality \
curl -i -X POST https://api.predictionguard.com/factuality \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/reference/injection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ your application.

<CodeBlock title="cURL">
```bash
curl -X POST https://api.predictionguard.com/injection \
curl -i -X POST https://api.predictionguard.com/injection \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/reference/toxicity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ on your preference or requirements, select the appropriate method for your appli

<CodeBlock title="cURL">
```bash
curl -X POST https://api.predictionguard.com/toxicity \
curl -i -X POST https://api.predictionguard.com/toxicity \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/reference/translate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ your preference or requirements, select the appropriate method for your applicat

<CodeBlock title="cURL">
```bash
curl -X POST https://api.predictionguard.com/translate \
curl -i -X POST https://api.predictionguard.com/translate \
-H "x-api-key: ${PGKEY}" \
-H "Content-Type: application/json" \
-d '{
Expand Down
2 changes: 1 addition & 1 deletion fern/docs/pages/sdks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ to get an access token.

You can find the SDK docs and package information using this link.

[Python SDK Docs](/docs/reference)
[Python SDK Docs](https://predictionguard.github.io/python-client/)

#### Python Code Example

Expand Down

0 comments on commit 93e9f75

Please sign in to comment.