seawolf2357 commited on
Commit
8270ab4
Β·
verified Β·
1 Parent(s): 1a4d898

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import discord
3
  import logging
4
  import os
@@ -13,7 +12,6 @@ intents = discord.Intents.default()
13
  intents.messages = True
14
 
15
  # μΆ”λ‘  API ν΄λΌμ΄μ–ΈνŠΈ μ„€μ •
16
- #hf_client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct", token=os.getenv("HF_TOKEN"))
17
  hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus", token=os.getenv("HF_TOKEN"))
18
 
19
  # λŒ€ν™” νžˆμŠ€ν† λ¦¬λ₯Ό μ €μž₯ν•  λ³€μˆ˜
@@ -68,7 +66,8 @@ async def generate_response(user_input):
68
  # 슀트리밍 응닡을 μ²˜λ¦¬ν•˜λŠ” 둜직 μΆ”κ°€
69
  full_response = ""
70
  for part in response:
71
- if part.choices and part.choices[0].delta and part.choices[0].delta.content: # 델타가 μžˆλŠ”μ§€ 확인
 
72
  full_response += part.choices[0].delta.content.strip()
73
 
74
  conversation_history.append({"role": "assistant", "content": full_response})
@@ -79,4 +78,3 @@ async def generate_response(user_input):
79
  # λ””μŠ€μ½”λ“œ 봇 μΈμŠ€ν„΄μŠ€ 생성 및 μ‹€ν–‰
80
  discord_client = MyClient(intents=intents)
81
  discord_client.run(os.getenv('DISCORD_TOKEN'))
82
-
 
 
1
  import discord
2
  import logging
3
  import os
 
12
  intents.messages = True
13
 
14
  # μΆ”λ‘  API ν΄λΌμ΄μ–ΈνŠΈ μ„€μ •
 
15
  hf_client = InferenceClient("CohereForAI/c4ai-command-r-plus", token=os.getenv("HF_TOKEN"))
16
 
17
  # λŒ€ν™” νžˆμŠ€ν† λ¦¬λ₯Ό μ €μž₯ν•  λ³€μˆ˜
 
66
  # 슀트리밍 응닡을 μ²˜λ¦¬ν•˜λŠ” 둜직 μΆ”κ°€
67
  full_response = ""
68
  for part in response:
69
+ logging.debug(f'Part received from stream: {part}') # 슀트리밍 μ‘λ‹΅μ˜ 각 파트 λ‘œκΉ…
70
+ if part.choices and part.choices[0].delta and part.choices[0].delta.content:
71
  full_response += part.choices[0].delta.content.strip()
72
 
73
  conversation_history.append({"role": "assistant", "content": full_response})
 
78
  # λ””μŠ€μ½”λ“œ 봇 μΈμŠ€ν„΄μŠ€ 생성 및 μ‹€ν–‰
79
  discord_client = MyClient(intents=intents)
80
  discord_client.run(os.getenv('DISCORD_TOKEN'))