Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import keras
|
2 |
import gradio as gr
|
|
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
|
5 |
link = hf_hub_download(repo_id="DiDiR6/GPT2Financial", filename="GPT2Financial_model.keras")
|
@@ -8,10 +9,25 @@ gpt2 = keras.models.load_model(link)
|
|
8 |
gpt2.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
|
9 |
|
10 |
def respond(message, chat_history):
|
|
|
|
|
11 |
bot_message = gpt2.generate(message)
|
12 |
return bot_message
|
13 |
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
1 |
import keras
|
2 |
import gradio as gr
|
3 |
+
from translate import Translator
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
|
6 |
link = hf_hub_download(repo_id="DiDiR6/GPT2Financial", filename="GPT2Financial_model.keras")
|
|
|
9 |
gpt2.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
|
10 |
|
11 |
def respond(message, chat_history):
|
12 |
+
translator = Translator(to_lang="en")
|
13 |
+
translation = translator.translate(message)
|
14 |
bot_message = gpt2.generate(message)
|
15 |
return bot_message
|
16 |
|
17 |
|
18 |
+
with gr.Blocks() as app:
|
19 |
+
gr.HTML("""
|
20 |
+
<div style='width: 100%; height: 300px; background: url("https://raw.githubusercontent.com/sxfiene/Finance_GPT/main/logo.png") no-repeat center center;'>
|
21 |
+
</div>
|
22 |
+
<h1 style='text-align:center; width=100%; margin-top=500px'>FinanceGPT</h1>
|
23 |
+
<h3 style='text-align:center;'>L'IA répondant à vos intérogations sur la finance</h3>
|
24 |
+
""")
|
25 |
+
with gr.Row():
|
26 |
+
question = gr.Textbox(label="Qu'est ce que voulez-vous savoir ?", placeholder="Saisissez ici votre demande...")
|
27 |
+
submit = gr.Button("Envoyer")
|
28 |
+
response = gr.Textbox(label="Réponse", interactive=False)
|
29 |
+
|
30 |
|
31 |
+
submit.click(fn=respond)
|
32 |
+
|
33 |
+
app.launch()
|