Skip to content

Commit

Permalink
Merge pull request #19 from PromptSail/dev
Browse files Browse the repository at this point in the history
Alpha release
  • Loading branch information
ksopyla authored Feb 4, 2024
2 parents c921e37 + 6b678ae commit 53079bb
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 53 deletions.
32 changes: 15 additions & 17 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ name: Build and Publish Docker to ghcr
on:
push:
branches:
#- dev
- build-actions
- dev
# Publish semver tags as releases.
#tags: [ 'v*.*.*' ]
pull_request:
branches:
- build-actions
release:
types: [created]

env:
# Use docker.io for Docker Hub if empty
Expand Down Expand Up @@ -106,13 +104,13 @@ jobs:
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
uses: docker/setup-buildx-action@v3 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
uses: docker/login-action@v3 # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -122,20 +120,20 @@ jobs:
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
uses: docker/metadata-action@v5 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
uses: docker/build-push-action@v5 # v5.0.0
with:
context: ./backend
file: ./backend/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/promptsail/ps_backend_dev:${{ env.NOW }} #${{ steps.meta.outputs.tags }} #"ghcr.io/promptsail/dev-${{ env.NOW }}"
tags: ghcr.io/promptsail/promptsail-backend:${{ github.ref_name }}, ghcr.io/promptsail/promptsail-backend:${{ env.NOW }}, ghcr.io/promptsail/promptsail-backend:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -149,7 +147,7 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
TAGS: ${{ steps.build-and-push.outputs.tags }} # Use tags from build-and-push step
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
Expand Down Expand Up @@ -189,13 +187,13 @@ jobs:
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
uses: docker/setup-buildx-action@v3 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
uses: docker/login-action@v3 # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -205,20 +203,20 @@ jobs:
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
uses: docker/metadata-action@v5 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
uses: docker/build-push-action@v5 # v5.0.0
with:
context: ./ui
file: ./ui/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/promptsail/ps_ui_dev:${{ env.NOW }} #${{ steps.meta.outputs.tags }} #"ghcr.io/promptsail/dev-${{ env.NOW }}"
tags: ghcr.io/promptsail/promptsail-ui:${{ github.ref_name }}, ghcr.io/promptsail/promptsail-ui:${{ env.NOW }}, ghcr.io/promptsail/promptsail-ui:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -232,7 +230,7 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
TAGS: ${{ steps.build-and-push.outputs.tags }} # Use tags from build-and-push step
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
Expand Down
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Sets up all our shared environment variables
################################
FROM python:3.10.2-slim-buster as python-base
LABEL org.opencontainers.image.source="https://github.com/PromptSail/prompt_sail"

# python
ENV PYTHONUNBUFFERED=1 \
Expand Down
33 changes: 14 additions & 19 deletions docs/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,18 @@ docs:
url: /docs/quick-start-guide/
- title: "Project Setup"
url: /docs/how-to-setup-llm-proxy-project/
- title: 1- LLM proxy setup
- title: 1- LLM integrations
children:
- title: "LLM frameworks integration"
url: /docs/todo/
- title: "Input/output capturing"
url: /docs/todo/
- title: "Working with tags"
url: /docs/todo/
- title: "Working with experiments"
url: /docs/todo/
url: /docs/storing-transactions/
- title: "LLM frameworks integration"
url: /docs/llm-integrations/
- title: 2 - User UI Guide
children:
- title: "Organization Dashboard"
url: /docs/todo/
url: /docs/organization-dashboard/
- title: "Project Dashboard"
url: /docs/todo/
url: /docs/project-dashboard/
- title: "Transactions View"
url: /docs/todo/
- title: "Cost Analysis View"
Expand All @@ -49,19 +45,18 @@ docs:
- title: "Documentation"
url: /docs/how-to-write-documentation/
- title: "Repository Structure"
url: /docs/todo/
- title: "Dependency injection"
url: /docs/todo/
- title: "How revers proxies work"
url: /docs/todo/
url: /docs/repository-structure/
- title: "Code of Conduct"
url: /docs/code-of-conduct/
- title: "Contributing Guidelines"
url: /docs/contributing/



