summerstars commited on
Commit
586ee73
·
verified ·
1 Parent(s): a45220e

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -2
main.py CHANGED
@@ -100,8 +100,8 @@ async def main():
100
  """
101
  )
102
 
103
- with gr.Tab("文章の類似度計算"):
104
- gr.Markdown("## 2つの文章を入力して類似度を計算します")
105
  with gr.Row():
106
  text_input1 = gr.Textbox(label="文章1", lines=3, placeholder="例: 今日の天気は晴れです。")
107
  text_input2 = gr.Textbox(label="文章2", lines=3, placeholder="例: 今日は良い天気ですね。")
@@ -118,6 +118,9 @@ async def main():
118
  generate_button = gr.Button("ベクトルを生成", variant="primary")
119
  embeddings_output = gr.JSON(label="生成された埋め込みベクトル")
120
  generate_button.click(fn=get_embeddings, inputs=texts_input, outputs=embeddings_output)
 
 
 
121
 
122
  # --- 6. Gradioアプリの起動(高性能化: キュー拡張と同時実行制限増加) ---
123
  demo.queue(max_size=500, default_concurrency_limit=20) # キューサイズ拡大と同時実行制限増加
 
100
  """
101
  )
102
 
103
+ with gr.Tab("コンテキスト理解"):
104
+ gr.Markdown("## 2つの文章を入力して類似度を計算します(コンテキスト理解機能)")
105
  with gr.Row():
106
  text_input1 = gr.Textbox(label="文章1", lines=3, placeholder="例: 今日の天気は晴れです。")
107
  text_input2 = gr.Textbox(label="文章2", lines=3, placeholder="例: 今日は良い天気ですね。")
 
118
  generate_button = gr.Button("ベクトルを生成", variant="primary")
119
  embeddings_output = gr.JSON(label="生成された埋め込みベクトル")
120
  generate_button.click(fn=get_embeddings, inputs=texts_input, outputs=embeddings_output)
121
+
122
+ # カスタムAPIエンドポイントの追加: 2つのテキストの類似度計算を非同期で公開
123
+ gr.api(calculate_similarity, api_name="calculate_similarity")
124
 
125
  # --- 6. Gradioアプリの起動(高性能化: キュー拡張と同時実行制限増加) ---
126
  demo.queue(max_size=500, default_concurrency_limit=20) # キューサイズ拡大と同時実行制限増加