mirror of
https://github.com/imartinez/privateGPT.git
synced 2025-09-23 12:07:12 +00:00
fix: Remove global state (#1216)
* Remove all global settings state * chore: remove autogenerated class * chore: cleanup * chore: merge conflicts
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
from typing import Literal
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from private_gpt.di import root_injector
|
||||
from private_gpt.open_ai.extensions.context_filter import ContextFilter
|
||||
from private_gpt.server.chunks.chunks_service import Chunk, ChunksService
|
||||
from private_gpt.server.utils.auth import authenticated
|
||||
@@ -25,7 +24,7 @@ class ChunksResponse(BaseModel):
|
||||
|
||||
|
||||
@chunks_router.post("/chunks", tags=["Context Chunks"])
|
||||
def chunks_retrieval(body: ChunksBody) -> ChunksResponse:
|
||||
def chunks_retrieval(request: Request, body: ChunksBody) -> ChunksResponse:
|
||||
"""Given a `text`, returns the most relevant chunks from the ingested documents.
|
||||
|
||||
The returned information can be used to generate prompts that can be
|
||||
@@ -45,7 +44,7 @@ def chunks_retrieval(body: ChunksBody) -> ChunksResponse:
|
||||
`/ingest/list` endpoint. If you want all ingested documents to be used,
|
||||
remove `context_filter` altogether.
|
||||
"""
|
||||
service = root_injector.get(ChunksService)
|
||||
service = request.state.injector.get(ChunksService)
|
||||
results = service.retrieve_relevant(
|
||||
body.text, body.context_filter, body.limit, body.prev_next_chunks
|
||||
)
|
||||
|
Reference in New Issue
Block a user