- title: 4 - About the project
children:
- title: "History"
url: /docs/history/
- title: "Contributing"
url: /docs/contributing/
- title: "Contributors"
url: /docs/contributors/
- title: "License"
url: /docs/license/
- title: "Terms & Privacy Policy"
Expand Down
11 changes: 3 additions & 8 deletions docs/_docs/00-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ For **Business owners** can ensure compliance with regulations and maintain gove
## Key Features

1. **Transparent Logging**
It captures and logs all interactions with LLM APIs, providing a comprehensive record of prompts and responses.
It captures and logs all interactions with LLM APIs, providing a comprehensive record of prompts and responses.

2. **Optimization and Analysis**
By providing a concise and detailed view of all interactions, developers can analyze and refine their prompts.
Expand All @@ -33,19 +33,14 @@ By providing a concise and detailed view of all interactions, developers can ana
Project managers can track and analyze the costs associated with each project and experiment, enabling better budget management.

4. **Compliance and Governance**

Empowers business owners to maintain control over instructions, chat messages, and other interactions with LLM APIs. This enables the implementation of standards and policies, identification of misuse, and detection of non-compliant content.


5. **Easy Integration**

Prompt Sail seamlessly integrates into your workflow and used libraries. Just modify the `base_url` parameter when creating your provider API object.

6. **Searchable Database*

All prompts and responses are stored in a searchable database, making finding and analyzing specific interactions easy. You can export the data for further analysis.
6. **Searchable Database**
All prompts and responses are stored in a MongoDB, making finding and analyzing specific interactions easy. You can export the data for further analysis.

7. **User-Friendly Interface**

Simple and intuitive UI lets you easily view and filter your transactions (prompts and responses) by project, API provider, LLM model, or tags.

