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