Skip to content

Commit

Permalink
Merge pull request #194 from MervinPraison/develop
Browse files Browse the repository at this point in the history
Fix postgres
  • Loading branch information
MervinPraison authored Dec 6, 2024
2 parents b03db0f + 45bffe0 commit 0077ffe
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install flask praisonai==1.0.3 gunicorn markdown
RUN pip install flask praisonai==1.0.4 gunicorn markdown
EXPOSE 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]
2 changes: 1 addition & 1 deletion docs/api/praisonai/deploy.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h2 id="raises">Raises</h2>
file.write(&#34;FROM python:3.11-slim\n&#34;)
file.write(&#34;WORKDIR /app\n&#34;)
file.write(&#34;COPY . .\n&#34;)
file.write(&#34;RUN pip install flask praisonai==1.0.3 gunicorn markdown\n&#34;)
file.write(&#34;RUN pip install flask praisonai==1.0.4 gunicorn markdown\n&#34;)
file.write(&#34;EXPOSE 8080\n&#34;)
file.write(&#39;CMD [&#34;gunicorn&#34;, &#34;-b&#34;, &#34;0.0.0.0:8080&#34;, &#34;api:app&#34;]\n&#39;)

Expand Down
2 changes: 1 addition & 1 deletion praisonai.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class Praisonai < Formula

desc "AI tools for various AI applications"
homepage "https://github.com/MervinPraison/PraisonAI"
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/1.0.3.tar.gz"
url "https://github.com/MervinPraison/PraisonAI/archive/refs/tags/1.0.4.tar.gz"
sha256 "1828fb9227d10f991522c3f24f061943a254b667196b40b1a3e4a54a8d30ce32" # Replace with actual SHA256 checksum
license "MIT"

Expand Down
2 changes: 1 addition & 1 deletion praisonai/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def create_dockerfile(self):
file.write("FROM python:3.11-slim\n")
file.write("WORKDIR /app\n")
file.write("COPY . .\n")
file.write("RUN pip install flask praisonai==1.0.3 gunicorn markdown\n")
file.write("RUN pip install flask praisonai==1.0.4 gunicorn markdown\n")
file.write("EXPOSE 8080\n")
file.write('CMD ["gunicorn", "-b", "0.0.0.0:8080", "api:app"]\n')

Expand Down
119 changes: 57 additions & 62 deletions praisonai/ui/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,19 @@ async def create_tables(engine):
id UUID PRIMARY KEY,
identifier TEXT NOT NULL UNIQUE,
metadata JSONB NOT NULL,
createdAt TEXT
created_at TEXT
)
"""))

await conn.execute(text("""
CREATE TABLE IF NOT EXISTS threads (
id UUID PRIMARY KEY,
createdAt TEXT,
created_at TEXT,
name TEXT,
userId UUID,
userIdentifier TEXT,
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
user_identifier TEXT,
tags TEXT[],
metadata JSONB NOT NULL DEFAULT '{}',
FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE
metadata JSONB NOT NULL DEFAULT '{}'
)
"""))

Expand All @@ -84,70 +83,68 @@ async def create_tables(engine):
id UUID PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL,
threadId UUID NOT NULL,
parentId UUID,
disableFeedback BOOLEAN NOT NULL DEFAULT 0,
streaming BOOLEAN NOT NULL DEFAULT 0,
waitForAnswer BOOLEAN DEFAULT 0,
isError BOOLEAN NOT NULL DEFAULT 0,
thread_id UUID NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
parent_id UUID,
disable_feedback BOOLEAN NOT NULL DEFAULT false,
streaming BOOLEAN NOT NULL DEFAULT false,
wait_for_answer BOOLEAN DEFAULT false,
is_error BOOLEAN NOT NULL DEFAULT false,
metadata JSONB DEFAULT '{}',
tags TEXT[],
input TEXT,
output TEXT,
createdAt TEXT,
start TEXT,
end TEXT,
created_at TEXT,
start_time TEXT,
end_time TEXT,
generation JSONB,
showInput TEXT,
show_input TEXT,
language TEXT,
indent INT,
FOREIGN KEY (threadId) REFERENCES threads (id) ON DELETE CASCADE
indent INTEGER
)
"""))

await conn.execute(text("""
CREATE TABLE IF NOT EXISTS elements (
id UUID PRIMARY KEY,
threadId UUID,
thread_id UUID REFERENCES threads(id) ON DELETE CASCADE,
type TEXT,
url TEXT,
chainlitKey TEXT,
chainlit_key TEXT,
name TEXT NOT NULL,
display TEXT,
objectKey TEXT,
object_key TEXT,
size TEXT,
page INT,
page INTEGER,
language TEXT,
forId UUID,
mime TEXT,
FOREIGN KEY (threadId) REFERENCES threads (id) ON DELETE CASCADE
for_id UUID,
mime TEXT
)
"""))

await conn.execute(text("""
CREATE TABLE IF NOT EXISTS feedbacks (
id UUID PRIMARY KEY,
forId UUID NOT NULL,
value INT NOT NULL,
threadId UUID,
for_id UUID NOT NULL,
value INTEGER NOT NULL,
thread_id UUID,
comment TEXT
)
"""))

await conn.execute(text("""
CREATE TABLE IF NOT EXISTS settings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
id SERIAL PRIMARY KEY,
key TEXT UNIQUE,
value TEXT
)
"""))

# Create indexes
await conn.execute(text(
"CREATE INDEX IF NOT EXISTS idx_steps_threadId ON steps(threadId)"
"CREATE INDEX IF NOT EXISTS idx_steps_thread_id ON steps(thread_id)"
))
await conn.execute(text(
"CREATE INDEX IF NOT EXISTS idx_threads_createdAt ON threads(createdAt DESC)"
"CREATE INDEX IF NOT EXISTS idx_threads_created_at ON threads(created_at DESC)"
))
else:
# SQLite tables (existing schema)
Expand All @@ -156,20 +153,19 @@ async def create_tables(engine):
id TEXT PRIMARY KEY,
identifier TEXT NOT NULL UNIQUE,
metadata TEXT NOT NULL,
createdAt TEXT
created_at TEXT
)
"""))

await conn.execute(text("""
CREATE TABLE IF NOT EXISTS threads (
id TEXT PRIMARY KEY,
createdAt TEXT,
created_at TEXT,
name TEXT,
userId TEXT,
userIdentifier TEXT,
user_id TEXT REFERENCES users(id) ON DELETE CASCADE,
user_identifier TEXT,
tags TEXT,
metadata TEXT NOT NULL DEFAULT '{}',
FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE
metadata TEXT NOT NULL DEFAULT '{}'
)
"""))

Expand All @@ -178,52 +174,50 @@ async def create_tables(engine):
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL,
threadId TEXT NOT NULL,
parentId TEXT,
disableFeedback BOOLEAN NOT NULL DEFAULT 0,
streaming BOOLEAN NOT NULL DEFAULT 0,
waitForAnswer BOOLEAN DEFAULT 0,
isError BOOLEAN NOT NULL DEFAULT 0,
thread_id TEXT NOT NULL REFERENCES threads(id) ON DELETE CASCADE,
parent_id TEXT,
disable_feedback INTEGER NOT NULL DEFAULT 0,
streaming INTEGER NOT NULL DEFAULT 0,
wait_for_answer INTEGER DEFAULT 0,
is_error INTEGER NOT NULL DEFAULT 0,
metadata TEXT DEFAULT '{}',
tags TEXT,
input TEXT,
output TEXT,
createdAt TEXT,
start TEXT,
end TEXT,
created_at TEXT,
start_time TEXT,
end_time TEXT,
generation TEXT,
showInput TEXT,
show_input TEXT,
language TEXT,
indent INT,
FOREIGN KEY (threadId) REFERENCES threads (id) ON DELETE CASCADE
indent INTEGER
)
"""))

await conn.execute(text("""
CREATE TABLE IF NOT EXISTS elements (
id TEXT PRIMARY KEY,
threadId TEXT,
thread_id TEXT REFERENCES threads(id) ON DELETE CASCADE,
type TEXT,
url TEXT,
chainlitKey TEXT,
chainlit_key TEXT,
name TEXT NOT NULL,
display TEXT,
objectKey TEXT,
object_key TEXT,
size TEXT,
page INT,
page INTEGER,
language TEXT,
forId TEXT,
mime TEXT,
FOREIGN KEY (threadId) REFERENCES threads (id) ON DELETE CASCADE
for_id TEXT,
mime TEXT
)
"""))

await conn.execute(text("""
CREATE TABLE IF NOT EXISTS feedbacks (
id TEXT PRIMARY KEY,
forId TEXT NOT NULL,
value INT NOT NULL,
threadId TEXT,
for_id TEXT NOT NULL,
value INTEGER NOT NULL,
thread_id TEXT,
comment TEXT
)
"""))
Expand All @@ -238,16 +232,17 @@ async def create_tables(engine):

# Create indexes
await conn.execute(text(
"CREATE INDEX IF NOT EXISTS idx_steps_threadId ON steps(threadId)"
"CREATE INDEX IF NOT EXISTS idx_steps_thread_id ON steps(thread_id)"
))
await conn.execute(text(
"CREATE INDEX IF NOT EXISTS idx_threads_createdAt ON threads(createdAt DESC)"
"CREATE INDEX IF NOT EXISTS idx_threads_created_at ON threads(created_at DESC)"
))

logger.info(f"Successfully created tables for {dialect} database")
except Exception as e:
logger.error(f"Error creating tables: {str(e)}")
raise DatabaseError(f"Failed to create database tables: {str(e)}")
from sqlalchemy.exc import DatabaseError as SQLAlchemyDatabaseError
raise SQLAlchemyDatabaseError(statement=str(e), params=None, orig=e)

# Initialize the database
async def initialize_db():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "PraisonAI"
version = "1.0.3"
version = "1.0.4"
description = "PraisonAI application combines AutoGen and CrewAI or similar frameworks into a low-code solution for building and managing multi-agent LLM systems, focusing on simplicity, customization, and efficient human-agent collaboration."
authors = ["Mervin Praison"]
license = ""
Expand Down

0 comments on commit 0077ffe

Please sign in to comment.