From 54287653298e18ef5661e3224958de0bb06d5864 Mon Sep 17 00:00:00 2001 From: Deven Patel Date: Fri, 3 Nov 2023 13:52:33 -0700 Subject: [PATCH] Beautify JSON docs (#906) Co-authored-by: Deven Patel --- docs/data-sources/json.mdx | 6 +++--- examples/rest-api/main.py | 19 ++++++++----------- examples/rest-api/models.py | 5 +++-- examples/rest-api/services.py | 3 +-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/docs/data-sources/json.mdx b/docs/data-sources/json.mdx index 5f243070..d4821638 100644 --- a/docs/data-sources/json.mdx +++ b/docs/data-sources/json.mdx @@ -12,7 +12,7 @@ Here are the supported sources for loading `json`: ``` If you would like to add other data structures (e.x. list, dict etc.), do: -``` +```python import json a = {"foo": "bar"} valid_json_string_data = json.dumps(a, indent=0) @@ -21,7 +21,7 @@ If you would like to add other data structures (e.x. list, dict etc.), do: valid_json_string_data = json.dumps(b, indent=0) ``` Example: -``` +```python import os from embedchain.apps.app import App @@ -43,7 +43,7 @@ print(response) "As of October 2023, Elon Musk's net worth is $255.2 billion." ``` temp.json -``` +```json { "question": "What is your net worth, Elon Musk?", "answer": "As of October 2023, Elon Musk's net worth is $255.2 billion, making him one of the wealthiest individuals in the world." diff --git a/examples/rest-api/main.py b/examples/rest-api/main.py index 70bb87fb..9b234104 100644 --- a/examples/rest-api/main.py +++ b/examples/rest-api/main.py @@ -1,19 +1,16 @@ -import os import logging +import os + import yaml -from fastapi import FastAPI, UploadFile, Depends, HTTPException +from database import Base, SessionLocal, engine +from fastapi import Depends, FastAPI, HTTPException, UploadFile +from models import DefaultResponse, DeployAppRequest, QueryApp, SourceApp +from services import get_app, get_apps, remove_app, save_app from sqlalchemy.orm import Session +from utils import generate_error_message_for_api_keys + from embedchain import Pipeline as App from embedchain.client import Client -from models import ( - QueryApp, - SourceApp, - DefaultResponse, - DeployAppRequest, -) -from database import Base, engine, SessionLocal -from services import get_app, save_app, get_apps, remove_app -from utils import generate_error_message_for_api_keys Base.metadata.create_all(bind=engine) diff --git a/examples/rest-api/models.py b/examples/rest-api/models.py index 7a359852..1aecf00a 100644 --- a/examples/rest-api/models.py +++ b/examples/rest-api/models.py @@ -1,7 +1,8 @@ from typing import Optional -from pydantic import BaseModel, Field -from sqlalchemy import Column, String, Integer + from database import Base +from pydantic import BaseModel, Field +from sqlalchemy import Column, Integer, String class QueryApp(BaseModel): diff --git a/examples/rest-api/services.py b/examples/rest-api/services.py index af2c984b..c200454b 100644 --- a/examples/rest-api/services.py +++ b/examples/rest-api/services.py @@ -1,6 +1,5 @@ -from sqlalchemy.orm import Session - from models import AppModel +from sqlalchemy.orm import Session def get_app(db: Session, app_id: str):