mirror of
https://github.com/run-llama/create-llama.git
synced 2026-07-19 23:13:36 -04:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9852e7399c | |||
| 95227a7539 |
@@ -1,5 +1,11 @@
|
||||
# create-llama
|
||||
|
||||
## 0.3.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 95227a7: Add query endpoint
|
||||
|
||||
## 0.3.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+1
-1
@@ -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
|
||||
Reference in New Issue
Block a user