Mustafiz996 commited on
Commit
044ec3a
·
verified ·
1 Parent(s): b95bbab

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +113 -112
README.md CHANGED
@@ -1,112 +1,113 @@
1
- ---
2
- tags: [gradio-custom-component, SimpleTextbox, gradio-spreadsheet-custom-component]
3
- title: gradio_spreadsheetcomponent
4
- short_description: This component answers questions about spreadsheets.
5
- colorFrom: blue
6
- colorTo: yellow
7
- sdk: gradio
8
- pinned: false
9
- app_file: space.py
10
- ---
11
-
12
- # `gradio_spreadsheetcomponent`
13
- <a href="https://pypi.org/project/gradio_spreadsheetcomponent/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_spreadsheetcomponent"></a>
14
-
15
- This component is used to answer questions about spreadsheets.
16
-
17
- ## Installation
18
-
19
- ```bash
20
- pip install gradio_spreadsheetcomponent
21
- ```
22
-
23
- ## Usage
24
-
25
- ```python
26
- import gradio as gr
27
- from gradio_spreadsheetcomponent import SpreadsheetComponent
28
- from dotenv import load_dotenv
29
- import os
30
- import pandas as pd
31
-
32
- def answer_question(file, question):
33
- if not file or not question:
34
- return "Please upload a file and enter a question."
35
-
36
- # Load the spreadsheet data
37
- df = pd.read_excel(file.name)
38
-
39
- # Create a SpreadsheetComponent instance
40
- spreadsheet = SpreadsheetComponent(value=df)
41
-
42
- # Use the component to answer the question
43
- return spreadsheet.answer_question(question)
44
-
45
- with gr.Blocks() as demo:
46
- gr.Markdown("# Spreadsheet Question Answering")
47
-
48
- with gr.Row():
49
- file_input = gr.File(label="Upload Spreadsheet", file_types=[".xlsx"])
50
- question_input = gr.Textbox(label="Ask a Question")
51
-
52
- answer_output = gr.Textbox(label="Answer", interactive=False, lines=4)
53
-
54
- submit_button = gr.Button("Submit")
55
- submit_button.click(answer_question, inputs=[file_input, question_input], outputs=answer_output)
56
-
57
-
58
- if __name__ == "__main__":
59
- demo.launch()
60
-
61
- ```
62
-
63
- ## `SpreadsheetComponent`
64
-
65
- ### Initialization
66
-
67
- <table>
68
- <thead>
69
- <tr>
70
- <th align="left">name</th>
71
- <th align="left" style="width: 25%;">type</th>
72
- <th align="left">default</th>
73
- <th align="left">description</th>
74
- </tr>
75
- </thead>
76
- <tbody>
77
- <tr>
78
- <td align="left"><code>value</code></td>
79
- <td align="left" style="width: 25%;">
80
-
81
- ```python
82
- pandas.core.frame.DataFrame | list | dict | None
83
- ```
84
-
85
- </td>
86
- <td align="left"><code>None</code></td>
87
- <td align="left">Default value to show in spreadsheet. Can be a pandas DataFrame, list of lists, or dictionary</td>
88
- </tr>
89
- </tbody></table>
90
-
91
-
92
-
93
-
94
- ### User function
95
-
96
- The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
97
-
98
- - When used as an Input, the component only impacts the input signature of the user function.
99
- - When used as an output, the component only impacts the return signature of the user function.
100
-
101
- The code snippet below is accurate in cases where the component is used as both an input and an output.
102
-
103
- - **As output:** Is passed, the preprocessed input data sent to the user's function in the backend.
104
-
105
-
106
- ```python
107
- def predict(
108
- value: typing.Any
109
- ) -> Unknown:
110
- return value
111
- ```
112
-
 
 
1
+ ---
2
+ tags: [gradio-custom-component, custom-component-track, gradio-spreadsheet-custom-component]
3
+ title: gradio_spreadsheetcomponent
4
+ short_description: This component answers questions about spreadsheets.
5
+ colorFrom: blue
6
+ colorTo: yellow
7
+ sdk: gradio
8
+ pinned: false
9
+ app_file: space.py
10
+ app_link: https://huggingface.co/spaces/Mustafiz996/gradio_spreadsheetcomponent
11
+ ---
12
+
13
+ # `gradio_spreadsheetcomponent`
14
+ <a href="https://pypi.org/project/gradio_spreadsheetcomponent/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_spreadsheetcomponent"></a>
15
+
16
+ This component is used to answer questions about spreadsheets.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install gradio_spreadsheetcomponent
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```python
27
+ import gradio as gr
28
+ from gradio_spreadsheetcomponent import SpreadsheetComponent
29
+ from dotenv import load_dotenv
30
+ import os
31
+ import pandas as pd
32
+
33
+ def answer_question(file, question):
34
+ if not file or not question:
35
+ return "Please upload a file and enter a question."
36
+
37
+ # Load the spreadsheet data
38
+ df = pd.read_excel(file.name)
39
+
40
+ # Create a SpreadsheetComponent instance
41
+ spreadsheet = SpreadsheetComponent(value=df)
42
+
43
+ # Use the component to answer the question
44
+ return spreadsheet.answer_question(question)
45
+
46
+ with gr.Blocks() as demo:
47
+ gr.Markdown("# Spreadsheet Question Answering")
48
+
49
+ with gr.Row():
50
+ file_input = gr.File(label="Upload Spreadsheet", file_types=[".xlsx"])
51
+ question_input = gr.Textbox(label="Ask a Question")
52
+
53
+ answer_output = gr.Textbox(label="Answer", interactive=False, lines=4)
54
+
55
+ submit_button = gr.Button("Submit")
56
+ submit_button.click(answer_question, inputs=[file_input, question_input], outputs=answer_output)
57
+
58
+
59
+ if __name__ == "__main__":
60
+ demo.launch()
61
+
62
+ ```
63
+
64
+ ## `SpreadsheetComponent`
65
+
66
+ ### Initialization
67
+
68
+ <table>
69
+ <thead>
70
+ <tr>
71
+ <th align="left">name</th>
72
+ <th align="left" style="width: 25%;">type</th>
73
+ <th align="left">default</th>
74
+ <th align="left">description</th>
75
+ </tr>
76
+ </thead>
77
+ <tbody>
78
+ <tr>
79
+ <td align="left"><code>value</code></td>
80
+ <td align="left" style="width: 25%;">
81
+
82
+ ```python
83
+ pandas.core.frame.DataFrame | list | dict | None
84
+ ```
85
+
86
+ </td>
87
+ <td align="left"><code>None</code></td>
88
+ <td align="left">Default value to show in spreadsheet. Can be a pandas DataFrame, list of lists, or dictionary</td>
89
+ </tr>
90
+ </tbody></table>
91
+
92
+
93
+
94
+
95
+ ### User function
96
+
97
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
98
+
99
+ - When used as an Input, the component only impacts the input signature of the user function.
100
+ - When used as an output, the component only impacts the return signature of the user function.
101
+
102
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
103
+
104
+ - **As output:** Is passed, the preprocessed input data sent to the user's function in the backend.
105
+
106
+
107
+ ```python
108
+ def predict(
109
+ value: typing.Any
110
+ ) -> Unknown:
111
+ return value
112
+ ```
113
+