Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sofia Collections
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
ecolab
LIRIAe
Sofia Collections
Commits
335e8b3f
Commit
335e8b3f
authored
7 months ago
by
Andréas Livet
Browse files
Options
Downloads
Patches
Plain Diff
chat : adapt to the new sofia chat format and handle empty docs
parent
457d3e30
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/app/api/routes/chat.py
+8
-2
8 additions, 2 deletions
backend/app/api/routes/chat.py
with
8 additions
and
2 deletions
backend/app/api/routes/chat.py
+
8
−
2
View file @
335e8b3f
...
@@ -80,7 +80,9 @@ async def transform_sofia_chat_response(
...
@@ -80,7 +80,9 @@ async def transform_sofia_chat_response(
async
for
line
in
sofia_chat_response
:
async
for
line
in
sofia_chat_response
:
# Response is in json
# Response is in json
res
=
json
.
loads
(
line
)
res
=
json
.
loads
(
line
)
content_list
,
document_list_str
,
rephrased_query
,
year_list
=
res
content_list
=
res
[
"
history
"
]
document_list_str
=
res
[
"
docs_html
"
]
rephrased_query
=
res
[
"
output_query
"
]
document_list
=
json
.
loads
(
document_list_str
)
document_list
=
json
.
loads
(
document_list_str
)
if
rephrased_query
and
not
has_send_rephrased_query
:
if
rephrased_query
and
not
has_send_rephrased_query
:
has_send_rephrased_query
=
True
has_send_rephrased_query
=
True
...
@@ -90,7 +92,11 @@ async def transform_sofia_chat_response(
...
@@ -90,7 +92,11 @@ async def transform_sofia_chat_response(
"
query
"
:
rephrased_query
,
"
query
"
:
rephrased_query
,
}
,
}
,
}
)
}
$$$
\n
"""
}
)
}
$$$
\n
"""
if
len
(
document_list
)
>
0
and
not
has_send_documents
:
# If there is no relevant document, document_list will be : ['No document to show.']
if
len
(
document_list
)
==
1
and
type
(
document_list
[
0
])
is
str
:
has_send_documents
=
True
viewer_sources
=
[]
elif
len
(
document_list
)
>
0
and
not
has_send_documents
:
viewer_sources
=
[
viewer_sources
=
[
{
{
"
id
"
:
doc
[
"
document_id
"
]
"
id
"
:
doc
[
"
document_id
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment