Spaces:
Sleeping
Sleeping
text extraction
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
import requests
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from spiralfilm import FilmCore, FilmConfig
|
| 6 |
|
|
@@ -8,6 +9,11 @@ from spiralfilm import FilmCore, FilmConfig
|
|
| 8 |
def greet(name):
|
| 9 |
return "こんにちは " + name + "さん!! \n僕はパスカルくんだよ。よろしくね"
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
async def summarize(input_text: str, input_url: str):
|
| 13 |
if input_text:
|
|
@@ -51,7 +57,10 @@ async def chat(input_text, input_url):
|
|
| 51 |
headers = {'API-Key': os.environ.get("TWINROOM_API_KEY")}
|
| 52 |
json_payload = json.dumps(payload)
|
| 53 |
response = requests.post(endpoint, headers=headers, data=json_payload)
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
with gr.Blocks() as iface:
|
| 57 |
# UI
|
|
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
import requests
|
| 4 |
+
import re
|
| 5 |
import gradio as gr
|
| 6 |
from spiralfilm import FilmCore, FilmConfig
|
| 7 |
|
|
|
|
| 9 |
def greet(name):
|
| 10 |
return "こんにちは " + name + "さん!! \n僕はパスカルくんだよ。よろしくね"
|
| 11 |
|
| 12 |
+
def extract_texts(input_str):
|
| 13 |
+
pattern = r"msg='([^']*)'"
|
| 14 |
+
matches = re.findall(pattern, input_str)
|
| 15 |
+
return matches
|
| 16 |
+
|
| 17 |
|
| 18 |
async def summarize(input_text: str, input_url: str):
|
| 19 |
if input_text:
|
|
|
|
| 57 |
headers = {'API-Key': os.environ.get("TWINROOM_API_KEY")}
|
| 58 |
json_payload = json.dumps(payload)
|
| 59 |
response = requests.post(endpoint, headers=headers, data=json_payload)
|
| 60 |
+
|
| 61 |
+
response_msgs = extract_texts(response.text)
|
| 62 |
+
|
| 63 |
+
return ''.join(response_msgs)
|
| 64 |
|
| 65 |
with gr.Blocks() as iface:
|
| 66 |
# UI
|