openfree commited on
Commit
dde0f10
ยท
verified ยท
1 Parent(s): 0aa641f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -125,20 +125,22 @@ def do_web_search(query: str) -> str:
125
  summary_lines.append(
126
  f"### Result {idx}: {title}\n\n"
127
  f"{snippet}\n\n"
128
- f"**Source**: [{displayed_link}]({link})\n\n"
129
  f"---\n"
130
  )
131
 
132
  # ๋ชจ๋ธ์—๊ฒŒ ๋ช…ํ™•ํ•œ ์ง€์นจ ์ถ”๊ฐ€
133
  instructions = """
134
- # Web Search Results
135
- Below are the search results. Please refer to the title, snippet, and source link of each result when answering:
136
- 1. Cite the sources explicitly in your answer (e.g., "According to [Source Title](link)...").
137
- 2. Incorporate information from multiple sources.
 
 
138
  """
139
 
140
  search_results = instructions + "\n".join(summary_lines)
141
- logger.info(f"Processed {len(limited_organic)} search results")
142
  return search_results
143
 
144
  except Exception as e:
@@ -498,12 +500,13 @@ def run(
498
  ws_result = do_web_search(ws_query)
499
  combined_system_msg += f"[Search top-20 Full Items Based on user prompt]\n{ws_result}\n\n"
500
  # >>> ์ถ”๊ฐ€๋œ ์•ˆ๋‚ด ๋ฌธ๊ตฌ (๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ์˜ link ๋“ฑ ์ถœ์ฒ˜๋ฅผ ํ™œ์šฉ)
501
- combined_system_msg += "[Note: Use the above search results and their links as sources when answering.]\n\n"
502
  combined_system_msg += """
503
- [Important Instructions]
504
- 1. Cite the sources found in the search results using markdown links, e.g., "[Source Title](link)".
505
- 2. Combine information from multiple sources in your answer.
506
- 3. At the end of your answer, add a "References:" section listing the key source links.
 
507
  """
508
  else:
509
  combined_system_msg += "[No valid keywords found, skipping WebSearch]\n\n"
@@ -541,7 +544,7 @@ def run(
541
 
542
  streamer = TextIteratorStreamer(processor, timeout=30.0, skip_prompt=True, skip_special_tokens=True)
543
  gen_kwargs = dict(
544
- inputs=inputs,
545
  streamer=streamer,
546
  max_new_tokens=max_new_tokens,
547
  )
@@ -556,7 +559,7 @@ def run(
556
 
557
  except Exception as e:
558
  logger.error(f"Error in run: {str(e)}")
559
- yield f"Sorry, an error occurred: {str(e)}"
560
 
561
  finally:
562
  # ์ž„์‹œ ํŒŒ์ผ ์‚ญ์ œ
@@ -577,6 +580,7 @@ def run(
577
  clear_cuda_cache()
578
 
579
 
 
580
  ##############################################################################
581
  # ์˜ˆ์‹œ๋“ค (๋ชจ๋‘ ์˜์–ด๋กœ)
582
  ##############################################################################
@@ -767,11 +771,12 @@ title_html = """
767
  <h1 align="center" style="margin-bottom: 0.2em; font-size: 1.6em;"> ๐Ÿค— Gemma3-R1984-27B </h1>
768
  <p align="center" style="font-size:1.1em; color:#555;">
769
  โœ…Agentic AI Platform โœ…Reasoning & Uncensored โœ…Multimodal & VLM โœ…Deep-Research & RAG <br>
770
- Operates on an NVIDIA A100 GPU as an independent local server, enhancing security and preventing information leakage.<br>
771
  @Based by 'MS Gemma-3-27b' / @Powered by 'MOUSE-II'(VIDRAFT)
772
  </p>
773
  """
774
 
 
775
  with gr.Blocks(css=css, title="Gemma3-R1984-27B") as demo:
776
  gr.Markdown(title_html)
777
 
 
125
  summary_lines.append(
126
  f"### Result {idx}: {title}\n\n"
127
  f"{snippet}\n\n"
128
+ f"**์ถœ์ฒ˜**: [{displayed_link}]({link})\n\n"
129
  f"---\n"
130
  )
131
 
132
  # ๋ชจ๋ธ์—๊ฒŒ ๋ช…ํ™•ํ•œ ์ง€์นจ ์ถ”๊ฐ€
133
  instructions = """
134
+ # ์›น ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ
135
+ ์•„๋ž˜๋Š” ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค. ์งˆ๋ฌธ์— ๋‹ต๋ณ€ํ•  ๋•Œ ์ด ์ •๋ณด๋ฅผ ํ™œ์šฉํ•˜์„ธ์š”:
136
+ 1. ๊ฐ ๊ฒฐ๊ณผ์˜ ์ œ๋ชฉ, ๋‚ด์šฉ, ์ถœ์ฒ˜ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”
137
+ 2. ๋‹ต๋ณ€์— ๊ด€๋ จ ์ •๋ณด์˜ ์ถœ์ฒ˜๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ ์ธ์šฉํ•˜์„ธ์š” (์˜ˆ: "X ์ถœ์ฒ˜์— ๋”ฐ๋ฅด๋ฉด...")
138
+ 3. ์‘๋‹ต์— ์‹ค์ œ ์ถœ์ฒ˜ ๋งํฌ๋ฅผ ํฌํ•จํ•˜์„ธ์š”
139
+ 4. ์—ฌ๋Ÿฌ ์ถœ์ฒ˜์˜ ์ •๋ณด๋ฅผ ์ข…ํ•ฉํ•˜์—ฌ ๋‹ต๋ณ€ํ•˜์„ธ์š”
140
  """
141
 
142
  search_results = instructions + "\n".join(summary_lines)
143
+ logger.info(f"๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ {len(limited_organic)}๊ฐœ ์ฒ˜๋ฆฌ ์™„๋ฃŒ")
144
  return search_results
145
 
146
  except Exception as e:
 
500
  ws_result = do_web_search(ws_query)
501
  combined_system_msg += f"[Search top-20 Full Items Based on user prompt]\n{ws_result}\n\n"
502
  # >>> ์ถ”๊ฐ€๋œ ์•ˆ๋‚ด ๋ฌธ๊ตฌ (๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ์˜ link ๋“ฑ ์ถœ์ฒ˜๋ฅผ ํ™œ์šฉ)
503
+ combined_system_msg += "[์ฐธ๊ณ : ์œ„ ๊ฒ€์ƒ‰๊ฒฐ๊ณผ ๋‚ด์šฉ๊ณผ link๋ฅผ ์ถœ์ฒ˜๋กœ ์ธ์šฉํ•˜์—ฌ ๋‹ต๋ณ€ํ•ด ์ฃผ์„ธ์š”.]\n\n"
504
  combined_system_msg += """
505
+ [์ค‘์š” ์ง€์‹œ์‚ฌํ•ญ]
506
+ 1. ๋‹ต๋ณ€์— ๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ์—์„œ ์ฐพ์€ ์ •๋ณด์˜ ์ถœ์ฒ˜๋ฅผ ๋ฐ˜๋“œ์‹œ ์ธ์šฉํ•˜์„ธ์š”.
507
+ 2. ์ถœ์ฒ˜ ์ธ์šฉ ์‹œ "[์ถœ์ฒ˜ ์ œ๋ชฉ](๋งํฌ)" ํ˜•์‹์˜ ๋งˆํฌ๋‹ค์šด ๋งํฌ๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.
508
+ 3. ์—ฌ๋Ÿฌ ์ถœ์ฒ˜์˜ ์ •๋ณด๋ฅผ ์ข…ํ•ฉํ•˜์—ฌ ๋‹ต๋ณ€ํ•˜์„ธ์š”.
509
+ 4. ๋‹ต๋ณ€ ๋งˆ์ง€๋ง‰์— "์ฐธ๊ณ  ์ž๋ฃŒ:" ์„น์…˜์„ ์ถ”๊ฐ€ํ•˜๊ณ  ์‚ฌ์šฉํ•œ ์ฃผ์š” ์ถœ์ฒ˜ ๋งํฌ๋ฅผ ๋‚˜์—ดํ•˜์„ธ์š”.
510
  """
511
  else:
512
  combined_system_msg += "[No valid keywords found, skipping WebSearch]\n\n"
 
544
 
545
  streamer = TextIteratorStreamer(processor, timeout=30.0, skip_prompt=True, skip_special_tokens=True)
546
  gen_kwargs = dict(
547
+ inputs,
548
  streamer=streamer,
549
  max_new_tokens=max_new_tokens,
550
  )
 
559
 
560
  except Exception as e:
561
  logger.error(f"Error in run: {str(e)}")
562
+ yield f"์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค. ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค: {str(e)}"
563
 
564
  finally:
565
  # ์ž„์‹œ ํŒŒ์ผ ์‚ญ์ œ
 
580
  clear_cuda_cache()
581
 
582
 
583
+
584
  ##############################################################################
585
  # ์˜ˆ์‹œ๋“ค (๋ชจ๋‘ ์˜์–ด๋กœ)
586
  ##############################################################################
 
771
  <h1 align="center" style="margin-bottom: 0.2em; font-size: 1.6em;"> ๐Ÿค— Gemma3-R1984-27B </h1>
772
  <p align="center" style="font-size:1.1em; color:#555;">
773
  โœ…Agentic AI Platform โœ…Reasoning & Uncensored โœ…Multimodal & VLM โœ…Deep-Research & RAG <br>
774
+ Operates on an โœ…'NVIDIA A100 GPU' as an independent local server, enhancing security and preventing information leakage.<br>
775
  @Based by 'MS Gemma-3-27b' / @Powered by 'MOUSE-II'(VIDRAFT)
776
  </p>
777
  """
778
 
779
+
780
  with gr.Blocks(css=css, title="Gemma3-R1984-27B") as demo:
781
  gr.Markdown(title_html)
782