mirror of
https://github.com/StanGirard/quivr.git
synced 2024-08-17 00:50:37 +03:00
feat: use user openai key if defined
This commit is contained in:
parent
09c3022c6d
commit
2d3b77b37b
@ -7,6 +7,7 @@ from models.brains import Brain
|
|||||||
from models.files import File
|
from models.files import File
|
||||||
from models.settings import common_dependencies
|
from models.settings import common_dependencies
|
||||||
from models.users import User
|
from models.users import User
|
||||||
|
from repository.user_identity.get_user_identity import get_user_identity
|
||||||
from utils.file import convert_bytes, get_file_size
|
from utils.file import convert_bytes, get_file_size
|
||||||
from utils.processors import filter_file
|
from utils.processors import filter_file
|
||||||
|
|
||||||
@ -59,12 +60,19 @@ async def upload_file(
|
|||||||
"type": "error",
|
"type": "error",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
openai_api_key = request.headers.get("Openai-Api-Key", None)
|
||||||
|
if openai_api_key is None:
|
||||||
|
openai_api_key = brain.get_brain_details()["openai_api_key"]
|
||||||
|
|
||||||
|
if openai_api_key is None:
|
||||||
|
openai_api_key = get_user_identity(current_user.id).openai_api_key
|
||||||
|
|
||||||
message = await filter_file(
|
message = await filter_file(
|
||||||
commons,
|
commons,
|
||||||
file,
|
file,
|
||||||
enable_summarization,
|
enable_summarization,
|
||||||
brain_id=brain_id,
|
brain_id=brain_id,
|
||||||
openai_api_key=request.headers.get("Openai-Api-Key", None),
|
openai_api_key=openai_api_key,
|
||||||
)
|
)
|
||||||
|
|
||||||
return message
|
return message
|
||||||
|
Loading…
Reference in New Issue
Block a user