File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed
templates/types/streaming/fastapi Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " create-llama " : patch
3+ ---
4+
5+ Make OpenAPI spec usable by custom GPTs
Original file line number Diff line number Diff line change @@ -16,7 +16,11 @@ def get_query_engine() -> BaseQueryEngine:
1616 return index .as_query_engine ()
1717
1818
19- @r .get ("/" )
19+ @r .get (
20+ "/" ,
21+ summary = "Call the get information from a knowledge base" ,
22+ description = "Get information from the knowledge base using a search query parameter" ,
23+ )
2024async def query_request (
2125 query : str ,
2226) -> str :
Original file line number Diff line number Diff line change 11# flake8: noqa: E402
22from app .config import DATA_DIR , STATIC_DIR
33from dotenv import load_dotenv
4+ import toml
45
56load_dotenv ()
67
1617from fastapi .responses import RedirectResponse
1718from fastapi .staticfiles import StaticFiles
1819
19- app = FastAPI ()
20-
2120init_settings ()
2221init_observability ()
2322
2423environment = os .getenv ("ENVIRONMENT" , "dev" ) # Default to 'development' if not set
2524logger = logging .getLogger ("uvicorn" )
2625
26+ servers = []
27+ # Add the fly.dev URL to the OpenAPI spec
28+ if os .path .exists ("fly.toml" ):
29+ try :
30+ with open ("fly.toml" ) as f :
31+ fly_config = toml .load (f )
32+ app_name = fly_config ["app" ]
33+ servers = [{"url" : f"https://{ app_name } .fly.dev" }]
34+ except Exception as e :
35+ logger .warning (f"Failed to read fly.toml: { e } " )
36+ app = FastAPI (servers = servers )
37+
2738
2839def mount_static_files (directory , path , html = False ):
2940 if os .path .exists (directory ):
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ aiostream = "^0.5.2"
2121cachetools = " ^5.3.3"
2222llama-index = " ^0.12.1"
2323rich = " ^13.9.4"
24+ toml = " ^0.10.2"
2425
2526[tool .poetry .group .dev .dependencies ]
2627mypy = " ^1.8.0"
You can’t perform that action at this time.
0 commit comments