zcodel commited on
Commit
0609008
·
verified ·
1 Parent(s): 1b4eeea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -1,20 +1,23 @@
1
  import gradio as gr
2
  import pandas as pd
 
 
 
 
 
3
 
4
  def generate_solutions(query):
5
- # Dummy function to simulate solution generation
6
- # Replace with your actual logic for generating solutions
7
- solutions = [
8
- {"Solution": "Check the power supply", "Link": "https://example.com/power-supply"},
9
- {"Solution": "Inspect the wiring", "Link": "https://example.com/wiring-inspection"},
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 with clickable links
17
- table_html = df.to_html(escape=False, index=False, render_links=True)
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 precisely, and get an organized table of suggested solutions with web links."
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
+