ginipick commited on
Commit
db3cf6b
ยท
verified ยท
1 Parent(s): d6f7a9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -13,10 +13,14 @@ import threading
13
  import json
14
  import re
15
 
 
16
  HF_TOKEN = os.getenv("HF_TOKEN")
17
- hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus-08-2024", token=HF_TOKEN)
18
  hf_api = HfApi(token=HF_TOKEN)
19
 
 
 
 
 
20
  def get_headers():
21
  if not HF_TOKEN:
22
  raise ValueError("Hugging Face token not found in environment variables")
@@ -81,7 +85,7 @@ def summarize_code(app_content: str):
81
  ]
82
 
83
  try:
84
- response = hf_client.chat_completion(messages, max_tokens=200, temperature=0.7)
85
  return response.choices[0].message.content
86
  except Exception as e:
87
  return f"์š”์•ฝ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
@@ -102,7 +106,7 @@ def analyze_code(app_content: str):
102
  ]
103
 
104
  try:
105
- response = hf_client.chat_completion(messages, max_tokens=1000, temperature=0.7)
106
  return response.choices[0].message.content
107
  except Exception as e:
108
  return f"๋ถ„์„ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
@@ -117,7 +121,7 @@ def explain_usage(app_content: str):
117
  ]
118
 
119
  try:
120
- response = hf_client.chat_completion(messages, max_tokens=800, temperature=0.7)
121
  return response.choices[0].message.content
122
  except Exception as e:
123
  return f"์‚ฌ์šฉ๋ฒ• ์„ค๋ช… ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
@@ -195,7 +199,7 @@ def respond(
195
  messages.append({"role": "user", "content": message})
196
 
197
  response = ""
198
- for message in hf_client.chat_completion(
199
  messages,
200
  max_tokens=max_tokens,
201
  stream=True,
@@ -288,7 +292,7 @@ def create_ui():
288
  """
289
 
290
  with gr.Blocks(theme="default", css=css) as demo:
291
- gr.Markdown("# MOUSE Space Analysis", elem_classes="header-markdown")
292
 
293
  with gr.Tabs() as tabs:
294
  with gr.TabItem("๋ถ„์„"):
 
13
  import json
14
  import re
15
 
16
+ # HuggingFace ๊ด€๋ จ API ํ‚ค (์ŠคํŽ˜์ด์Šค ๋ถ„์„ ์šฉ)
17
  HF_TOKEN = os.getenv("HF_TOKEN")
 
18
  hf_api = HfApi(token=HF_TOKEN)
19
 
20
+ # Gemini 2.0 Thinking ๋ชจ๋ธ ๊ด€๋ จ API ํ‚ค ๋ฐ ํด๋ผ์ด์–ธํŠธ (LLM ์šฉ)
21
+ G_API_KEY = os.getenv("G_API_KEY")
22
+ gemini_client = InferenceClient("Gemini-2.0-thinking", token=G_API_KEY)
23
+
24
  def get_headers():
25
  if not HF_TOKEN:
26
  raise ValueError("Hugging Face token not found in environment variables")
 
85
  ]
86
 
87
  try:
88
+ response = gemini_client.chat_completion(messages, max_tokens=200, temperature=0.7)
89
  return response.choices[0].message.content
90
  except Exception as e:
91
  return f"์š”์•ฝ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
 
106
  ]
107
 
108
  try:
109
+ response = gemini_client.chat_completion(messages, max_tokens=1000, temperature=0.7)
110
  return response.choices[0].message.content
111
  except Exception as e:
112
  return f"๋ถ„์„ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
 
121
  ]
122
 
123
  try:
124
+ response = gemini_client.chat_completion(messages, max_tokens=800, temperature=0.7)
125
  return response.choices[0].message.content
126
  except Exception as e:
127
  return f"์‚ฌ์šฉ๋ฒ• ์„ค๋ช… ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
 
199
  messages.append({"role": "user", "content": message})
200
 
201
  response = ""
202
+ for message in gemini_client.chat_completion(
203
  messages,
204
  max_tokens=max_tokens,
205
  stream=True,
 
292
  """
293
 
294
  with gr.Blocks(theme="default", css=css) as demo:
295
+ gr.Markdown("# MOUSE: HF Space Deep-Research", elem_classes="header-markdown")
296
 
297
  with gr.Tabs() as tabs:
298
  with gr.TabItem("๋ถ„์„"):