forked from janhq/jan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Chore disable git submodule for web-client and app-backend * Chore add newest source code of app-backend and web-client --------- Co-authored-by: Hien To <[email protected]>
- Loading branch information
Showing
282 changed files
with
17,895 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
[submodule "web-client"] | ||
path = web-client | ||
url = ../jan-web.git | ||
[submodule "app-backend"] | ||
path = app-backend | ||
url = ../app-backend.git | ||
[submodule "jan-inference/sd/sd_cpp"] | ||
path = jan-inference/sd/sd_cpp | ||
url = https://github.com/leejet/stable-diffusion.cpp |
Submodule app-backend
deleted from
4c44ef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
.env | ||
.env_postgresql | ||
worker/node_modules/.mf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
## Jan Backend | ||
|
||
A Hasura Data API Platform designed to provide APIs for client interaction with the Language Model (LLM) through chat or the generation of art using Stable Diffusion. It is encapsulated within a Docker container for easy local deployment | ||
|
||
## Quickstart | ||
1. Run docker up | ||
|
||
```bash | ||
docker compose up | ||
``` | ||
|
||
2. Install [HasuraCLI](https://hasura.io/docs/latest/hasura-cli/overview/) | ||
|
||
3. Open Hasura Console | ||
|
||
```bash | ||
cd hasura && hasura console | ||
``` | ||
|
||
4. Apply Migration | ||
|
||
```bash | ||
hasura migrate apply | ||
``` | ||
|
||
5. Apply Metadata | ||
|
||
```bash | ||
hasura metadata apply | ||
``` | ||
|
||
6. Apply seeds | ||
|
||
```bash | ||
hasura seed apply | ||
``` | ||
|
||
## Hasura One Click Deploy | ||
Use this URL to deploy this app to Hasura Cloud | ||
|
||
[![Hasura Deploy](https://hasura.io/deploy-button.svg)](https://cloud.hasura.io/deploy?github_repo=https://github.com/janhq/app-backend/&hasura_dir=/hasura) | ||
|
||
[One-click deploy docs](https://hasura.io/docs/latest/getting-started/getting-started-cloud/) | ||
|
||
## Modify schema & model | ||
[Hasura Tutorials](https://hasura.io/docs/latest/resources/tutorials/index/) | ||
|
||
## Events & Workers | ||
|
||
Serverless function (Cloudflare worker) to stream llm message & update | ||
|
||
Readmore about Hasura Events here: | ||
> https://hasura.io/docs/latest/event-triggers/serverless/ | ||
## Deploy Worker | ||
```bash | ||
npx wrangler deploy | ||
``` | ||
[Cloudflare Worker Guide](https://developers.cloudflare.com/workers/get-started/guide/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
version: "3.6" | ||
services: | ||
postgres: | ||
image: postgres:13 | ||
restart: always | ||
volumes: | ||
- db_data:/var/lib/postgresql/data | ||
env_file: | ||
- .env_postgresql | ||
graphql-engine: | ||
image: hasura/graphql-engine:v2.31.0.cli-migrations-v3 | ||
ports: | ||
- "8080:8080" | ||
restart: always | ||
env_file: | ||
- .env | ||
volumes: | ||
- ./hasura/migrations:/migrations | ||
- ./hasura/metadata:/metadata | ||
depends_on: | ||
data-connector-agent: | ||
condition: service_healthy | ||
|
||
data-connector-agent: | ||
image: hasura/graphql-data-connector:v2.31.0 | ||
restart: always | ||
ports: | ||
- 8081:8081 | ||
environment: | ||
QUARKUS_LOG_LEVEL: ERROR # FATAL, ERROR, WARN, INFO, DEBUG, TRACE | ||
## https://quarkus.io/guides/opentelemetry#configuration-reference | ||
QUARKUS_OPENTELEMETRY_ENABLED: "false" | ||
## QUARKUS_OPENTELEMETRY_TRACER_EXPORTER_OTLP_ENDPOINT: http://jaeger:4317 | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:8081/api/v1/athena/health"] | ||
interval: 5s | ||
timeout: 10s | ||
retries: 5 | ||
start_period: 5s | ||
worker: | ||
build: | ||
context: ./worker | ||
dockerfile: ./Dockerfile | ||
restart: always | ||
environment: | ||
- "NODE_ENV=development" | ||
volumes: | ||
- ./worker:/worker | ||
ports: | ||
- "8787:8787" | ||
volumes: | ||
db_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 3 | ||
endpoint: http://localhost:8080 | ||
admin_secret: myadminsecretkey | ||
metadata_directory: metadata | ||
actions: | ||
kind: synchronous | ||
handler_webhook_baseurl: http://localhost:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
type Mutation { | ||
imageGeneration( | ||
input: ImageGenerationInput! | ||
): ImageGenerationOutput | ||
} | ||
|
||
input ImageGenerationInput { | ||
prompt: String! | ||
neg_prompt: String! | ||
model: String! | ||
seed: Int! | ||
steps: Int! | ||
width: Int! | ||
height: Int! | ||
} | ||
|
||
type ImageGenerationOutput { | ||
url: String! | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
actions: | ||
- name: imageGeneration | ||
definition: | ||
kind: synchronous | ||
handler: '{{HASURA_ACTION_STABLE_DIFFUSION_URL}}' | ||
request_transform: | ||
body: | ||
action: transform | ||
template: |- | ||
{ | ||
"prompt": {{$body.input.input.prompt}}, | ||
"neg_prompt": {{$body.input.input.neg_prompt}}, | ||
"unet_model": {{$body.input.input.model}}, | ||
"seed": {{$body.input.input.seed}}, | ||
"steps": {{$body.input.input.steps}}, | ||
"width": {{$body.input.input.width}}, | ||
"height": {{$body.input.input.height}} | ||
} | ||
method: POST | ||
query_params: {} | ||
template_engine: Kriti | ||
url: '{{$base_url}}/inferences/txt2img' | ||
version: 2 | ||
permissions: | ||
- role: user | ||
custom_types: | ||
enums: [] | ||
input_objects: | ||
- name: ImageGenerationInput | ||
objects: | ||
- name: ImageGenerationOutput | ||
scalars: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
dataconnector: | ||
athena: | ||
uri: http://data-connector-agent:8081/api/v1/athena | ||
mariadb: | ||
uri: http://data-connector-agent:8081/api/v1/mariadb | ||
mysql8: | ||
uri: http://data-connector-agent:8081/api/v1/mysql | ||
oracle: | ||
uri: http://data-connector-agent:8081/api/v1/oracle | ||
snowflake: | ||
uri: http://data-connector-agent:8081/api/v1/snowflake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- name: jandb | ||
kind: postgres | ||
configuration: | ||
connection_info: | ||
database_url: | ||
from_env: PG_DATABASE_URL | ||
isolation_level: read-committed | ||
use_prepared_statements: false | ||
tables: "!include jandb/tables/tables.yaml" |
43 changes: 43 additions & 0 deletions
43
app-backend/hasura/metadata/databases/jandb/tables/public_collection_products.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
table: | ||
name: collection_products | ||
schema: public | ||
array_relationships: | ||
- name: collections | ||
using: | ||
manual_configuration: | ||
column_mapping: | ||
collection_id: id | ||
insertion_order: null | ||
remote_table: | ||
name: collections | ||
schema: public | ||
- name: products | ||
using: | ||
manual_configuration: | ||
column_mapping: | ||
product_id: id | ||
insertion_order: null | ||
remote_table: | ||
name: products | ||
schema: public | ||
select_permissions: | ||
- role: public | ||
permission: | ||
columns: | ||
- created_at | ||
- updated_at | ||
- collection_id | ||
- id | ||
- product_id | ||
filter: {} | ||
comment: "" | ||
- role: user | ||
permission: | ||
columns: | ||
- created_at | ||
- updated_at | ||
- collection_id | ||
- id | ||
- product_id | ||
filter: {} | ||
comment: "" |
36 changes: 36 additions & 0 deletions
36
app-backend/hasura/metadata/databases/jandb/tables/public_collections.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
table: | ||
name: collections | ||
schema: public | ||
array_relationships: | ||
- name: collection_products | ||
using: | ||
manual_configuration: | ||
column_mapping: | ||
id: collection_id | ||
insertion_order: null | ||
remote_table: | ||
name: collection_products | ||
schema: public | ||
select_permissions: | ||
- role: public | ||
permission: | ||
columns: | ||
- slug | ||
- description | ||
- name | ||
- created_at | ||
- updated_at | ||
- id | ||
filter: {} | ||
comment: "" | ||
- role: user | ||
permission: | ||
columns: | ||
- slug | ||
- description | ||
- name | ||
- created_at | ||
- updated_at | ||
- id | ||
filter: {} | ||
comment: "" |
68 changes: 68 additions & 0 deletions
68
app-backend/hasura/metadata/databases/jandb/tables/public_conversations.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
table: | ||
name: conversations | ||
schema: public | ||
object_relationships: | ||
- name: conversation_product | ||
using: | ||
manual_configuration: | ||
column_mapping: | ||
product_id: id | ||
insertion_order: null | ||
remote_table: | ||
name: products | ||
schema: public | ||
array_relationships: | ||
- name: conversation_messages | ||
using: | ||
manual_configuration: | ||
column_mapping: | ||
id: conversation_id | ||
insertion_order: null | ||
remote_table: | ||
name: messages | ||
schema: public | ||
insert_permissions: | ||
- role: user | ||
permission: | ||
check: | ||
user_id: | ||
_eq: X-Hasura-User-Id | ||
columns: | ||
- last_image_url | ||
- last_text_message | ||
- product_id | ||
- user_id | ||
comment: "" | ||
select_permissions: | ||
- role: user | ||
permission: | ||
columns: | ||
- last_image_url | ||
- last_text_message | ||
- user_id | ||
- created_at | ||
- updated_at | ||
- id | ||
- product_id | ||
filter: | ||
user_id: | ||
_eq: X-Hasura-User-Id | ||
comment: "" | ||
update_permissions: | ||
- role: user | ||
permission: | ||
columns: | ||
- last_image_url | ||
- last_text_message | ||
filter: | ||
user_id: | ||
_eq: X-Hasura-User-Id | ||
check: null | ||
comment: "" | ||
delete_permissions: | ||
- role: user | ||
permission: | ||
filter: | ||
user_id: | ||
_eq: X-Hasura-User-Id | ||
comment: "" |
Oops, something went wrong.