Compare commits

..

2 Commits

Author SHA1 Message Date
github-actions[bot] 9852e7399c Release 0.3.21 (#459)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-12-06 16:41:24 +07:00
Marcus Schiesser 95227a7539 feat: add simple query endpoint (#458) 2024-12-06 16:12:52 +07:00
4 changed files with 34 additions and 1 deletions
+6
View File
@@ -1,5 +1,11 @@
# create-llama
## 0.3.21
### Patch Changes
- 95227a7: Add query endpoint
## 0.3.20
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "create-llama",
"version": "0.3.20",
"version": "0.3.21",
"description": "Create LlamaIndex-powered apps with one command",
"keywords": [
"rag",
@@ -3,11 +3,13 @@ from fastapi import APIRouter
from .chat import chat_router # noqa: F401
from .chat_config import config_router # noqa: F401
from .upload import file_upload_router # noqa: F401
from .query import query_router # noqa: F401
api_router = APIRouter()
api_router.include_router(chat_router, prefix="/chat")
api_router.include_router(config_router, prefix="/chat/config")
api_router.include_router(file_upload_router, prefix="/chat/upload")
api_router.include_router(query_router, prefix="/query")
# Dynamically adding additional routers if they exist
try:
@@ -0,0 +1,25 @@
import logging
from fastapi import APIRouter
from app.engine.index import IndexConfig, get_index
from llama_index.core.base.base_query_engine import BaseQueryEngine
query_router = r = APIRouter()
logger = logging.getLogger("uvicorn")
def get_query_engine() -> BaseQueryEngine:
index_config = IndexConfig(**{})
index = get_index(index_config)
return index.as_query_engine()
@r.get("/")
async def query_request(
query: str,
) -> str:
query_engine = get_query_engine()
response = await query_engine.aquery(query)
return response.response