seawolf2357 commited on
Commit
8270ab4
โ€ข
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'))