Skip to content

Commit

Permalink
Merge pull request #8 from preqldata/model-dev-devex
Browse files Browse the repository at this point in the history
committing current fixes
  • Loading branch information
greenmtnboy authored Apr 12, 2024
2 parents ec838b4 + cc8bc7d commit 1ce1644
Show file tree
Hide file tree
Showing 49 changed files with 3,440 additions and 1,566 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ release
*.pyc
.ruff_cache
.mypy_cache
__pycache__

# python
*.pyc
Expand All @@ -42,4 +43,8 @@ demo_data
backend/build
backend/dist

playwright-report
playwright-report

local_prompt_cache.db

*.cpython-*
Binary file modified backend/__pycache__/io_models.cpython-311.pyc
Binary file not shown.
84 changes: 83 additions & 1 deletion backend/io_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from typing import List, Optional
from typing import List, Optional, Dict, Tuple

from preql.core.models import DataType, Purpose
from pydantic import BaseModel, Field
from preql_nlp.enums import Provider
from preql import Dialects
from datetime import datetime


class LineageItem(BaseModel):
Expand All @@ -27,3 +30,82 @@ class Model(BaseModel):

class ListModelResponse(BaseModel):
models: List[Model]


class GenAIConnectionInSchema(BaseModel):
name: str
provider: Provider
api_key: str = Field(alias="apiKey")
extra: Dict = Field(default_factory=dict)


class QueryInSchema(BaseModel):
connection: str
query: str
# chart_type: ChartType | None = None


class GenAIQueryInSchema(BaseModel):
connection: str
text: str
genai_connection: str


class GenAIQueryOutSchema(BaseModel):
text: str


class FormatQueryOutSchema(BaseModel):
text: str


class InputRequest(BaseModel):
text: str
connection: str
# conversation:str


class ModelSourceInSchema(BaseModel):
alias: str
contents: str


class ModelInSchema(BaseModel):
name: str
sources: List[ModelSourceInSchema]


class ConnectionInSchema(BaseModel):
name: str
dialect: Dialects
extra: Dict | None = Field(default_factory=dict)
model: str | None = None
full_model: ModelInSchema | None = None


class ConnectionListItem(BaseModel):
name: str
dialect: Dialects
model: str


class ConnectionListOutput(BaseModel):
connections: List[ConnectionListItem]


class QueryOutColumn(BaseModel):
name: str
datatype: DataType
purpose: Purpose


class QueryOut(BaseModel):
connection: str
query: str
generated_sql: str
headers: list[str]
results: list[dict]
created_at: datetime = Field(default_factory=datetime.now)
refreshed_at: datetime = Field(default_factory=datetime.now)
duration: Optional[int]
columns: List[Tuple[str, QueryOutColumn]] | None
Loading

0 comments on commit 1ce1644

Please sign in to comment.