ll7098ll commited on
Commit
3b4323a
ยท
verified ยท
1 Parent(s): 4a76e3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -16
app.py CHANGED
@@ -64,34 +64,27 @@ def generate_curriculum(topic):
64
 
65
  prompt = [
66
  SYSTEM_PROMPT,
67
- f"**ํ™œ๋™ ์ฃผ์ œ:** {topic}",
68
  "**ํ™œ๋™:**",
69
  ]
70
-
71
- # Progress bar initialization
72
- progress_bar = gr.Progress(track_literals=True)
73
- total_steps = 10 # You can adjust this based on expected response length
74
 
 
75
  collected_text = ""
76
- for i, token in enumerate(model.generate_content(prompt, stream=True)):
77
  chunk = token.text
78
  collected_text += chunk
79
- progress_bar(i/total_steps, desc="Generating curriculum...") # Update progress bar
80
- time.sleep(0.01) # Simulate processing time
81
-
82
- return collected_text
83
 
84
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
85
  iface = gr.Interface(
86
  fn=generate_curriculum,
87
- inputs=gr.Textbox(lines=3, label="ํ™œ๋™ ์ฃผ์ œ ์ž…๋ ฅ"),
88
- outputs=gr.Textbox(lines=10, label="๊ฒŒ์ด๋ฏธํ”ผ์ผ€์ด์…˜ ์ˆ˜์—… ์„ค๊ณ„"),
89
- title="๊ฒŒ์ด๋ฏธํ”ผ์ผ€์ด์…˜ ์ˆ˜์—… ์„ค๊ณ„ ๋„์šฐ๋ฏธ",
90
- description="์„ ์ƒ๋‹˜์ด ํ™œ๋™ ์ฃผ์ œ๋ฅผ ์ž…๋ ฅํ•˜์‹œ๋ฉด ๊ฒŒ์ด๋ฏธํ”ผ์ผ€์ด์…˜ ์š”์†Œ๋ฅผ ํฌํ•จํ•˜์—ฌ ์ˆ˜์—…์„ ๊ตฌ์ฒด์ ์œผ๋กœ ์„ค๊ณ„ํ•ด์ค๋‹ˆ๋‹ค.",
91
  examples=[
92
  ["์ž„์ง„์™œ๋ž€"],
93
- ["์‹๋ฌผ์˜ ๊ตฌ์กฐ"],
94
- ["ํƒœ์–‘๊ณ„"]
95
  ]
96
  )
97
 
 
64
 
65
  prompt = [
66
  SYSTEM_PROMPT,
67
+ f"**ํ™œ๋™ ์ปจ์…‰:** {achievement_standard}",
68
  "**ํ™œ๋™:**",
69
  ]
 
 
 
 
70
 
71
+ response = model.generate_content(prompt, stream=True)
72
  collected_text = ""
73
+ for token in response:
74
  chunk = token.text
75
  collected_text += chunk
76
+ yield collected_text # ์‹ค์‹œ๊ฐ„ ์ถœ๋ ฅ์„ ์œ„ํ•ด yield ์‚ฌ์šฉ
77
+ time.sleep(0.03) # ์ถœ๋ ฅ ์†๋„ ์กฐ์ ˆ
 
 
78
 
79
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
80
  iface = gr.Interface(
81
  fn=generate_curriculum,
82
+ inputs=gr.Textbox(lines=1, label="ํ™œ๋™ ์ฃผ์ œ ์ž…๋ ฅ"),
83
+ outputs=gr.Textbox(lines=10, label="๊ฒŒ์ด๋ฏธํ”ผ์ผ€์ด์…˜ ์ˆ˜์—… ์„ค๊ณ„"),
84
+ title="๊ฒŒ์ด๋ฏธํ”ผ์ผ€์ด์…˜ ์ˆ˜์—… ์„ค๊ณ„ ๋„์šฐ๋ฏธ",
85
+ description="์„ ์ƒ๋‹˜์ด ํ™œ๋™ ์ฃผ์ œ๋ฅผ ์ž…๋ ฅํ•˜์‹œ๋ฉด ๊ฒŒ์ด๋ฏธํ”ผ์ผ€์ด์…˜ ์š”์†Œ๋ฅผ ํฌํ•จํ•˜์—ฌ ์ˆ˜์—…์„ ๊ตฌ์ฒด์ ์œผ๋กœ ์„ค๊ณ„ํ•ด์ค๋‹ˆ๋‹ค.",
86
  examples=[
87
  ["์ž„์ง„์™œ๋ž€"],
 
 
88
  ]
89
  )
90