Skip to content
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b7bf38e
rest api history repository
wwwy3y3 Apr 18, 2025
2b96fff
refactor
wwwy3y3 Apr 22, 2025
1884ae1
show intent reasoning
wwwy3y3 Apr 22, 2025
f8d2ede
add api history graphql api
wwwy3y3 Apr 22, 2025
f5dec5e
run sql
wwwy3y3 Apr 22, 2025
69e7a78
sanitize records
wwwy3y3 Apr 22, 2025
5a7d256
response id
wwwy3y3 Apr 22, 2025
129fd3b
return invalid_sql if it's provided
wwwy3y3 Apr 23, 2025
daee193
add language parameter to generate_sql
wwwy3y3 Apr 23, 2025
ec89807
add returnSqlDialect param to generate_sql
wwwy3y3 Apr 23, 2025
8d59e0a
stream explanation api
wwwy3y3 Apr 23, 2025
6b18484
generate_vega_spec api
wwwy3y3 Apr 23, 2025
bd53d7a
openapi yaml
wwwy3y3 Apr 23, 2025
9859664
fix graphql
wwwy3y3 Apr 23, 2025
cc461fc
vega utils
wwwy3y3 Apr 24, 2025
aa368be
upgrade uuid
wwwy3y3 Apr 24, 2025
bc97366
add fk to migration
wwwy3y3 Apr 24, 2025
0767658
add timeout
wwwy3y3 Apr 24, 2025
3ce476b
timeout error
wwwy3y3 Apr 24, 2025
fcc4280
fix created/updated time resolve null issue
wwwy3y3 Apr 24, 2025
1f7b37f
add required to pagination
wwwy3y3 Apr 24, 2025
d415504
fix code review issues
wwwy3y3 Apr 24, 2025
85c4928
fix language param default logics
wwwy3y3 Apr 24, 2025
8a940af
feat(wren-ui): API history page for monitoring RESTful API access (#1…
andreashimin Apr 25, 2025
c07f9aa
fix code review
wwwy3y3 Apr 25, 2025
0950762
typo
wwwy3y3 Apr 25, 2025
ae6106f
fix(wren-ui): defense mechanism for json string
andreashimin Apr 25, 2025
bf6d824
feat(wren-ui): adjust column width
andreashimin Apr 25, 2025
33b9e0f
update openapi doc
wwwy3y3 Apr 25, 2025
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
43 changes: 43 additions & 0 deletions wren-ui/migrations/20250511000000-create-api-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.schema.createTable('api_history', (table) => {
table.string('id').primary();

// Project
table.integer('project_id').notNullable();
Comment thread
wwwy3y3 marked this conversation as resolved.
table
.foreign('project_id')
.references('id')
.inTable('projects')
.onDelete('CASCADE');

// Thread
table.string('thread_id');

// API Type
table.string('api_type').notNullable();

// Request
table.jsonb('headers');
table.jsonb('request_payload');

// Response
table.jsonb('response_payload');

// Result
table.integer('status_code').notNullable();
table.integer('duration_ms').notNullable();
table.timestamps(true, true);
});
Comment thread
wwwy3y3 marked this conversation as resolved.
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.schema.dropTable('api_history');
};
216 changes: 216 additions & 0 deletions wren-ui/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
openapi: 3.0.0
info:
title: Wren AI API
description: API for interacting with Wren AI services
version: 1.0.0
servers:
- url: /api/v1
description: Wren AI API v1
paths:
/generate_sql:
post:
summary: Generate SQL from natural language
description: Converts a natural language question into a SQL query
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- question
properties:
question:
type: string
description: The natural language question to convert to SQL
threadId:
type: string
description: Optional thread ID for conversation context
language:
type: string
description: Optional language override for the AI response (EN, ES, etc.)
Comment thread
wwwy3y3 marked this conversation as resolved.
Outdated
responses:
'200':
description: Successfully generated SQL
content:
application/json:
schema:
type: object
properties:
sql:
type: string
description: The generated SQL statement
threadId:
type: string
description: ID of the thread (existing or newly created)
'400':
description: Bad request or unable to generate SQL
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'405':
description: Method not allowed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/run_sql:
post:
summary: Execute SQL and return results
description: Runs a SQL query and returns the results as structured data
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- sql
properties:
sql:
type: string
description: The SQL query to execute
threadId:
type: string
description: Optional thread ID for conversation context
limit:
type: integer
description: Maximum number of rows to return
default: 1000
responses:
'200':
description: Successfully executed SQL
content:
application/json:
schema:
type: object
properties:
records:
type: array
description: Array of records, each represented as an object
items:
type: object
columns:
type: array
description: Metadata about the result columns
items:
$ref: '#/components/schemas/ColumnMetadata'
threadId:
type: string
description: ID of the thread (existing or newly created)
totalRows:
type: integer
description: The total number of rows returned
'400':
description: Bad request or SQL execution error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'405':
description: Method not allowed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/generate_vega_spec:
post:
summary: Generate Vega visualization spec
description: Generates a Vega specification for data visualization from a question and SQL query
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- question
- sql
properties:
question:
type: string
description: The natural language question about visualization
sql:
type: string
description: The SQL query that produces the data to visualize
threadId:
type: string
description: Optional thread ID for conversation context
sampleSize:
type: integer
description: Maximum number of rows to include in the visualization
default: 10000
responses:
'200':
description: Successfully generated Vega specification
content:
application/json:
schema:
type: object
properties:
vegaSpec:
type: object
description: The Vega specification with embedded data
threadId:
type: string
description: ID of the thread (existing or newly created)
'400':
description: Bad request or specification generation error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'405':
description: Method not allowed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/stream_explanation:
get:
summary: Stream an explanation
description: Streams an explanation for a non-SQL query using server-sent events
parameters:
- name: queryId
in: query
description: The query ID to stream results from
required: true
schema:
type: string
responses:
'200':
description: Stream of explanation events
content:
text/event-stream:
schema:
type: string
description: Server-sent events stream with explanation chunks
'500':
description: Internal server error
components:
Comment thread
wwwy3y3 marked this conversation as resolved.
schemas:
ErrorResponse:
type: object
properties:
error:
type: string
description: Error message
code:
type: string
description: Error code
ColumnMetadata:
type: object
properties:
name:
type: string
description: Column name
type:
type: string
description: Data type of the column
notNull:
type: boolean
description: Whether the column allows null values
properties:
type: object
description: Additional column properties
2 changes: 1 addition & 1 deletion wren-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"pg-cursor": "^2.7.4",
"posthog-node": "^4.3.2",
"sql-formatter": "^15.3.0",
"uuid": "^9.0.1"
"uuid": "^11.1.0"
},
"devDependencies": {
"@apollo/client": "^3.6.9",
Expand Down
Loading