11 changes: 6 additions & 5 deletions docs/_docs/01-quick-start-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ All of the above are set in the [docker-compose.yml](https://github.com/PromptSa

## Make your first API call

Folder [examples](https://github.com/PromptSail/prompt_sail/tree/docs/examples) and [LLM Integration]() section of the documentation contain more examples of how to make API calls to different LLM providers via Prompt Sail.
Folder [examples](https://github.com/PromptSail/prompt_sail/tree/docs/examples) and [LLM Integration](/docs/llm-integrations/) section of the documentation contain more examples of how to make API calls to different LLM providers via Prompt Sail.

### OpenAI
### OpenAI Chat model example

Based on [How to store transactions from OpenAI via OpenAI Python SDK](https://github.com/PromptSail/prompt_sail/blob/examples/examples/openai_sdk_openai.ipynb) notebook.


Create .evn file with your OpenAI API key and organization ID.
Expand Down Expand Up @@ -101,9 +103,8 @@ openai_org_id = os.getenv("OPENAI_ORG_ID")
Make an API call to OpenAI via Prompt Sail.

```python
api_base = "http://project1.promptsail.local"

# api_base = "http://localhost:8000/project1"
api_base = "http://localhost:8000/project1"

ps_client = OpenAI(
base_url=api_base,
Expand All @@ -127,4 +128,4 @@ response = ps_client.chat.completions.create(

pprint(response.choices[0].message)

``````
```
39 changes: 39 additions & 0 deletions docs/_docs/10-Input-output-proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: "How PromptSail stores transactions"
permalink: /docs/storing-transactions/
excerpt: "How all inputs and outputs are stored by PromptSail"
last_modified_at: 2024-01-04T18:48:05+01:00
redirect_from:
- /theme-setup/
toc: true

---


## Input/output proxy

Prompt Sail stores transactions by acting as a proxy for libraries and capturing the request and response data. This is done in the **store_transaction** function in the **src\transactions\use_cases.py** file.

All the magic happens thanks to properly prepared **base_url** with points to the prompt sail backend as a proxy

The url structure is as follows:

```
http://<prompt_sail_backend_url>/project_slug/ai_deployment/?tags=tag1,tag2,tag3
```

where:
* **project_slug** is a slugified project name, configured in the UI while creating a project
* **ai_deployment** is a slugified AI deployment name, configured in the project settings with the target AI provider api url eg. https://api.openai.com/v1/, you can configure multiple AI deployments for a single project
* **tags** is a comma-separated list of tags. This is optional and can be used to tag a transaction eg. with a specific experiment name, department, prompting technique etc. Tags can help you filter and analyze transactions in the UI.


Proxy on your behalf make a call to the configured AI API and log the request and response data in the database.

Transaction object is created with the following fields:

* `id`: The ID of the transaction.
* `project_id`: The ID of the project that the transaction belongs to.
* `request`: A dictionary that contains the original request data, including the method, URL, host, headers, extensions, and content.
* `response`: A dictionary that contains the response data, including the status code, headers, next request, error status, success status, content, elapsed time, and encoding.
* `query_params`: A dictionary that contains additional query parameters like tags.
33 changes: 33 additions & 0 deletions docs/_docs/11-LLM integrations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: "LLM integrations"
permalink: /docs/llm-integrations/
excerpt: "Integrations with most common LLM libraries and providers"
last_modified_at: 2024-01-04T18:18:15+01:00
redirect_from:
- /theme-setup/
toc: true

---


todo: Under construction

## Supported LLM libraries and providers

* [LangChain](#langchain-integration)
* [OpenAI](#openai-integration)


## OpenAI integration


### Chat models

### Embedding models


## Azure OpenAI integration

### Chat models

### Embedding models
35 changes: 35 additions & 0 deletions docs/_docs/21-Organization-Dashboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: "Organization Dashboard"
permalink: /docs/organization-dashboard/
excerpt: "The Organization Dashboard page serves as a central hub for managing projects within the organization"
last_modified_at: 2024-02-01T14:06:00+01:00
redirect_from:
- /theme-setup/
toc: true
---

The Organization Dashboard page serves as a central hub for managing projects within the organization. It provides users with easy access to all pertinent project information and enables quick searching and creation of new projects.
This page can be accessed at `localhost:80` after logging in to the application.

<img src='../assets/images/Organization_Dashboard.png' />

### Interface Elements:

- **Project List:**

- Displays a list of all projects belonging to the organization.
- Each project is represented by a container containing basic information such as name, description, tags, etc.
- Clicking on a project opens the Project Dashboard, where users can access detailed information and manage the project.

- **Search bar:**

- Allows users to quickly find a specific project by entering search criteria such as name, slug, description, or tags.
- Search is performed live, dynamically filtering the project list as the user types their query.

- **"New Project" Button:**
- Clicking the button opens the new project wizard, which guides the user through the process of creating a new project.
- The wizard enables users to specify all necessary information about the new project, such as name, description, tags, etc.

### Notes:

- The Organization Dashboard page serves as the starting point for users of the application, providing them with quick access to all essential project management functions.
27 changes: 27 additions & 0 deletions docs/_docs/22-Project-Dashboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: "Project Dashboard"
permalink: /docs/project-dashboard/
excerpt: "The Project Dashboard page provides detailed information about a specific project"
last_modified_at: 2024-02-01T15:36:00+01:00
redirect_from:
- /theme-setup/
toc: true
---

The Project Dashboard page provides detailed information about a specific project. The main container displays key project details such as name, description, slug, tags, list of AI providers, number of members, number of transactions, URL address utilizing the slug, which is used by `Promptsail` to add transactions.

### Buttons

- **Delete:** Displays a popup to delete the project.
- **Update:** Redirects to the project form for editing.
- **Install:** Displays a popup with instructions on how to add transactions for this project.

### LLM Transactions

- **Transactions Table:** Displays a table with the last five transactions for this project.
- **"All Project Transactions" Button:** Redirects to a table with all transactions for this project.

**Notes:**

- The Project Dashboard page provides users with comprehensive project information and convenient access to project-related actions such as editing, deleting, and managing transactions.
- The Recent Transactions table offers a quick overview of recent project activity, while the "All Project Transactions" button allows users to view all transactions associated with the project.
Loading

0 comments on commit 53079bb

Please sign in to comment.