Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
WiolaGreen committed Jul 4, 2024
2 parents a3ab004 + 3d9bb56 commit cda11f8
Show file tree
Hide file tree
Showing 25 changed files with 1,088 additions and 456 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,4 @@ backend/poetry.lock
**/.env
private_examples/*
docker-compose-wk.yml
examples/poetry.lock
55 changes: 55 additions & 0 deletions backend/provider_price_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,17 @@
"is_active": true,
"mode": "chat"
},
{
"model_name": "claude-3.5-sonnet-20240620",
"provider": "Anthropic",
"start_date": "",
"match_pattern": "(?i)^(claude-3-5-sonnet-20240620)$",
"input_price": 0.003,
"output_price": 0.015,
"total_price": 0,
"is_active": true,
"mode": "chat"
},
{
"model_name": "claude-instant-1.2",
"provider": "Anthropic",
Expand Down Expand Up @@ -900,5 +911,49 @@
"total_price": 0.0001,
"is_active": false,
"mode": "embedding"
},
{
"model_name": "llama3-8b-8192",
"provider": "Groq",
"start_date": "",
"match_pattern": "(?i)^(llama3)(-8b)(-8192)?$",
"input_price": 0.00005,
"output_price": 0.00008,
"total_price": 0,
"is_active": true,
"mode": "chat"
},
{
"model_name": "llama3-70b-8192",
"provider": "Groq",
"start_date": "",
"match_pattern": "(?i)^(llama3)(-70b)(-8192)?$",
"input_price": 0.00059,
"output_price": 0.00079,
"total_price": 0,
"is_active": true,
"mode": "chat"
},
{
"model_name": "mixtral-8x7b-32768",
"provider": "Groq",
"start_date": "",
"match_pattern": "(?i)^(mixtral)(-8x7b)(-32768)?$",
"input_price": 0.00024,
"output_price": 0.00024,
"total_price": 0,
"is_active": true,
"mode": "chat"
},
{
"model_name": "gemma-7b-it",
"provider": "Groq",
"start_date": "",
"match_pattern": "(?i)^(gemma)(-7b)(-it)?$",
"input_price": 0.00007,
"output_price": 0.00007,
"total_price": 0,
"is_active": true,
"mode": "chat"
}
]
57 changes: 39 additions & 18 deletions backend/src/app/web_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
get_all_filtered_and_paginated_transactions,
get_list_of_filtered_transactions,
get_transaction,
get_transactions_for_project,
get_transactions_for_project, get_all_transactions,
)

from .app import app
Expand Down Expand Up @@ -293,23 +293,22 @@ async def get_paginated_transactions(
if status_codes is not None:
status_codes = list(map(lambda x: int(x), status_codes.split(",")))
if provider_models is not None:
if provider_models is not None:
provider_models = list(
map(lambda x: x.split("."), provider_models.split(","))
)
pairs = {}
for pair in provider_models:
if pair[0] not in pairs:
try:
pairs[pair[0]] = (
[".".join(pair[1:])] if ".".join(pair[1:]) is not "" else []
)
except IndexError:
pairs[pair[0]] = []
else:
pairs[pair[0]].append(pair[1])
provider_models = pairs
print(provider_models)
provider_models = list(
map(lambda x: x.split("."), provider_models.split(","))
)
pairs = {}
for pair in provider_models:
if pair[0] not in pairs:
try:
pairs[pair[0]] = (
[".".join(pair[1:])] if ".".join(pair[1:]) != "" else []
)
except IndexError:
pairs[pair[0]] = []
else:
pairs[pair[0]].append(pair[1])
provider_models = pairs

transactions = ctx.call(
get_all_filtered_and_paginated_transactions,
page=page,
Expand Down Expand Up @@ -671,6 +670,28 @@ async def get_portfolio_details(
)


@app.get(
"/api/portfolio/costs_by_tag",
response_class=JSONResponse,
dependencies=[Security(decode_and_validate_token)],
)
async def get_costs_by_tag(ctx: Annotated[TransactionContext, Depends(get_transaction_context)]) -> dict:
transactions = ctx.call(get_all_transactions)
cost_by_tag = {}
for transaction in transactions:
if len(transaction.tags) > 0:
for tag in transaction.tags:
try:
cost_by_tag[tag] += transaction.total_cost if transaction.total_cost is not None else 0
except KeyError:
cost_by_tag[tag] = transaction.total_cost if transaction.total_cost is not None else 0
try:
cost_by_tag["untagged-transactions"] += transaction.total_cost if transaction.total_cost is not None else 0
except KeyError:
cost_by_tag["untagged-transactions"] = transaction.total_cost if transaction.total_cost is not None else 0
return cost_by_tag


@app.get(
"/api/statistics/pricelist",
response_class=JSONResponse,
Expand Down
16 changes: 8 additions & 8 deletions docs/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ docs:
children:
- title: "Input/output capturing"
url: /docs/storing-transactions/
- title: "Programmatic API"
url: /docs/programmatic-api/
- title: "LLM frameworks integration"
url: /docs/llm-integrations/
- title: "REST API"
url: /docs/backend-rest-api
- title: "Supported Models"
url: /docs/supported-gen-ai-models
- title: Deployment Cookbook
children:
- title: "Deployment recepies"
Expand All @@ -47,13 +47,13 @@ docs:
- title: User UI Guide
children:
- title: "Login Page"
url: /docs/login-page/
url: /docs/login-page
- title: "Organization Dashboard"
url: /docs/organization-dashboard/
url: /docs/organization-dashboard
- title: "Project Dashboard"
url: /docs/project-dashboard/
url: /docs/project-dashboard
- title: "Transactions View"
url: /docs/todo/
url: /docs/transations-view

- title: Developer Guide
children:
Expand Down
33 changes: 0 additions & 33 deletions docs/_docs/11-LLM integrations.md

This file was deleted.

83 changes: 83 additions & 0 deletions docs/_docs/11-supported-models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: "Supported Generative AI Model"
permalink: /docs/supported-gen-ai-models
excerpt: "Supported Generative AI Models and Providers"
last_modified_at: 2024-07-02T18:18:15+01:00
redirect_from:
- /theme-setup/
toc: false
toc_sticky: true
---




## Supported Providers and Models

<br><br>

| Provider | Model | Type | Support |
|-----------------|------------------------------------------------------------|------------------|----------------------------------------|
| OpenAI | babbage-002 | completion |<input type="checkbox" checked disabled>|
| OpenAI | davinci-002 | completion |<input type="checkbox" checked disabled>|
| OpenAI | gpt-3.5-turbo (gpt-3.5-turbo-0125) | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-3.5-turbo-0301 | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-3.5-turbo-0613 | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-3.5-turbo-1106 | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-3.5-turbo-16k (gpt-3.5-turbo-16k-0613) | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-3.5-turbo-instruct | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-3.5-turbo-instruct-0914 | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-4 (gpt-4-0613) | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-4-1106-preview | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-4-vision-preview (gpt-4-1106-vision-preview) | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-4-turbo (gpt-4-turbo-2024-04-09) | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-4-turbo-preview (gpt-4-0125-preview) | chat |<input type="checkbox" checked disabled>|
| OpenAI | gpt-4o (gpt-4o-2024-05-13) | chat |<input type="checkbox" checked disabled>|
| OpenAI | text-embedding-3-small | embedding |<input type="checkbox" checked disabled>|
| OpenAI | text-embedding-3-large | embedding |<input type="checkbox" checked disabled>|
| OpenAI | text-embedding-ada-002 | embedding |<input type="checkbox" checked disabled>|
| OpenAI | dall-e-2 | image generation |<input type="checkbox" checked disabled>|
| OpenAI | dall-e-3 | image generation |<input type="checkbox" checked disabled>|
| Azure OpenAI | babbage-002 | completion |<input type="checkbox" checked disabled>|
| Azure OpenAI | davinci-002 | completion |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-3.5-turbo-0125 | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-3.5-turbo-0301 | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-3.5-turbo-0613 | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-3.5-turbo-1106 | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-3.5-turbo-16k-0613 | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-3.5-turbo-instruct (gpt-3.5-turbo-instruct-0914) | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-4 (gpt-4-0613) | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-4-turbo (gpt-4-1106-preview) | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-4-turbo-vision (gpt-4-vision-preview) | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-4-turbo (gpt-4-0125-preview) | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | gpt-4o-2024-05-13 | chat |<input type="checkbox" checked disabled>|
| Azure OpenAI | text-embedding-3-small | embedding |<input type="checkbox" checked disabled>|
| Azure OpenAI | text-embedding-3-large | embedding |<input type="checkbox" checked disabled>|
| Azure OpenAI | text-embedding-ada-002 | embedding |<input type="checkbox" checked disabled>|
| Azure OpenAI | dall-e-2 | image generation | in progress |
| Azure OpenAI | dall-e-3 | image generation | in progress |
| Google Vertex AI| gemini-1.0-pro-001 | chat |<input type="checkbox" checked disabled>|
| Google Vertex AI| gemini-1.0-pro-002 | chat |<input type="checkbox" checked disabled>|
| Google Vertex AI| gemini-1.0-pro-vision-001 | chat |<input type="checkbox" checked disabled>|
| Google Vertex AI| gemini-1.5-flash-001 | chat |<input type="checkbox" checked disabled>|
| Google Vertex AI| gemini-1.5-flash-preview-0514 | chat |<input type="checkbox" checked disabled>|
| Google Vertex AI| gemini-1.5-pro-001 | chat |<input type="checkbox" checked disabled>|
| Google Vertex AI| gemini-1.5-pro-preview-0514 | chat |<input type="checkbox" checked disabled>|
| Anthropic | claude-2.0 | chat |<input type="checkbox" checked disabled>|
| Anthropic | claude-2.1 | chat |<input type="checkbox" checked disabled>|
| Anthropic | claude-3-haiku | chat |<input type="checkbox" checked disabled>|
| Anthropic | claude-3-opus | chat |<input type="checkbox" checked disabled>|
| Anthropic | claude-3-sonnet | chat |<input type="checkbox" checked disabled>|
| Anthropic | claude-3.5-sonnet | chat |<input type="checkbox" checked disabled>|
| Anthropic | claude-instant-1.2 | chat |<input type="checkbox" checked disabled>|
| Groq | gemma-7b-it | chat |<input type="checkbox" checked disabled>|
| Groq | llama3-8b | chat |<input type="checkbox" checked disabled>|
| Groq | llama3-70b | chat |<input type="checkbox" checked disabled>|
| Groq | mixtral-8x7b | chat |<input type="checkbox" checked disabled>|
| Ollama | | | in progress |
| Huggingface | | | in progress |





24 changes: 24 additions & 0 deletions docs/_docs/12-rest-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Rest API"
permalink: /docs/backend-rest-api
excerpt: "The Rest API documentation provides detailed information about the backend API endpoints and their functionalities."
last_modified_at: 2024-07-01T18:18:15+01:00
redirect_from:
- /theme-setup/
toc: false
toc_sticky: true
---


# Overview


We provide a RESTful API to interact with the PromptSail backend. The API allows you to perform various operations such as creating and managing projects (CRUD), viewing and interactinng with stored transactions, and accessing AI models and providers.
This allows you to integrate and automate project creation, AI providers configuration, and transaction management with your existing systems and tools.


When you [deploy the PromptSail backend](https://promptsail.com/docs/deploy-promptsail-cookbook), the swagger documentation is available at `http://localhost:8000/docs`.


![PromptSail REST API Swagger Documentation]({{ site.url }}{{ site.baseurl }}assets/images/promptsail_rest_api_swagger.png){: .align-center}

25 changes: 19 additions & 6 deletions docs/_docs/20-Login-page.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
---
title: "Login Page"
permalink: /docs/login-page/
permalink: /docs/login-page
excerpt: "The Login Page allows users to authenticate and access their accounts within the application"
last_modified_at: 2024-05-20T10:11:00+01:00
redirect_from:
- /theme-setup/
toc: true
---

The Login Page allows users to authenticate and access their accounts within the application. This documentation provides an overview of the login process and details the functionality available on the Login Page.
This page is available at `localhost:80`. You will be redirected to the `/signin` subpage if the application does not find or recognise the **access token** in the browser's storage.
Login page may operate in one of two mode, which you can set in `docker-compose`:

- `SSO_AUTH: "False"` - this mode is set by default, no need to login anywhere just press **Click to continue**
- `SSO_AUTH: "True"` - this mode requires you to select one of the available SSO login options and log in correctly. For more information, see [SSO Configuration](/docs/sso-configuration/)
## Overview

The Login Page allows users to authenticate and access their accounts within the application.


Prompt Sail login page for annomous access is shown below:
![PromptSail Login page - annomous access]({{ site.url }}{{ site.baseurl }}assets/images/promptsail_ui_login_page.png){: .align-center}

Promp Sail login page for SSO authentication enabled is shown below:

![PromptSail Login page - SSO enabled]({{ site.url }}{{ site.baseurl }}assets/images/promptsail_ui_login_page_sso.png){: .align-center}

By default, the application will redirect you to the login page if it does not find or recognize the access token in the browser's storage. The login functionality can operate in one of two modes, which you can set in the `docker-compose` file:

* allow annomous access to the application by setting env variable `SSO_AUTH: "False"` - this mode is set by default, no need to login anywhere just press **Click to continue**
* allow only authenticated users to access the application via SSO, to configure this just follow the steps described in [SSO Configuration](/docs/sso-configuration/)

You can customize the organization name by setting the `ORGANIZATION_NAME` environment variable in the `docker-compose` file. See the [Environment Variables](/docs/env-variables) documentation for more information.
Loading

0 comments on commit cda11f8

Please sign in to comment.