Spaces:
Sleeping
Sleeping
File size: 1,883 Bytes
1d53d27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
"""Add config table
Revision ID: ca81bd47c050
Revises: 7e5b5dc7342b
Create Date: 2024-08-25 15:26:35.241684
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
from sqlalchemy import text
# revision identifiers, used by Alembic.
revision: str = "ca81bd47c050"
down_revision: Union[str, None] = "7e5b5dc7342b"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade():
op.create_table(
"config",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("data", sa.JSON(), nullable=False),
sa.Column("version", sa.Integer, nullable=False),
sa.Column(
"created_at", sa.DateTime(), nullable=False, server_default=sa.func.now()
),
sa.Column(
"updated_at",
sa.DateTime(),
nullable=True,
server_default=sa.func.now(),
onupdate=sa.func.now(),
),
)
init_gaia_config()
def downgrade():
op.drop_table("config")
def init_gaia_config():
import json
prompt_suggestions = None
with open(
"/app/aworld/examples/gaia/GAIA/2023/validation/metadata.jsonl",
"r",
encoding="utf-8",
) as f:
data_set = [json.loads(line) for line in f]
prompt_suggestions = [
{
"title": [
i["task_id"],
i["Question"][:100],
],
"content": json.dumps({"task_id": i["task_id"]}),
}
for i in data_set
]
conn = op.get_bind()
conn.execute(
text("INSERT INTO config (id, data, version) VALUES (1, :data, 0)"),
{"data": json.dumps({"ui": {"prompt_suggestions": prompt_suggestions}})},
)
print(f">>> patch gaia_agent: add prompt_suggestions success!")
|