Spaces:
Runtime error
Runtime error
shigeru saito
commited on
Commit
·
d5613f1
1
Parent(s):
02a3819
アイコンの追加
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import gradio as gr
|
|
| 2 |
import openai
|
| 3 |
import requests
|
| 4 |
import os
|
| 5 |
-
import fileinput
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
|
| 8 |
title="松原仁美AI(β)"
|
|
@@ -83,17 +82,36 @@ class NajiminoAI:
|
|
| 83 |
|
| 84 |
@classmethod
|
| 85 |
def generate(cls, user_message):
|
| 86 |
-
|
|
|
|
| 87 |
return result
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
def main():
|
| 90 |
iface = gr.Interface(fn=NajiminoAI.generate,
|
| 91 |
inputs=gr.Textbox(label=inputs_label),
|
| 92 |
-
outputs=gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
title=title,
|
| 94 |
description=description,
|
| 95 |
-
article=article
|
| 96 |
-
allow_flagging='never'
|
| 97 |
)
|
| 98 |
|
| 99 |
iface.launch()
|
|
|
|
| 2 |
import openai
|
| 3 |
import requests
|
| 4 |
import os
|
|
|
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
|
| 7 |
title="松原仁美AI(β)"
|
|
|
|
| 82 |
|
| 83 |
@classmethod
|
| 84 |
def generate(cls, user_message):
|
| 85 |
+
response = OpenAI.chat_completion(prompt=user_message)
|
| 86 |
+
result = outputs_label_HTML.format(outputs=response)
|
| 87 |
return result
|
| 88 |
|
| 89 |
+
|
| 90 |
+
outputs_label_HTML = '''
|
| 91 |
+
<div id="component-0" class="block svelte-90oupt padded" style="border-style: solid; overflow: scroll; min-width: min(160px, 100%); border-width: var(--block-border-width);">
|
| 92 |
+
<label class="svelte-1kcgrqr container">
|
| 93 |
+
<img src="/file/static/hitomi-matsubara.png" alt="User Icon" style="width: 50px; height: 50px; border-radius: 50%; float: left; margin-right: 10px;">
|
| 94 |
+
<span>
|
| 95 |
+
松原仁美(AI)がお答えします。
|
| 96 |
+
</span>
|
| 97 |
+
<textarea data-testid="textbox" class="scroll-hide svelte-1kcgrqr" dir="ltr" placeholder="" rows="4" disabled
|
| 98 |
+
style="overflow-y: scroll; border-radius: 0 20px 20px 20px; height: 300px; width: calc(100% - 60px);">{outputs}</textarea>
|
| 99 |
+
</label>
|
| 100 |
+
</div>
|
| 101 |
+
'''
|
| 102 |
+
|
| 103 |
def main():
|
| 104 |
iface = gr.Interface(fn=NajiminoAI.generate,
|
| 105 |
inputs=gr.Textbox(label=inputs_label),
|
| 106 |
+
outputs=gr.HTML(outputs_label_HTML.format(outputs="")),
|
| 107 |
+
examples=[
|
| 108 |
+
"あなたはどこのどなたで、何をされてる方ですか?",
|
| 109 |
+
"資産持ちって何ですか?",
|
| 110 |
+
"講座について教えてください。",
|
| 111 |
+
],
|
| 112 |
title=title,
|
| 113 |
description=description,
|
| 114 |
+
article=article
|
|
|
|
| 115 |
)
|
| 116 |
|
| 117 |
iface.launch()
|