Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New UI Enhancements and Multimodal Handling #36

Merged
merged 116 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
fabb60c
new ui - sidebar
Bklzn Apr 17, 2024
fbfbeb7
new ui - dashboard filters
Bklzn Apr 22, 2024
5df3052
new ui - dashboard, project tiles && styles config
Bklzn Apr 24, 2024
f55a1a8
new ui - tags visibility adjust to container width
Bklzn Apr 24, 2024
ec6d0aa
new ui - dashboard, pagination
Bklzn Apr 24, 2024
8dcb05d
new ui - dashboard, filters logic
Bklzn Apr 25, 2024
3cdf02b
new ui - dashboard, add pagination info logic
Bklzn Apr 26, 2024
53b4f28
new ui - dashboard, filters fix
Bklzn Apr 26, 2024
38cea6a
new ui - dashboard, filters fix
Bklzn Apr 29, 2024
b57e54c
new ui - fix styles line height
Bklzn Apr 29, 2024
648e924
new ui - dashboard, add noFoundProjects page
Bklzn Apr 29, 2024
6645adb
new ui - dashboard, add new filter empty state
Bklzn May 9, 2024
fbf476a
in documentation 3.1 developement environment - backend section
sliwaszymon May 14, 2024
24e2fe0
new ui - add Project form, style fixes, context fixes
Bklzn May 16, 2024
4152f5e
database structure for docs
sliwaszymon May 17, 2024
ff4ecfa
dev docs fix and db running part in backend section; db objects field…
sliwaszymon May 17, 2024
499fcbc
Merge branch 'dev' into docs
ksopyla May 18, 2024
b6f7e89
update SSO docs & fix imgs paths
Bklzn May 20, 2024
4b44ff6
new ui - project form, add cancel button func
Bklzn May 20, 2024
44ea1a5
adding warning about pulling the images before docker-compose command
WiolaGreen May 21, 2024
a0e2c57
new ui - project details, tab Overview
Bklzn May 22, 2024
c654852
new ui - project details, tab AI Providers
Bklzn May 22, 2024
4994db3
new ui - project details, tab Transactions
Bklzn May 24, 2024
752dbb6
new ui - project details, tab transactions
Bklzn May 24, 2024
904e9af
new ui - project details, add Delete Buttons functionality
Bklzn May 24, 2024
4c6cedf
azure deployment documentation section
sliwaszymon May 25, 2024
9ddfd2b
azure deployment documentation section fix
sliwaszymon May 25, 2024
ed63398
azure deployment documentation section fix
sliwaszymon May 25, 2024
c8205ed
new ui - project details, update ai_providers funcionality
Bklzn May 28, 2024
f97ceed
fix for getting tokens from vertex
sliwaszymon May 29, 2024
8589822
vertex ai models are now set as visible
sliwaszymon May 29, 2024
afc0aab
tokens fix for vertex
sliwaszymon May 29, 2024
f0ba6f3
new ui - project details, Proxy URL Configuration
Bklzn May 29, 2024
f60f78b
new ui - project details, edit description functionality
Bklzn May 29, 2024
22a85a0
transaction table - fix speed toFixed error
Bklzn May 29, 2024
b39e88d
fixes
Bklzn May 29, 2024
ebb57f5
project details table - fix speed toFixed error
Bklzn May 29, 2024
d29b83a
new ui - Transactions & fix transactions display errors
Bklzn May 29, 2024
2c8bbba
tests for rest of stats
sliwaszymon May 29, 2024
904aa00
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon May 29, 2024
c88c281
fill frontend section for /docs/development-environment/
Bklzn May 30, 2024
342f838
Merge branch 'ui' into dev
Bklzn May 31, 2024
3f1eae1
sidebar - disable not supported buttons
Bklzn May 31, 2024
29340ae
fix
Bklzn May 31, 2024
d495a18
new ui, transactions details - add Overview & Messages tab
Bklzn May 31, 2024
e9942a0
Sidebar - fix help button
Bklzn May 31, 2024
090aef5
req_resp_to_transaction_parser refactored into TransactionParamExtrac…
sliwaszymon Jun 2, 2024
29c085a
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon Jun 2, 2024
a24647c
docs - env variables update in local deployment section
sliwaszymon Jun 3, 2024
cbef5f5
docs - env variables section
sliwaszymon Jun 3, 2024
4909015
docs - env variables section (added into navbar)
sliwaszymon Jun 3, 2024
ca9a9ca
docker-compose for try-promptsail
sliwaszymon Jun 3, 2024
6883f18
new ui, transactions details - fixes, add JSON tab
Bklzn Jun 3, 2024
1d5fb72
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
Bklzn Jun 3, 2024
a29932e
sidebar - add user info && fix logout
Bklzn Jun 3, 2024
cabc540
project, porviders list - add copy button to proxy URL
Bklzn Jun 3, 2024
66e7e20
project, overview - round cost to 4 decimals
Bklzn Jun 3, 2024
a96b1f6
transaction, overview - round generation_speed to 4 decimals
Bklzn Jun 3, 2024
a162c29
gpt-4o for azure added to pricelist
sliwaszymon Jun 4, 2024
38f4d19
create project - handle input Owner
Bklzn Jun 4, 2024
ab5ed41
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
Bklzn Jun 4, 2024
2315894
returns authorized user as index 0 in /api/users response
sliwaszymon Jun 4, 2024
e319d7c
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon Jun 4, 2024
93da338
azure deployment docs for separated containers
sliwaszymon Jun 4, 2024
dd22765
endpoint for adding transactions by hand
sliwaszymon Jun 5, 2024
5f07bcb
dashboard - handle owner display and config for types of auth
Bklzn Jun 5, 2024
ca34bc6
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
Bklzn Jun 5, 2024
6906294
project form - fix incorrect owner
Bklzn Jun 5, 2024
a392dc8
dashboard - fix displaying tiles more than 'pageData.size'
Bklzn Jun 5, 2024
6b5da29
sidebar - fix picture when url is null
Bklzn Jun 5, 2024
de9b947
tokenization fix for streaming responses,
sliwaszymon Jun 5, 2024
db7d46e
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon Jun 5, 2024
7849982
Transactions - add project filter, demo status filter
Bklzn Jun 6, 2024
b1632ea
fix - remove unused LatestTransacions.tsx
Bklzn Jun 6, 2024
4ee1331
examples dependencies extracted from promptsail pyproject to separat…
sliwaszymon Jun 7, 2024
d6beefa
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon Jun 7, 2024
bd76906
new multiple filters (statuses, providers, models)
sliwaszymon Jun 7, 2024
7d695e3
Statistics - enlargin the graph area for values
Bklzn Jun 7, 2024
1991d97
status filters now catch whole status group
sliwaszymon Jun 7, 2024
b94e2a1
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon Jun 7, 2024
e0fca1c
Transactions - connect status filter to api, add provider filters
Bklzn Jun 7, 2024
d85785f
Transactions - add models filters
Bklzn Jun 10, 2024
60046dd
project details - fixes to AiProviderList
Bklzn Jun 10, 2024
bb0db83
statistics - new granularity ranges
Bklzn Jun 10, 2024
3e4ca0a
Transactions - add tags filters
Bklzn Jun 10, 2024
6d4f737
fix tokens for azure embeddings, possible fix for vertexai examples
sliwaszymon Jun 11, 2024
556f2aa
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon Jun 11, 2024
a2634d8
transactions - fix token display
Bklzn Jun 11, 2024
d7b1f56
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
Bklzn Jun 11, 2024
e2af1a7
project details - fix collapsed AIprovider while editing
Bklzn Jun 11, 2024
a0ab423
fix for oai embeddigns, example for oai sdk embeddings
sliwaszymon Jun 12, 2024
a190eb5
format
sliwaszymon Jun 12, 2024
c4c0a0c
signin - new
Bklzn Jun 12, 2024
ffc796c
quick fix
Bklzn Jun 12, 2024
d19dc07
openai image variations handling + examples
sliwaszymon Jun 12, 2024
40d53ba
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon Jun 12, 2024
f1d4fce
add modal to delete provider & correct notifications
Bklzn Jun 12, 2024
2b97933
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
Bklzn Jun 12, 2024
013052f
signing - fix redirect uri
Bklzn Jun 12, 2024
7db5a40
environment-variables - add frontend section
Bklzn Jun 12, 2024
acab9bd
openai image generation handling + examples
sliwaszymon Jun 13, 2024
72e999c
openai image edit handling + examples
sliwaszymon Jun 13, 2024
9cfa200
displaying response images in examples
sliwaszymon Jun 13, 2024
e72f35d
embedding tokens fix
sliwaszymon Jun 13, 2024
e32a3f2
statistics - set week as deafult date range
Bklzn Jun 13, 2024
7240602
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
Bklzn Jun 13, 2024
d8e574d
create project - add modal to delete provider
Bklzn Jun 13, 2024
0434b8e
transaction - correct higlight
Bklzn Jun 13, 2024
1db14cd
update project - load project owner to field
Bklzn Jun 13, 2024
5209bec
change default avatar
Bklzn Jun 13, 2024
3e6a751
gpt-4o multimodal (text + image) handling + examples
sliwaszymon Jun 14, 2024
25427a3
Merge branch 'dev' of https://github.com/PromptSail/prompt_sail into dev
sliwaszymon Jun 14, 2024
af50992
transactions - remove error alert
Bklzn Jun 14, 2024
5089f04
Update 50-deploy-cookbook-introduction.md
ksopyla Jun 16, 2024
ddd0ae0
Update 50-deploy-cookbook-introduction.md
ksopyla Jun 16, 2024
eedca0b
Merge branch 'dev' into docs
ksopyla Jun 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions backend/provider_price_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,73 +221,73 @@
},
{
"model_name": "gemini-1.0-pro-001",
"provider": "Google Vertex AI",
"provider": "Google VertexAI",
"start_date": "",
"match_pattern": "(?i)^(gemini-1.0-pro-001)?$",
"input_price": 0.000125,
"output_price": 0.000375,
"total_price": 0,
"is_active": false
"is_active": true
},
{
"model_name": "gemini-1.0-pro-002",
"provider": "Google Vertex AI",
"provider": "Google VertexAI",
"start_date": "",
"match_pattern": "(?i)^(gemini-1.0-pro-002)?$",
"input_price": 0.000125,
"output_price": 0.000375,
"total_price": 0,
"is_active": false
"is_active": true
},
{
"model_name": "gemini-1.0-pro-vision-001",
"provider": "Google Vertex AI",
"provider": "Google VertexAI",
"start_date": "",
"match_pattern": "(?i)^(gemini-1.0-pro-vision-001)?$",
"input_price": 0.000125,
"output_price": 0.000375,
"total_price": 0,
"is_active": false
"is_active": true
},
{
"model_name": "gemini-1.5-flash-001",
"provider": "Google Vertex AI",
"provider": "Google VertexAI",
"start_date": "",
"match_pattern": "(?i)^(gemini-1.5-flash-001)?$",
"input_price": 0.000125,
"output_price": 0.000375,
"total_price": 0,
"is_active": false
"is_active": true
},
{
"model_name": "gemini-1.5-flash-preview-0514",
"provider": "Google Vertex AI",
"provider": "Google VertexAI",
"start_date": "",
"match_pattern": "(?i)^(gemini-1.5-flash-preview-0514)?$",
"input_price": 0.000125,
"output_price": 0.000375,
"total_price": 0,
"is_active": false
"is_active": true
},
{
"model_name": "gemini-1.5-pro-001",
"provider": "Google Vertex AI",
"provider": "Google VertexAI",
"start_date": "",
"match_pattern": "(?i)^(gemini-1.5-pro-001)?$",
"input_price": 0.00125,
"output_price": 0.00375,
"total_price": 0,
"is_active": false
"is_active": true
},
{
"model_name": "gemini-1.5-pro-preview-0514",
"provider": "Google Vertex AI",
"provider": "Google VertexAI",
"start_date": "",
"match_pattern": "(?i)^(gemini-1.5-pro-preview-0514)?$",
"input_price": 0.00125,
"output_price": 0.00375,
"total_price": 0,
"is_active": false
"is_active": true
},
{
"model_name": "gpt-35-turbo-0125",
Expand Down Expand Up @@ -539,6 +539,16 @@
"total_price": 0,
"is_active": true
},
{
"model_name": "gpt-4o-2024-05-13",
"provider": "Azure OpenAI",
"start_date": "",
"match_pattern": "(?i)^(gpt-4o)(|-2024-05-13)$",
"input_price": 0.005,
"output_price": 0.015,
"total_price": 0,
"is_active": true
},
{
"model_name": "gpt-4o-2024-05-13",
"provider": "OpenAI",
Expand Down
12 changes: 0 additions & 12 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ requests-mock = "^1.11.0"
locust = "^2.24.1"


[tool.poetry.group.examples]
optional = true

[tool.poetry.group.examples.dependencies]
ipykernel = "^6.25.2"
langchain = "^0.0"
openai = "^1"
boto3 = "^1.34.13"
anthropic = "^0.25.6"
rich = "^13.7.1"
langchain-anthropic = "^0.1.11"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
118 changes: 107 additions & 11 deletions backend/src/app/web_api.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import re
from typing import Annotated, Any

import utils
from _datetime import datetime, timezone
from app.dependencies import get_provider_pricelist, get_transaction_context
from auth.authorization import decode_and_validate_token
from auth.schemas import GetUserSchema, GetPartialUserSchema
from auth.models import User
from auth.schemas import GetPartialUserSchema, GetUserSchema
from auth.use_cases import get_all_users
from fastapi import Depends, Request, Security
from fastapi.responses import JSONResponse
from lato import TransactionContext

from auth.use_cases import get_all_users
from projects.models import AIProvider, Project
from projects.schemas import (
CreateProjectSchema,
Expand All @@ -29,8 +30,10 @@
from slugify import slugify
from transactions.models import generate_uuid
from transactions.schemas import (
CreateTransactionSchema,
GetTransactionLatencyStatisticsWithoutDateSchema,
GetTransactionPageResponseSchema,
GetTransactionSchema,
GetTransactionsLatencyStatisticsSchema,
GetTransactionStatusStatisticsSchema,
GetTransactionsUsageStatisticsSchema,
Expand All @@ -39,6 +42,7 @@
StatisticTransactionSchema,
)
from transactions.use_cases import (
add_transaction,
count_token_usage_for_project,
count_transactions,
delete_multiple_transactions,
Expand All @@ -53,7 +57,7 @@

@app.get("/api/auth/whoami", dependencies=[Security(decode_and_validate_token)])
def whoami(
request: Request, user: dict = Depends(decode_and_validate_token)
request: Request, user: User = Depends(decode_and_validate_token)
) -> GetUserSchema:
return GetUserSchema(
external_id=user.external_id,
Expand Down Expand Up @@ -258,6 +262,9 @@ async def get_paginated_transactions(
project_id: str | None = None,
sort_field: str | None = None,
sort_type: str | None = None,
status_codes: str | None = None,
providers: str | None = None,
models: str | None = None,
) -> GetTransactionPageResponseSchema:
"""
API endpoint to retrieve a paginated list of transactions based on specified filters.
Expand All @@ -271,9 +278,18 @@ async def get_paginated_transactions(
:param project_id: Optional. Project ID to filter transactions by.
:param sort_field: Optional. Field to sort by.
:param sort_type: Optional. Ordering method (asc or desc).
:param status_codes: Optional. List of status codes for filtering transactions.
:param providers: Optional. List of providers for filtering transactions.
:param models: Optional. List of models for filtering transactions.
"""
if tags is not None:
tags = tags.split(",")
if status_codes is not None:
status_codes = list(map(lambda x: int(x), status_codes.split(",")))
if providers is not None:
providers = providers.split(",")
if models is not None:
models = models.split(",")

transactions = ctx.call(
get_all_filtered_and_paginated_transactions,
Expand All @@ -285,6 +301,9 @@ async def get_paginated_transactions(
project_id=project_id,
sort_field=sort_field,
sort_type=sort_type,
status_codes=status_codes,
providers=providers,
models=models,
)

projects = ctx.call(get_all_projects)
Expand All @@ -307,6 +326,9 @@ async def get_paginated_transactions(
date_from=date_from,
date_to=date_to,
project_id=project_id,
status_codes=status_codes,
providers=providers,
models=models,
)
page_response = GetTransactionPageResponseSchema(
items=new_transactions,
Expand Down Expand Up @@ -357,7 +379,7 @@ async def get_transaction_usage_statistics_over_time(
project_id=project_id,
date_from=date_from,
date_to=date_to,
status_code=200,
status_codes=[200],
)
if count == 0:
return []
Expand All @@ -367,7 +389,7 @@ async def get_transaction_usage_statistics_over_time(
project_id=project_id,
date_from=date_from,
date_to=date_to,
status_code=200,
status_codes=[200],
)
transactions = [
StatisticTransactionSchema(
Expand Down Expand Up @@ -529,7 +551,7 @@ async def get_transaction_latency_statistics_over_time(
project_id=project_id,
date_from=date_from,
date_to=date_to,
status_code=200,
status_codes=[200],
null_generation_speed=False,
)
if count == 0:
Expand All @@ -540,7 +562,7 @@ async def get_transaction_latency_statistics_over_time(
project_id=project_id,
date_from=date_from,
date_to=date_to,
status_code=200,
status_codes=[200],
null_generation_speed=False,
)
transactions = [
Expand Down Expand Up @@ -642,13 +664,87 @@ async def get_config(
}


@app.get("/api/users", response_class=JSONResponse)
async def get_users(ctx: Annotated[TransactionContext, Depends(get_transaction_context)]) -> list[GetPartialUserSchema]:
@app.get("/api/users", dependencies=[Security(decode_and_validate_token)])
async def get_users(
ctx: Annotated[TransactionContext, Depends(get_transaction_context)],
auth_user: User = Depends(decode_and_validate_token),
) -> list[GetPartialUserSchema]:
users = ctx.call(get_all_users)
parsed_users = map(lambda user: GetPartialUserSchema(id=user.id, email=user.email, full_name=str(user.given_name + " " + user.family_name), picture=user.picture), users)
idx = next(
(i for i, usr in enumerate(users) if usr.external_id == auth_user.external_id),
None,
)
if idx is not None:
temp = users.pop(idx)
users.insert(0, temp)
else:
users.insert(0, User(**auth_user.model_dump()))

parsed_users = map(
lambda user: GetPartialUserSchema(
id=user.id,
email=user.email,
full_name=str(user.given_name + " " + user.family_name),
picture=user.picture,
),
users,
)
return list(parsed_users)


@app.post(
"/api/transactions",
response_class=JSONResponse,
status_code=201,
dependencies=[Security(decode_and_validate_token)],
)
def create_transaction(
request: Request,
data: CreateTransactionSchema,
ctx: Annotated[TransactionContext, Depends(get_transaction_context)],
) -> GetTransactionSchema:
if ((data.status_code == 200) and data.model and data.provider) and not (
data.input_cost or data.output_cost or data.total_cost
):
pricelist = get_provider_pricelist(request)
pricelist = [
item
for item in pricelist
if item.provider == data.provider
and re.match(item.match_pattern, data.model)
]
if len(pricelist) > 0:
if pricelist[0].input_price == 0:
data.input_cost, data.output_cost = 0, 0
data.total_cost = (
(data.input_tokens + data.output_tokens)
/ 1000
* pricelist[0].total_price
)
else:
data.input_cost = pricelist[0].input_price * (data.input_tokens / 1000)
data.output_cost = pricelist[0].output_price * (
data.output_tokens / 1000
)
data.total_cost = data.input_cost + data.output_cost
else:
data.input_cost, data.output_cost, data.total_cost = None, None, None

if not data.generation_speed:
if data.output_tokens is not None and (data.output_tokens > 0):
data.generation_speed = (
data.output_tokens
/ (datetime.now(tz=timezone.utc) - data.request_time).total_seconds()
)
elif data.output_tokens == 0:
data.generation_speed = None
else:
data.generation_speed = 0

created_transaction = ctx.call(add_transaction, data=data)
return GetTransactionSchema(**created_transaction.model_dump())


@app.post("/api/only_for_purpose/mock_transactions", response_class=JSONResponse)
async def mock_transactions(
ctx: Annotated[TransactionContext, Depends(get_transaction_context)],
Expand Down
2 changes: 1 addition & 1 deletion backend/src/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Config(BaseSettings):
STATIC_DIRECTORY: str = str((BASE_DIR / Path("../static")).resolve())
GOOGLE_CLIENT_ID: str | None = os.getenv("GOOGLE_CLIENT_ID", None)
AZURE_CLIENT_ID: str | None = os.getenv("AZURE_CLIENT_ID", None)
SSO_AUTH: bool = os.getenv("SSO_AUTH", "True").lower() in ("true", "1", "t")
SSO_AUTH: bool = os.getenv("SSO_AUTH", "False").lower() in ("true", "1", "t")


config = Config()
Expand Down
25 changes: 25 additions & 0 deletions backend/src/transactions/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,28 @@ class GetTransactionPageResponseSchema(BaseModel):
page_size: int
total_pages: int
total_elements: int


class CreateTransactionSchema(BaseModel):
project_id: str
request: dict[str, Any]
response: dict[str, Any]
tags: list[str]
provider: str
model: str | None
type: str
os: str | None
input_tokens: int | None
output_tokens: int | None
library: str
status_code: int
messages: list[dict[str, Any]] | str | None
last_message: str | None
prompt: str
error_message: str | None
generation_speed: int | float | None
request_time: datetime
input_cost: int | float | None
output_cost: int | float | None
total_cost: int | float | None
response_time: datetime | None
Loading
Loading