Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Memri
plugins
RSS importer
Commits
07a4d830
Commit
07a4d830
authored
1 year ago
by
Alp Deniz Ogut
Browse files
Options
Download
Email Patches
Plain Diff
Code format
parent
f22c9933
Pipeline
#14986
passed with stages
in 1 minute and 41 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rss_importer/app.py
+7
-5
rss_importer/app.py
rss_importer/plugin.py
+5
-5
rss_importer/plugin.py
with
12 additions
and
10 deletions
+12
-10
rss_importer/app.py
+
7
-
5
View file @
07a4d830
...
...
@@ -140,17 +140,19 @@ def get_feeds(
feeds
=
[
n
for
n
in
feeds
if
n
.
id
==
feed_id
]
return
feeds
class
RSSFeedChat
(
BaseModel
):
messages
:
list
[
dict
]
index_name
:
str
=
"rss_feed"
category
:
str
=
"all"
@
app
.
post
(
"/feed/chat"
)
def
feed_chat
(
re
q
:
RSSFeedChat
,
plugin
:
RSSImporter
=
Depends
(
get_plugin
)
):
return
StreamingResponse
(
plugin
.
feed_chat
(
req
.
index_name
,
req
.
messages
,
req
.
category
),
media_type
=
"text/event-stream"
)
def
feed_chat
(
req
:
RSSFeedChat
,
plugin
:
RSSImporter
=
Depends
(
get_plugin
)):
re
turn
StreamingResponse
(
plugin
.
feed_chat
(
req
.
index_name
,
req
.
messages
,
req
.
category
),
media_type
=
"text/event-stream"
,
)
@
app
.
get
(
"/update_all_feeds"
)
...
...
This diff is collapsed.
Click to expand it.
rss_importer/plugin.py
+
5
-
5
View file @
07a4d830
...
...
@@ -312,12 +312,10 @@ Ensure the output is a one-level bullet list without additional text.
return
summary
def
feed_chat
(
self
,
index_name
,
messages
,
category_text
=
None
):
index_query
=
messages
[
-
1
][
'
content
'
]
index_query
=
messages
[
-
1
][
"
content
"
]
if
category_text
is
not
None
and
category_text
!=
"all"
:
index_query
=
f
"
{
index_query
}
{
category_text
}
"
print
(
f
"Sending chat request with query:
{
index_query
}
"
)
print
(
f
"Sending chat request with query:
{
index_query
}
"
)
rss_client_kwargs
=
{
"url"
:
RSS_POD_URL
,
"owner_key"
:
RSS_OWNER_KEY
,
...
...
@@ -331,6 +329,7 @@ Ensure the output is a one-level bullet list without additional text.
logger
.
error
(
f
"Error during chat request stream:
{
e
}
"
)
return
None
def
bulletize_summary
(
summary
:
str
)
->
str
:
"""Converts a summary to a bulletized list per sentence."""
nltk
.
download
(
"punkt"
,
quiet
=
True
)
...
...
@@ -375,6 +374,7 @@ def chat_request(index_name, messages, pod_client_kwargs, index_query=None):
logger
.
error
(
f
"JSON decoding failed for LLM reply:
{
r
}
"
)
return
reply
def
chat_request_stream
(
index_name
,
messages
,
pod_client_kwargs
,
index_query
=
None
):
data
:
dict
=
{
"index_name"
:
index_name
,
...
...
@@ -388,7 +388,7 @@ def chat_request_stream(index_name, messages, pod_client_kwargs, index_query=Non
f
"
{
MEMRI_BOT_URL
}
/v1/memory/chat"
,
json
=
data
,
timeout
=
120
,
stream
=
True
).
iter_lines
():
if
r
:
yield
r
+
b
'
\n
'
yield
r
+
b
"
\n
"
def
semantic_index_request
(
ids
:
list
[
str
],
documents
:
list
[
str
]):
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets