|
20 | 20 | import urllib.parse
|
21 | 21 |
|
22 | 22 | from app.models import ChatResponse, EmbeddingModel, HardwareInfo, ProjectInfo, ProjectModel, ProjectModelUpdate, QuestionModel, ChatModel, QuestionResponse, URLIngestModel, User, UserCreate, UserUpdate
|
23 |
| -from app.tools import FindFileLoader, IndexDocuments, ExtractKeywordsForMetadata, loadEnvVars |
| 23 | +from app.tools import FindFileLoader, IndexDocuments, ExtractKeywordsForMetadata, get_logger, loadEnvVars |
24 | 24 | from fastapi.staticfiles import StaticFiles
|
25 | 25 | from fastapi.middleware.cors import CORSMiddleware
|
26 | 26 | from app.vectordb import vector_delete_source, vector_delete_id, vector_find, vector_info, vector_init, vector_save, vector_urls
|
@@ -572,12 +572,17 @@ def question_project(
|
572 | 572 | sources = [{"content": doc.page_content,
|
573 | 573 | "keywords": doc.metadata["keywords"],
|
574 | 574 | "source": doc.metadata["source"]} for doc in docs]
|
575 |
| - |
576 |
| - return { |
| 575 | + |
| 576 | + output = { |
577 | 577 | "question": input.question,
|
578 | 578 | "answer": answer,
|
579 | 579 | "sources": sources,
|
580 |
| - "type": "question"} |
| 580 | + "type": "question" |
| 581 | + } |
| 582 | + |
| 583 | + get_logger("inference").info({"user": user.username, "output": output}) |
| 584 | + |
| 585 | + return output |
581 | 586 | except Exception as e:
|
582 | 587 | try:
|
583 | 588 | brain.semaphore.release()
|
@@ -605,12 +610,16 @@ def chat_project(
|
605 | 610 | "keywords": doc.metadata["keywords"],
|
606 | 611 | "source": doc.metadata["source"]} for doc in docs]
|
607 | 612 |
|
608 |
| - return { |
| 613 | + output = { |
609 | 614 | "question": input.question,
|
610 | 615 | "answer": answer,
|
611 | 616 | "id": chat.id,
|
612 | 617 | "sources": sources,
|
613 | 618 | "type": "chat"}
|
| 619 | + |
| 620 | + get_logger("inference").info({"user": user.username, "output": output}) |
| 621 | + |
| 622 | + return output |
614 | 623 | except Exception as e:
|
615 | 624 | try:
|
616 | 625 | brain.semaphore.release()
|
|
0 commit comments