-
Notifications
You must be signed in to change notification settings - Fork 0
add changes #27
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
base: main
Are you sure you want to change the base?
add changes #27
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """Add unique constraint to tables | ||
|
|
||
| Revision ID: 70e8a34ff877 | ||
| Revises: f9a3d1c8e205 | ||
| Create Date: 2026-07-07 11:17:43.459879 | ||
|
|
||
| """ | ||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
| import sqlmodel | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = '70e8a34ff877' | ||
| down_revision: Union[str, None] = 'f9a3d1c8e205' | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_constraint('uq_table_profiles_table_id', 'table_profiles', type_='unique') | ||
| op.drop_index('ix_table_profiles_table_id', table_name='table_profiles') | ||
| op.create_index(op.f('ix_table_profiles_table_id'), 'table_profiles', ['table_id'], unique=True) | ||
| op.drop_column('table_profiles', 'is_partial') | ||
| op.create_unique_constraint('uq_table_fqn', 'tables', ['catalog', 'schema_name', 'name']) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_constraint('uq_table_fqn', 'tables', type_='unique') | ||
| op.add_column('table_profiles', sa.Column('is_partial', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False)) | ||
| op.drop_index(op.f('ix_table_profiles_table_id'), table_name='table_profiles') | ||
| op.create_index('ix_table_profiles_table_id', 'table_profiles', ['table_id'], unique=False) | ||
| op.create_unique_constraint('uq_table_profiles_table_id', 'table_profiles', ['table_id'], postgresql_nulls_not_distinct=False) | ||
| # ### end Alembic commands ### |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,17 @@ class ChatResponse(BaseModel): | |
| trace_id: str | None = None | ||
| execution_path: list[str] | None = None | ||
|
|
||
| class TraceSpan(BaseModel): | ||
| span_name: str | ||
| start_time: str | None = None | ||
| duration_ms: int = 0 | ||
| input_tokens: int = 0 | ||
| output_tokens: int = 0 | ||
| model: str = "N/A" | ||
| status: str | ||
| input_preview: str = "" | ||
| output_preview: str = "" | ||
|
Comment on lines
+70
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🛡️ Proposed fix timeline.append(
{
- "span_name": obs.get("name") or obs.get("type"),
+ "span_name": obs.get("name") or obs.get("type") or "unknown",Also applies to: 304-316 🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Helpers | ||
|
|
@@ -187,6 +198,8 @@ async def chat(request: ChatRequest) -> ChatResponse: | |
| "allowed_tables": request.allowed_tables, | ||
| "allowed_statuses": request.allowed_statuses, | ||
| "extractors": request.extractors, | ||
| "active_skills": request.active_skills, | ||
| "execution_mode": request.execution_mode, | ||
| "hitl_enabled": request.hitl_enabled, | ||
| } | ||
|
|
||
|
|
@@ -254,13 +267,13 @@ async def event_generator(): | |
| return StreamingResponse(event_generator(), media_type="text/event-stream") | ||
|
|
||
|
|
||
| @router.get("/traces/{trace_id}") | ||
| @router.get("/traces/{trace_id}", response_model=list[TraceSpan]) | ||
| async def get_trace_timeline(trace_id: str): | ||
| """Fetch trace from Langfuse and normalize observations for frontend timeline.""" | ||
| auth = (settings.LANGFUSE_PUBLIC_KEY, settings.LANGFUSE_SECRET_KEY) | ||
| url = f"{settings.LANGFUSE_HOST}/api/public/traces/{trace_id}" | ||
|
|
||
| async with httpx.AsyncClient() as client: | ||
| async with httpx.AsyncClient(timeout=settings.LANGFUSE_REQUEST_TIMEOUT) as client: | ||
| resp = await client.get(url, auth=auth) | ||
| if resp.status_code != 200: | ||
| if resp.status_code == 404: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Set default to
Nonefor optional fields.Since
erroris typed asOptional[str], usingdefault_factory=strinitializes it to an empty string""instead ofNone. It is more idiomatic and semantically accurate to usedefault=Nonefor optional error fields.♻️ Proposed refactor
📝 Committable suggestion
🤖 Prompt for AI Agents