Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,30 @@
|
|
1 |
import gradio as gr
|
2 |
# from humanize import paraphrase_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
with gr.Blocks() as demo:
|
5 |
gr.Markdown("# Polygraf Writer")
|
@@ -52,7 +77,7 @@ with gr.Blocks() as demo:
|
|
52 |
gr.Markdown("Penalizes shorter outputs.")
|
53 |
|
54 |
process_button.click(
|
55 |
-
fn=
|
56 |
inputs=[
|
57 |
input_topic,
|
58 |
model_dropdown,
|
|
|
1 |
import gradio as gr
|
2 |
# from humanize import paraphrase_text
|
3 |
+
from gradio_client import Client
|
4 |
+
from ai_generate import generate
|
5 |
+
|
6 |
+
client = Client("polygraf-ai/Humanizer")
|
7 |
+
def humanize(
|
8 |
+
text,
|
9 |
+
model,
|
10 |
+
temperature=1.2,
|
11 |
+
repetition_penalty=1,
|
12 |
+
top_k=50,
|
13 |
+
length_penalty=1,
|
14 |
+
)
|
15 |
+
ai_text = generate(f"Write an article about the topic: {text}")
|
16 |
+
print(f"AI Generated: {ai_text}")
|
17 |
+
ai_text = ai_text["choices"][0]["message"]["content"]
|
18 |
+
result = client.predict(
|
19 |
+
text=text,
|
20 |
+
model_name=model,
|
21 |
+
temperature=temperature,
|
22 |
+
repetition_penalty=repetition_penalty,
|
23 |
+
top_k=top_k,
|
24 |
+
length_penalty=length_penalty,
|
25 |
+
api_name="/paraphrase_text"
|
26 |
+
)
|
27 |
+
return result
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
gr.Markdown("# Polygraf Writer")
|
|
|
77 |
gr.Markdown("Penalizes shorter outputs.")
|
78 |
|
79 |
process_button.click(
|
80 |
+
fn=humanize,
|
81 |
inputs=[
|
82 |
input_topic,
|
83 |
model_dropdown,
|