Update app.py
Browse files
app.py
CHANGED
@@ -244,6 +244,38 @@ app = gr.Interface(
|
|
244 |
outputs=["text", "number"],
|
245 |
)
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
####
|
248 |
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, TextIteratorStreamer
|
249 |
from threading import Thread
|
@@ -349,12 +381,12 @@ def topic_sale_inform (text):
|
|
349 |
#conversation = Conversation("Welcome")
|
350 |
|
351 |
def callChains(current_message):
|
352 |
-
final_answer = generate(current_message, 1.0, 256, 0.9, 1.0)
|
353 |
-
sentiment_analysis_result =
|
354 |
-
topic_sale_inform_result =
|
355 |
#conversation.append_response("The Big lebowski.")
|
356 |
#conversation.add_user_input("Is it good?")
|
357 |
-
|
358 |
return final_answer, sentiment_analysis_result, topic_sale_inform_result
|
359 |
|
360 |
|
@@ -366,7 +398,7 @@ topic_sale_inform_result_inputfield = gr.Textbox(label="Thema ")
|
|
366 |
|
367 |
chat_bot = gr.Interface(fn=callChains , inputs=current_message_inputfield, outputs=[final_answer_inputfield,sentiment_analysis_result_inputfield,topic_sale_inform_result_inputfield], title="Conversation Bot with extra")
|
368 |
# create a public link, set `share=True` in `launch()
|
369 |
-
chat_bot.launch()
|
370 |
####################
|
371 |
|
372 |
|
|
|
244 |
outputs=["text", "number"],
|
245 |
)
|
246 |
|
247 |
+
|
248 |
+
|
249 |
+
#####
|
250 |
+
tDeEn = pipeline(model="Helsinki-NLP/opus-mt-de-en")
|
251 |
+
tEnDe = pipeline(model="Helsinki-NLP/opus-mt-en-de")
|
252 |
+
bot = pipeline(model="google/flan-t5-large")
|
253 |
+
|
254 |
+
def solve(text,max_length,length_penalty,no_repeat_ngram_size,num_beams,language):
|
255 |
+
if(language=="Deutsch"):
|
256 |
+
text=tDeEn(text)[0]["translation_text"]
|
257 |
+
out=bot(text,max_length=max_length, length_penalty=length_penalty, no_repeat_ngram_size=no_repeat_ngram_size, num_beams=num_beams, early_stopping=True)[0]["generated_text"]
|
258 |
+
if(language=="Deutsch"):
|
259 |
+
out=tEnDe(out)[0]["translation_text"]
|
260 |
+
return out
|
261 |
+
|
262 |
+
task = gr.Interface(
|
263 |
+
fn=solve,
|
264 |
+
inputs=[
|
265 |
+
gr.Textbox(lines=5,max_lines=6,label="Frage"),
|
266 |
+
gr.Slider(minimum=1.0,maximum=200.0,value=50.0,step=1,interactive=True,label="max_length"),
|
267 |
+
gr.Slider(minimum=1.0,maximum=20.0,value=1.0,step=1,interactive=True,label="length_penalty"),
|
268 |
+
gr.Slider(minimum=0.0,maximum=5.0,value=3.0,step=1,interactive=True,label="no_repeat_ngram_size"),
|
269 |
+
gr.Slider(minimum=1.0,maximum=20.0,value=1.0,step=1,interactive=True,label="num_beams"),
|
270 |
+
gr.Dropdown(["Deutsch", "Englisch"],value="Deutsch"),
|
271 |
+
],
|
272 |
+
outputs="text",
|
273 |
+
title=title,
|
274 |
+
description=desc,
|
275 |
+
examples=examples
|
276 |
+
).launch()
|
277 |
+
|
278 |
+
|
279 |
####
|
280 |
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, TextIteratorStreamer
|
281 |
from threading import Thread
|
|
|
381 |
#conversation = Conversation("Welcome")
|
382 |
|
383 |
def callChains(current_message):
|
384 |
+
#final_answer = generate(current_message, 1.0, 256, 0.9, 1.0)
|
385 |
+
sentiment_analysis_result = pipeline_predict_sentiment(current_message)
|
386 |
+
topic_sale_inform_result = topic_sale_inform(current_message)
|
387 |
#conversation.append_response("The Big lebowski.")
|
388 |
#conversation.add_user_input("Is it good?")
|
389 |
+
final_answer = func(current_message)
|
390 |
return final_answer, sentiment_analysis_result, topic_sale_inform_result
|
391 |
|
392 |
|
|
|
398 |
|
399 |
chat_bot = gr.Interface(fn=callChains , inputs=current_message_inputfield, outputs=[final_answer_inputfield,sentiment_analysis_result_inputfield,topic_sale_inform_result_inputfield], title="Conversation Bot with extra")
|
400 |
# create a public link, set `share=True` in `launch()
|
401 |
+
#chat_bot.launch()
|
402 |
####################
|
403 |
|
404 |
|