Update app.py
Browse files
app.py
CHANGED
@@ -2,24 +2,24 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
4 |
|
5 |
-
# Initialize the Hugging Face pipeline
|
6 |
-
model_name = "
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
9 |
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
10 |
|
11 |
def generate_solutions(query):
|
12 |
# Use the language model to generate solutions
|
13 |
-
|
14 |
|
15 |
# Extract the generated texts
|
16 |
-
solutions = [{"Solution":
|
17 |
|
18 |
# Convert solutions to a DataFrame
|
19 |
df = pd.DataFrame(solutions)
|
20 |
|
21 |
-
# Convert DataFrame to HTML table
|
22 |
-
table_html = df.to_html(escape=False, index=False)
|
23 |
|
24 |
return table_html
|
25 |
|
@@ -29,7 +29,7 @@ iface = gr.Interface(
|
|
29 |
inputs=gr.Textbox(lines=2, placeholder="Describe the problem with the machine..."),
|
30 |
outputs=gr.HTML(),
|
31 |
title="Oroz: Your Industry Maintenance Assistant",
|
32 |
-
description="Describe the problem with your machine, and get an organized table of suggested solutions."
|
33 |
)
|
34 |
|
35 |
iface.launch(share=True)
|
|
|
2 |
import pandas as pd
|
3 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
4 |
|
5 |
+
# Initialize the Hugging Face pipeline with GPT-4 model
|
6 |
+
model_name = "EleutherAI/gpt-neo-2.7B" # Change to your desired GPT-4 model
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
9 |
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
10 |
|
11 |
def generate_solutions(query):
|
12 |
# Use the language model to generate solutions
|
13 |
+
responses = generator(query, max_length=100, num_return_sequences=3)
|
14 |
|
15 |
# Extract the generated texts
|
16 |
+
solutions = [{"Solution": response['generated_text'].strip(), "Link": "https://example.com"} for response in responses]
|
17 |
|
18 |
# Convert solutions to a DataFrame
|
19 |
df = pd.DataFrame(solutions)
|
20 |
|
21 |
+
# Convert DataFrame to HTML table with clickable links
|
22 |
+
table_html = df.to_html(escape=False, index=False, render_links=True)
|
23 |
|
24 |
return table_html
|
25 |
|
|
|
29 |
inputs=gr.Textbox(lines=2, placeholder="Describe the problem with the machine..."),
|
30 |
outputs=gr.HTML(),
|
31 |
title="Oroz: Your Industry Maintenance Assistant",
|
32 |
+
description="Describe the problem with your machine, and get an organized table of suggested solutions with web links."
|
33 |
)
|
34 |
|
35 |
iface.launch(share=True)
|