mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-06-04 03:29:16 +02:00
fixes for summarizers
This commit is contained in:
parent
cb7802c509
commit
c60e8af3af
@ -83,9 +83,11 @@ class TextSummarizationHuggingChat(DVMTaskInterface):
|
|||||||
for evt in evts:
|
for evt in evts:
|
||||||
prompt += evt.content() + "\n"
|
prompt += evt.content() + "\n"
|
||||||
|
|
||||||
|
clean_prompt = re.sub(r'^https?:\/\/.*[\r\n]*', '', prompt, flags=re.MULTILINE)
|
||||||
options = {
|
options = {
|
||||||
"prompt": prompt,
|
"prompt": clean_prompt[:4000],
|
||||||
}
|
}
|
||||||
|
|
||||||
request_form['options'] = json.dumps(options)
|
request_form['options'] = json.dumps(options)
|
||||||
|
|
||||||
return request_form
|
return request_form
|
||||||
@ -102,14 +104,11 @@ class TextSummarizationHuggingChat(DVMTaskInterface):
|
|||||||
cookies = sign.login()
|
cookies = sign.login()
|
||||||
sign.saveCookiesToDir(cookie_path_dir)
|
sign.saveCookiesToDir(cookie_path_dir)
|
||||||
|
|
||||||
|
|
||||||
options = DVMTaskInterface.set_options(request_form)
|
options = DVMTaskInterface.set_options(request_form)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
chatbot = hugchat.ChatBot(cookies=cookies.get_dict()) # or cookie_path="usercookies/<email>.json"
|
chatbot = hugchat.ChatBot(cookies=cookies.get_dict()) # or cookie_path="usercookies/<email>.json"
|
||||||
text = re.sub(r'^https?:\/\/.*[\r\n]*', '', str(options["prompt"]), flags=re.MULTILINE)
|
query_result = chatbot.query("Summarize the following notes: " + str(options["prompt"]))
|
||||||
|
|
||||||
query_result = chatbot.query("Summarize the following notes: " + text[:3500])
|
|
||||||
print(query_result["text"]) # or query_result.text or query_result["text"]
|
print(query_result["text"]) # or query_result.text or query_result["text"]
|
||||||
return str(query_result["text"]).lstrip()
|
return str(query_result["text"]).lstrip()
|
||||||
|
|
||||||
@ -118,7 +117,6 @@ class TextSummarizationHuggingChat(DVMTaskInterface):
|
|||||||
raise Exception(e)
|
raise Exception(e)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# We build an example here that we can call by either calling this file directly from the main directory,
|
# We build an example here that we can call by either calling this file directly from the main directory,
|
||||||
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
|
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
|
||||||
# playground or elsewhere
|
# playground or elsewhere
|
||||||
|
@ -84,9 +84,9 @@ class SummarizationUnleashedChat(DVMTaskInterface):
|
|||||||
for evt in evts:
|
for evt in evts:
|
||||||
prompt += evt.content() + "\n"
|
prompt += evt.content() + "\n"
|
||||||
|
|
||||||
prompt = re.sub(r'http\S+', '', prompt)
|
clean_prompt = re.sub(r'^https?:\/\/.*[\r\n]*', '', prompt, flags=re.MULTILINE)
|
||||||
options = {
|
options = {
|
||||||
"prompt": prompt,
|
"prompt": clean_prompt[:4000],
|
||||||
"nostr": nostr_mode,
|
"nostr": nostr_mode,
|
||||||
}
|
}
|
||||||
request_form['options'] = json.dumps(options)
|
request_form['options'] = json.dumps(options)
|
||||||
@ -108,9 +108,8 @@ class SummarizationUnleashedChat(DVMTaskInterface):
|
|||||||
|
|
||||||
for model in client.models.list():
|
for model in client.models.list():
|
||||||
print('- ' + model.id)
|
print('- ' + model.id)
|
||||||
text = re.sub(r'^https?:\/\/.*[\r\n]*', '', str(options["prompt"]), flags=re.MULTILINE)
|
|
||||||
|
|
||||||
content = "Summarize the following notes: " + text[:3500]
|
content = "Summarize the following notes: " + str(options["prompt"])
|
||||||
normal_stream = client.chat.completions.create(
|
normal_stream = client.chat.completions.create(
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
@ -148,7 +147,6 @@ def build_example(name, identifier, admin_config):
|
|||||||
dvm_config.SEND_FEEDBACK_EVENTS = True
|
dvm_config.SEND_FEEDBACK_EVENTS = True
|
||||||
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
|
||||||
|
|
||||||
nip89info = {
|
nip89info = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"image": "https://unleashed.chat/_app/immutable/assets/hero.pehsu4x_.jpeg",
|
"image": "https://unleashed.chat/_app/immutable/assets/hero.pehsu4x_.jpeg",
|
||||||
@ -164,9 +162,9 @@ def build_example(name, identifier, admin_config):
|
|||||||
admin_config2 = AdminConfig()
|
admin_config2 = AdminConfig()
|
||||||
admin_config2.REBROADCAST_NIP89 = False
|
admin_config2.REBROADCAST_NIP89 = False
|
||||||
|
|
||||||
return SummarizationUnleashedChat(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config2)
|
return SummarizationUnleashedChat(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
process_venv(SummarizationUnleashedChat)
|
process_venv(SummarizationUnleashedChat)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user