Skip to content

Commit 16f9405

Browse files
committed
fix typing
1 parent 9e5149e commit 16f9405

File tree

3 files changed

+27
-33
lines changed

3 files changed

+27
-33
lines changed

backend/danswer/one_shot_answer/answer_question.py

+19-26
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
def stream_answer_objects(
8484
query_req: DirectQARequest,
8585
user: User | None,
86-
temporary_persona: Persona | None,
8786
# These need to be passed in because in Web UI one shot flow,
8887
# we can have much more document as there is no history.
8988
# For Slack flow, we need to save more tokens for the thread context
@@ -99,6 +98,7 @@ def stream_answer_objects(
9998
retrieval_metrics_callback: (
10099
Callable[[RetrievalMetricsContainer], None] | None
101100
) = None,
101+
temporary_persona: Persona | None = None,
102102
rerank_metrics_callback: Callable[[RerankMetricsContainer], None] | None = None,
103103
) -> AnswerObjectIterator:
104104
"""Streams in order:
@@ -184,33 +184,27 @@ def stream_answer_objects(
184184
max_tokens=max_document_tokens,
185185
)
186186

187-
contains_tool = True
188187
if temporary_persona:
189-
contains_tool = False
190188
for tool in temporary_persona.tools:
191189
if tool.in_code_tool_id == "SearchTool":
192-
contains_tool = True
190+
pass
193191

194-
search_tool = (
195-
SearchTool(
196-
db_session=db_session,
197-
user=user,
198-
evaluation_type=LLMEvaluationType.SKIP
199-
if DISABLE_LLM_DOC_RELEVANCE
200-
else query_req.evaluation_type,
201-
persona=persona,
202-
retrieval_options=query_req.retrieval_options,
203-
prompt_config=prompt_config,
204-
llm=llm,
205-
fast_llm=fast_llm,
206-
pruning_config=document_pruning_config,
207-
bypass_acl=bypass_acl,
208-
chunks_above=query_req.chunks_above,
209-
chunks_below=query_req.chunks_below,
210-
full_doc=query_req.full_doc,
211-
)
212-
if contains_tool
213-
else None
192+
search_tool = SearchTool(
193+
db_session=db_session,
194+
user=user,
195+
evaluation_type=LLMEvaluationType.SKIP
196+
if DISABLE_LLM_DOC_RELEVANCE
197+
else query_req.evaluation_type,
198+
persona=persona,
199+
retrieval_options=query_req.retrieval_options,
200+
prompt_config=prompt_config,
201+
llm=llm,
202+
fast_llm=fast_llm,
203+
pruning_config=document_pruning_config,
204+
bypass_acl=bypass_acl,
205+
chunks_above=query_req.chunks_above,
206+
chunks_below=query_req.chunks_below,
207+
full_doc=query_req.full_doc,
214208
)
215209

216210
answer_config = AnswerStyleConfig(
@@ -230,9 +224,8 @@ def stream_answer_objects(
230224
ForceUseTool(
231225
tool_name=search_tool.name,
232226
args={"query": rephrased_query},
227+
force_use=True,
233228
)
234-
if search_tool
235-
else None
236229
),
237230
# for now, don't use tool calling for this flow, as we haven't
238231
# tested quotes with tool calling too much yet

backend/danswer/one_shot_answer/models.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any
2+
13
from pydantic import BaseModel
24
from pydantic import Field
35
from pydantic import model_validator
@@ -8,9 +10,9 @@
810
from danswer.chat.models import QADocsResponse
911
from danswer.configs.constants import MessageType
1012
from danswer.db.models import StarterMessage
13+
from danswer.search.enums import LLMEvaluationType
1114
from danswer.search.enums import RecencyBiasSetting
1215
from danswer.search.enums import SearchType
13-
from danswer.search.enums import LLMEvaluationType
1416
from danswer.search.models import ChunkContext
1517
from danswer.search.models import RerankingDetails
1618
from danswer.search.models import RetrievalDetails
@@ -40,13 +42,13 @@ class DocumentSetConfig(BaseModel):
4042

4143

4244
class ToolConfig(BaseModel):
43-
id: int | None = None
45+
id: int
4446

4547

4648
class PersonaConfig(BaseModel):
4749
name: str
4850
description: str
49-
search_type: SearchType = SearchType.HYBRID
51+
search_type: SearchType = SearchType.SEMANTIC
5052
num_chunks: float | None = None
5153
llm_relevance_filter: bool = False
5254
llm_filter_extraction: bool = False
@@ -67,11 +69,10 @@ class PersonaConfig(BaseModel):
6769

6870
class DirectQARequest(ChunkContext):
6971
persona_config: PersonaConfig | None = None
70-
persona_id: int | None = None
72+
persona_id: int
7173

7274
messages: list[ThreadMessage]
7375
prompt_id: int | None
74-
persona_id: int
7576
multilingual_query_expansion: list[str] | None = None
7677
retrieval_options: RetrievalDetails = Field(default_factory=RetrievalDetails)
7778
rerank_settings: RerankingDetails | None = None

backend/danswer/server/query_and_chat/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class RenameChatSessionResponse(BaseModel):
136136
class ChatSessionDetails(BaseModel):
137137
id: int
138138
name: str
139-
persona_id: int
139+
persona_id: int | None = None
140140
time_created: str
141141
shared_status: ChatSessionSharedStatus
142142
folder_id: int | None = None
@@ -196,7 +196,7 @@ class SearchSessionDetailResponse(BaseModel):
196196
class ChatSessionDetailResponse(BaseModel):
197197
chat_session_id: int
198198
description: str
199-
persona_id: int
199+
persona_id: int | None = None
200200
persona_name: str
201201
messages: list[ChatMessageDetail]
202202
time_created: datetime

0 commit comments

Comments
 (0)