Antoniskaraolis commited on
Commit
196e16f
·
verified ·
1 Parent(s): 789c0b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -18
app.py CHANGED
@@ -1,22 +1,11 @@
1
- import pandas as pd
2
- import gradio as gr
3
  from transformers import pipeline
4
 
5
- emails_df = pd.read_csv('emails.csv', nrows=500, on_bad_lines='skip')
6
- context = " ".join(emails_df['message'].apply(lambda x: x.strip() if isinstance(x, str) else ''))
7
 
8
- qa_pipeline = pipeline("question-answering")
 
 
9
 
10
- def answer_query(question):
11
- try:
12
- result = qa_pipeline(question=question, context=context)
13
- return result['answer']
14
- except Exception as e:
15
- return str(e)
16
-
17
- iface = gr.Interface(
18
- fn=answer_query,
19
- inputs=gr.Textbox(label="Enter your question:"),
20
- outputs=gr.Textbox(label="Answer:")
21
- )
22
- iface.launch()
 
 
 
1
  from transformers import pipeline
2
 
3
+ model_path = '/content/model_output'
4
+ text_gen = pipeline("text-generation", model=model_path, tokenizer=model_path)
5
 
6
+ def answer_question(question):
7
+ result = text_gen(question, max_length=100, num_return_sequences=1)
8
+ return result[0]['generated_text']
9
 
10
+ iface = gr.Interface(fn=answer_question, inputs="text", outputs="text")
11
+ iface.launch()