Dorjzodovsuren commited on
Commit
e8674ce
·
verified ·
1 Parent(s): 46f10a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -35
app.py CHANGED
@@ -7,26 +7,13 @@ from huggingface_hub import InferenceClient
7
  """
8
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
9
  """
10
- #client = InferenceClient("google/gemma-3-27b-it", token=os.getenv("TOKEN"))
11
 
12
- client = InferenceClient(
13
- provider="fireworks-ai",
14
- api_key=os.getenv("TOKEN"),
15
- )
16
-
17
- # completion = client.chat.completions.create(
18
- # model="deepseek-ai/DeepSeek-V3-0324",
19
- # messages=[
20
- # {
21
- # "role": "user",
22
- # "content": "What is the capital of France?"
23
- # }
24
- # ],
25
- # max_tokens=500,
26
  # )
27
 
28
- # print(completion.choices[0].message)
29
-
30
  global history
31
  history = []
32
  async def respond(
@@ -47,26 +34,26 @@ async def respond(
47
 
48
  messages.append({"role": "user", "content": message})
49
 
50
- #response = ""
51
-
52
- #for message in client.chat_completion(
53
- # model="deepseek-ai/DeepSeek-V3-0324",
54
- # messages=messages,
55
- # max_tokens=max_tokens,
56
- # stream=True,
57
- # temperature=temperature,
58
- # top_p=top_p,
59
- # ):
60
- # token = message.choices[0].delta.content
61
- # response += token
62
 
63
- completion = client.chat.completions.create(
64
- model="deepseek-ai/DeepSeek-R1",
65
  messages=messages,
66
- max_tokens=500,
67
- )
68
- response = completion.choices[0].message.content
69
- print(response)
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  communicate = edge_tts.Communicate(response, voice="mn-MN-YesuiNeural")
72
  with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
 
7
  """
8
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
9
  """
10
+ client = InferenceClient("google/gemma-3-27b-it", token=os.getenv("TOKEN"))
11
 
12
+ # client = InferenceClient(
13
+ # provider="fireworks-ai",
14
+ # api_key=os.getenv("TOKEN"),
 
 
 
 
 
 
 
 
 
 
 
15
  # )
16
 
 
 
17
  global history
18
  history = []
19
  async def respond(
 
34
 
35
  messages.append({"role": "user", "content": message})
36
 
37
+ response = ""
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ for message in client.chat_completion(
40
+ model="google/gemma-3-27b-it",
41
  messages=messages,
42
+ max_tokens=max_tokens,
43
+ stream=True,
44
+ temperature=temperature,
45
+ top_p=top_p,
46
+ ):
47
+ token = message.choices[0].delta.content
48
+ response += token
49
+
50
+ # completion = client.chat.completions.create(
51
+ # model="deepseek-ai/DeepSeek-R1",
52
+ # messages=messages,
53
+ # max_tokens=500,
54
+ # )
55
+ # response = completion.choices[0].message.content
56
+ # print(response)
57
 
58
  communicate = edge_tts.Communicate(response, voice="mn-MN-YesuiNeural")
59
  with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file: