Skip to content
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

fix: various build runtime errors #25

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions core/ai-assistant-core.spec
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ a = Analysis(
['ai_assistant_core/main.py'],
pathex=[],
binaries=[],
datas=[],
datas=[
('ai_assistant_core/infrastructure/alembic/env.py', 'ai_assistant_core/infrastructure/alembic'),
('ai_assistant_core/infrastructure/alembic/versions/*', 'ai_assistant_core/infrastructure/alembic/versions'),
('ai_assistant_core/infrastructure/alembic.ini', 'ai_assistant_core/infrastructure')
],
hiddenimports=['tiktoken_ext.openai_public', 'tiktoken_ext'],
hookspath=[],
hookspath=['./pyinstaller_hooks'],
hooksconfig={},
runtime_hooks=[],
excludes=[],
Expand Down
18 changes: 0 additions & 18 deletions core/ai_assistant_core/infrastructure/alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
from logging.config import fileConfig

from sqlalchemy import engine_from_config
from sqlalchemy import pool

from alembic import context

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = None

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
Expand Down
28 changes: 28 additions & 0 deletions core/pyinstaller_hooks/hook-llama_cpp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# How to use this file
#
# 1. create a folder called "hooks" in your repo
# 2. copy this file there
# 3. add the --additional-hooks-dir flag to your pyinstaller command:
# ex: `pyinstaller --name binary-name --additional-hooks-dir=./hooks entry-point.py`

import os
import sys
from PyInstaller.utils.hooks import collect_data_files, get_package_paths


# Get the package path
package_path = get_package_paths("llama_cpp")[0]

# Collect data files
datas = collect_data_files("llama_cpp")

# Append the additional .dll or .so file
if os.name == "nt": # Windows
dll_path = os.path.join(package_path, "llama_cpp", "lib", "libllama.dll")
datas.append((dll_path, "llama_cpp"))
elif sys.platform == "darwin": # Mac
so_path = os.path.join(package_path, "llama_cpp", "lib", "libllama.dylib")
datas.append((so_path, "llama_cpp"))
elif os.name == "posix": # Linux
so_path = os.path.join(package_path, "llama_cpp", "lib", "libllama.so")
datas.append((so_path, "llama_cpp"))
11 changes: 11 additions & 0 deletions webapp/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { MainLayout } from '@/app/main-layout';
import { AppProps } from 'next/app';


export default function MyApp({ Component, pageProps }: AppProps): JSX.Element {
return (
<MainLayout>
<Component {...pageProps} />
</MainLayout>
);
}
12 changes: 4 additions & 8 deletions webapp/pages/thread/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';
import { useRouter } from 'next/router';
import { MainLayout } from '@/app/main-layout';
import AssistantThread from '@/app/_components/assistant-thread';
import RecentThreads from '@/app/_components/recent-threads';

Expand All @@ -9,13 +8,10 @@ export default function Page() {
const router = useRouter();

const id = typeof router.query.id === 'string' ? router.query.id : undefined;

return (
<MainLayout>
<main className="h-full flex flex-col">
<RecentThreads />
{ id && <AssistantThread threadId={id} /> }
</main>
</MainLayout>
<main className="h-full flex flex-col">
<RecentThreads />
{ id && <AssistantThread threadId={id} /> }
</main>
);
}
2 changes: 1 addition & 1 deletion webapp/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
"build": {
"beforeBuildCommand": "bash ./copy-assets.sh || pnpm run build:webapp",
"beforeBuildCommand": "pnpm build:webapp && bash ./copy-assets.sh",
"beforeDevCommand": "npm run dev:webapp",
"devPath": "http://localhost:3000",
"distDir": "../out"
Expand Down