From 5f1612554c800c129c5de5f7af9dead757434209 Mon Sep 17 00:00:00 2001 From: Ariel Weinberger Date: Thu, 23 Nov 2023 21:04:33 -0800 Subject: [PATCH] feat(docs): update to include pezzo proxy --- docs/client/request-caching.mdx | 27 ++++- .../docker-compose.mdx | 2 +- .../tutorial-observability/overview.mdx | 113 ++++++++---------- .../tutorial-prompt-management/overview.mdx | 19 +-- docs/introduction/what-is-pezzo.mdx | 17 +-- docs/mint.json | 22 +--- docs/platform/observability/metrics.mdx | 19 --- docs/platform/observability/overview.mdx | 43 ++++++- docs/platform/observability/requests.mdx | 28 ----- docs/platform/proxy/overview.mdx | 35 ++++++ 10 files changed, 166 insertions(+), 159 deletions(-) rename docs/{introduction => deployment}/docker-compose.mdx (96%) delete mode 100644 docs/platform/observability/metrics.mdx delete mode 100644 docs/platform/observability/requests.mdx create mode 100644 docs/platform/proxy/overview.mdx diff --git a/docs/client/request-caching.mdx b/docs/client/request-caching.mdx index e847a16b..16c6f73b 100644 --- a/docs/client/request-caching.mdx +++ b/docs/client/request-caching.mdx @@ -11,8 +11,10 @@ Utilizing caching can sometimes reduce your development costs and execution time ## Usage -To enable caching, simply set `cache: enabled` in the Pezzo Options parameter. Here is an example: +To enable caching, simply set the `X-Pezzo-Cache-Enabled: true` header. Here is an example: + + ```ts const response = await openai.chat.completions.create({ model: "gpt-3.5-turbo", @@ -23,9 +25,30 @@ const response = await openai.chat.completions.create({ } ] }, { - cache: true + headers: { + "X-Pezzo-Cache-Enabled": true, + } }); + +``` + + +```py +chat_completion = openai.chat.completions.create( + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "Tell me 5 fun facts about yourself", + } + ], + headers={ + "X-Pezzo-Cache-Enabled": "true" + } +) ``` + + ## Cached Requests in the Console diff --git a/docs/introduction/docker-compose.mdx b/docs/deployment/docker-compose.mdx similarity index 96% rename from docs/introduction/docker-compose.mdx rename to docs/deployment/docker-compose.mdx index c7909714..5a7a8e06 100644 --- a/docs/introduction/docker-compose.mdx +++ b/docs/deployment/docker-compose.mdx @@ -1,5 +1,5 @@ --- -title: "Running With Docker Compose" +title: "Docker Compose" description: "Learn how to run the full Pezzo stack locally with Docker Compose." --- diff --git a/docs/introduction/tutorial-observability/overview.mdx b/docs/introduction/tutorial-observability/overview.mdx index 889ab307..09651854 100644 --- a/docs/introduction/tutorial-observability/overview.mdx +++ b/docs/introduction/tutorial-observability/overview.mdx @@ -3,30 +3,6 @@ title: "Tutorial: Observability" description: "In just a few lines of code, monitor your AI operations seamlessly." --- - -This tutorial is for users who want to use Pezzo for observability and monitoring only. - -If you also want to use Pezzo to manage your prompts, version control and prompt deployment, check out the [Prompt Management tutorial](/introduction/tutorial-prompt-management/overview). - - -**Prefer a video tutorial?** We've prepared a 5-minute video for you! If you want to see the code example, [it's available on Codesandbox](https://codesandbox.io/p/sandbox/pezzo-example-observability-6d2qp6?file=%2Fsrc%2Fapp.ts%3A1%2C1). - - -
- -
- ## What you'll learn You're going to learn how to easily use Pezzo to supercharge your AI operations with monitoring and observability. It takes just a few lines of code! @@ -37,31 +13,25 @@ You're going to learn how to easily use Pezzo to supercharge your AI operations Cloud](https://app.pezzo.ai). -## Install depdendencies - -Install the Pezzo Client and the OpenAI SDK: - -```bash -npm i @pezzo/client openai -``` - -## Making calls to OpenAI +## Using Pezzo with OpenAI Here is a code example: -```ts app.ts -import { Pezzo, PezzoOpenAI } from "@pezzo/client"; + + +```ts +import OpenAI from "openai"; // Initialize the Pezzo client -const pezzo = new Pezzo({ - apiKey: "", - projectId: "", - environment: "Production", +const openai = new OpenAI({ + baseURL: "https://proxy.pezzo.ai/openai/v1", + defaultHeaders: { + "X-Pezzo-Api-Key": "", + "X-Pezzo-Project-Id": "", + "X-Pezzo-Environment": "Production", + } }); -// Initialize the OpenAI client -const openai = new PezzoOpenAI(pezzo); - async function main() { // Make calls to the OpenAI API as you normally would! const completion = await openai.chat.completions.create( @@ -71,37 +41,48 @@ async function main() { messages: [ { role: "user", - content: "Tell me {numFacts} fun facts about {topic}", + content: "Tell me 5 fun facts about yourself", }, ], - }, - { - variables: { - // You can define variables that will be interpolated during execution. - numFacts: 3, - topic: "Artificial Intelligence", - }, - properties: { - // You can optionally specify custom properties that will be associated with the request. - someProperty: "someValue", - }, } ); } main(); - ``` + + +```py +import openai + +openai.base_url = "https://proxy.pezzo.ai/openai/v1" +openai.default_headers = { + "X-Pezzo-Api-Key": "", + "X-Pezzo-Project-Id": "", + "X-Pezzo-Environment": "Production" +} -[Click here to run this example on CodeSandbox](https://codesandbox.io/p/sandbox/pezzo-example-observability-6d2qp6?file=%2Fsrc%2Fapp.ts%3A1%2C1) +chat_completion = openai.chat.completions.create( + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "Tell me 5 fun facts about yourself", + } + ] +) +``` + + **Let's explain what's going on here:** -- First, we initialize the Pezzo client and the OpenAI client. We pass the Pezzo client to the OpenAI client so it can use it to fetch the prompt. -- Then, we make a call to the OpenAI API as we normally would. -- (Optional) We specify additional parameters in the second argument, these are `variables` and `properties`. +We import and instantiate the OpenAI client with a few additional parameters. First, the `baseURL` which tells the OpenAI client to proxy the request through Pezzo. -The result will go directly to OpenAI and the response will be reported to Pezzo. +Then, we set a few default headers that will be present at any request made to OpenAI. These are: +- `X-Pezzo-Api-Key` - Your Pezzo API key. You can find it in your Organization page in [Pezzo Cloud](https://app.pezzo.ai). +- `X-Pezzo-Project-Id` - The ID of the project you want to use. You can find it anywhere [Pezzo Cloud](https://app.pezzo.ai). +- `X-Pezzo-Environment` - The name of the environment to use. By default, any Pezzo project is automatically created with a `Production` environment. ## Monitoring Requests @@ -112,3 +93,15 @@ If you want to learn more about Pezzo's observability feature, check out the [Ob + +# Next Steps + + + + Save up to 90% of your AI costs with Pezzo's request caching. + + diff --git a/docs/introduction/tutorial-prompt-management/overview.mdx b/docs/introduction/tutorial-prompt-management/overview.mdx index 3902ca64..2cd437d9 100644 --- a/docs/introduction/tutorial-prompt-management/overview.mdx +++ b/docs/introduction/tutorial-prompt-management/overview.mdx @@ -8,23 +8,6 @@ This tutorial is for users who want to manage their AI operations in Pezzo end-t If you wish to only use Pezzo for monitoring and observability, check out the [Observability Tutorial](/introduction/tutorial-observability/overview). -**Prefer a video tutorial?** We've prepared a 5-minute video for you! If you want to see the code example, [it's available on Codesandbox](https://codesandbox.io/p/sandbox/pezzo-example-prompt-management-qv5f86?file=%2Fsrc%2Fapp.ts%3A1%2C1). - -
- -
- ## What you'll learn You're going to learn how to manage your AI prompts with Pezzo, so you can streamline delivery and collaborate with your team. This includes: @@ -149,7 +132,7 @@ npm i @pezzo/client openai Here is a code example: -```ts app.ts +```ts Node.js import { Pezzo, PezzoOpenAI } from "@pezzo/client"; // Initialize the Pezzo client diff --git a/docs/introduction/what-is-pezzo.mdx b/docs/introduction/what-is-pezzo.mdx index 178f0803..efc310f5 100644 --- a/docs/introduction/what-is-pezzo.mdx +++ b/docs/introduction/what-is-pezzo.mdx @@ -22,24 +22,17 @@ Pezzo is a powerful open-source toolkit designed to streamline the process of AI # Next Steps - Learn about Pezzo's robust observability features. + Learn about Pezzo's robust observability & monitoring features. Learn how you can streamline your AI delivery with Pezzo. - - Get started with Pezzo and OpenAI in 5 minutes. - diff --git a/docs/mint.json b/docs/mint.json index 8cf0d8e1..83d35b20 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -36,35 +36,25 @@ "group": "Getting Started", "pages": [ "introduction/what-is-pezzo", - "introduction/tutorial-prompt-management/overview", "introduction/tutorial-observability/overview", - "introduction/docker-compose" + "introduction/tutorial-prompt-management/overview" ] }, { - "group": "Observability", + "group": "Features", "pages": [ + "platform/proxy/overview", "platform/observability/overview", - "platform/observability/requests", - "platform/observability/metrics" - ] - }, - { - "group": "Prompt Management", - "pages": [ - "platform/prompt-management/overview", + "client/request-caching", "platform/prompt-management/environments", "platform/prompt-management/prompt-editor", "platform/prompt-management/versioning-and-deployments" ] }, { - "group": "Pezzo SDK", + "group": "Deployment", "pages": [ - "client/pezzo-client-node", - "client/pezzo-client-python", - "client/integrations/openai", - "client/request-caching" + "deployment/docker-compose" ] }, { diff --git a/docs/platform/observability/metrics.mdx b/docs/platform/observability/metrics.mdx deleted file mode 100644 index 4d3f3adf..00000000 --- a/docs/platform/observability/metrics.mdx +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: 'Metrics' ---- -Pezzo provides a rich set of metrics to help you understand your Generative AI performance. - -# Prompt Metrics - - -We are in the process of moving the Metrics view to be at the Project level. Until then, Metrics are only available for users who manage their prompts with Pezzo. [Learn more about Prompt Management with Pezzo](/platform/prompt-management). - - -If you feel that there are metrics that are missing, please let us know by [creating an issue on GitHub](https://github.com/pezzolabs/pezzo/issues). - - -If you manage your prompts with Pezzo, you are able to view insights and metrics for a specific prompt. - - - - \ No newline at end of file diff --git a/docs/platform/observability/overview.mdx b/docs/platform/observability/overview.mdx index ba89ac69..7247380a 100644 --- a/docs/platform/observability/overview.mdx +++ b/docs/platform/observability/overview.mdx @@ -1,10 +1,47 @@ --- -title: 'Observability Overview' -sidebarTitle: 'Overview' +title: 'Monitoring & Observability' --- Pezzo enabels you to easily observe your Geneartive AI operations. This includes: - **Traces and Requests** - Pezzo automatically traces your operations and requests and provides you with a detailed view of the execution of your operations. - **Advanced Filtering** - Filter your traces and requests by any field, including custom fields (e.g. user ID, correlation ID, etc). - **Metrics** - Pezzo automatically collects metrics from your LLM calls (execution time, cost, error rate, and more) and provides you with detailed dashboards. -- **Alerts** *(Coming Soon)* - Define alerts on your metrics and get notified when something goes wrong. \ No newline at end of file +- **Alerts** *(Coming Soon)* - Define alerts on your metrics and get notified when something goes wrong. + +Observe your Generative AI operations with Pezzo. + +# Requests View + +Every project on Pezzo has a dedicated Requests view. This view shows you all the requests that have been made to your project. + + + + + +## Filters + +You can filter requests by various criteria. For example, you can filter by the status of the request, by date/time, or by the cost of execution. + + + + + +## Inspector + +You can inspect the details of any request by clicking on it. This will open the Inspector view. + + + + + +# Prompt Metrics + + +If you feel that there are metrics that are missing, please let us know by [creating an issue on GitHub](https://github.com/pezzolabs/pezzo/issues). + + +If you manage your prompts with Pezzo, you are able to view insights and metrics for a specific prompt. + + + + \ No newline at end of file diff --git a/docs/platform/observability/requests.mdx b/docs/platform/observability/requests.mdx deleted file mode 100644 index 0034add2..00000000 --- a/docs/platform/observability/requests.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: 'Requests & Traces' ---- -Observe your Generative AI operations with Pezzo. - -# Requests View - -Every project on Pezzo has a dedicated Requests view. This view shows you all the requests that have been made to your project. - - - - - -## Filters - -You can filter requests by various criteria. For example, you can filter by the status of the request, by date/time, or by the cost of execution. - - - - - -## Inspector - -You can inspect the details of any request by clicking on it. This will open the Inspector view. - - - - \ No newline at end of file diff --git a/docs/platform/proxy/overview.mdx b/docs/platform/proxy/overview.mdx new file mode 100644 index 00000000..f9773d17 --- /dev/null +++ b/docs/platform/proxy/overview.mdx @@ -0,0 +1,35 @@ +--- +title: 'Pezzo Proxy' +--- + +# What is the Pezzo Proxy? + +The Pezzo Proxy is a proxy server that can be used to automatically proxy requests to LLMs through Pezzo. + +Contrary to other solutions that force you to install SDKs and change the way you write code, we chose to build a proxy that can be used with any existing codebase. Here is why: + +- **Easy to integrate:** It allows you to integrate Pezzo into your codebase with zero changes to your LLM consumption code. +- **Always up-to-date:** The proxy will never prevent you from using new features released by OpenAI. As soon as OpenAI releases new feautres, they are immediately supported by Pezzo. +- **Language agnostic:** Whether you use Node.js, Python, Golang or any other language - Pezzo Proxy supports them all! +- **Enhanced LLM capabilities:** The proxy layer allows us to build powerful features on top of LLMs, for example a caching layer that allows you to save money on your API calls. +- **Maintainable:** We are able to push fixes to the Pezzo Proxy without requiring you to update any integration in your code base. It's completely transparent. + +# Is the Pezzo Proxy open source? + +Yes! As with any component at Pezzo, the Pezzo Proxy is open source under Apache 2.0 license. + +For more information, you can refer to: + +- [Pezzo Proxy source coude on GitHub](https://github.com/pezzolabs/pezzo/tree/main/apps/proxy) +- [Pezzo Proxy container on GitHub container registry](https://github.com/pezzolabs/pezzo/pkgs/container/pezzo%2Fproxy) + +# Next Steps + + + Learn about Pezzo's robust observability & monitoring features. + +