HugoVoxx commited on
Commit
11695a5
·
verified ·
1 Parent(s): 15bcbe6

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from reader import Reader
3
+ from utils import *
4
+
5
+ OUTPUT_FOLDER = 'ag4mout'
6
+
7
+ def geogeosolver(question:str, model:str):
8
+ if model == 'gpt-4o-mini':
9
+ get_github_token()
10
+ elif model == 'gemma2-9b-it':
11
+ get_grog_api()
12
+ reader = Reader(model=model)
13
+ input = translate(question)
14
+ reader.main(input)
15
+ run_ag()
16
+ image_path = f'{OUTPUT_FOLDER}/output.png'
17
+ result_dict = read_solution()
18
+ key_list = list(result_dict.keys())
19
+ premises = result_dict[key_list[0]]
20
+ constructions = result_dict[key_list[1]]
21
+ steps = result_dict[key_list[2]]
22
+ return image_path, premises, constructions, steps
23
+
24
+ if __name__ == '__main__':
25
+ with gr.Blocks() as demo:
26
+ with gr.Row():
27
+ with gr.Column():
28
+ question = gr.Textbox(lines=1, placeholder="Hãy nhập đề bài cần giải", label="Đề bài")
29
+ model = gr.Radio(["gpt-4o-mini", "gemma2-9b-it"], value = "gpt-4o-mini", label="Mô hình")
30
+ solve_button = gr.Button(value="Giải")
31
+ with gr.Column():
32
+ image = gr.Image(type="filepath", label="Hình Vẽ")
33
+ premises = gr.Textbox(lines=3, label="Các Giả Thuyết của Đề Bài")
34
+ constructions = gr.Textbox(lines=3, label="Các điểm được dựng thêm")
35
+ steps = gr.Textbox(lines=3, label="Các Bước Giải")
36
+ solve_button.click(geogeosolver, inputs=[question, model], outputs=[image, premises, constructions, steps])
37
+ example = gr.Examples(
38
+ examples = [
39
+ 'Cho tam giác ABC nhọn, vẽ các đường cao AD, BE, CF. Gọi H là trực tâm của tam giác. Gọi M, N, P, Q lần lượt là các hình chiếu vuông góc của D lên AB, BE, CF, AC. Chứng minh: tứ giác BMND nội tiếp.',
40
+ 'Cho tam giác ABC có ba góc nhọn nội tiếp đường tròn (O). Các đường cao AD, BE, CF cắt nhau tại H và cắt đường tròn (O) lần lượt tại M,N,P. Chứng minh rằng: Tứ giác CEHD nội tiếp.',
41
+ ],
42
+ inputs = [question],
43
+ )
44
+ demo.launch(share=True)