Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -49,15 +49,14 @@ async def generate_response(user_input, history, system_message, max_tokens, tem
|
|
49 |
messages.append({"role": "assistant", "content": val[1]})
|
50 |
messages.append({"role": "user", "content": user_input})
|
51 |
|
52 |
-
# 함수가 동기 방식이므로 await를 사용하지 않음
|
53 |
try:
|
54 |
-
response = hf_client.chat_completion(messages, max_tokens=max_tokens, stream=False, temperature=temperature, top_p=top_p)
|
55 |
-
|
|
|
56 |
except Exception as e:
|
57 |
logging.error(f"An error occurred: {e}")
|
58 |
return "오류가 발생했습니다. 다시 시도해 주세요."
|
59 |
|
60 |
-
|
61 |
# 디스코드 봇 인스턴스 생성 및 실행
|
62 |
discord_client = MyClient(intents=intents)
|
63 |
discord_client.run(os.getenv('DISCORD_TOKEN'))
|
|
|
49 |
messages.append({"role": "assistant", "content": val[1]})
|
50 |
messages.append({"role": "user", "content": user_input})
|
51 |
|
|
|
52 |
try:
|
53 |
+
response = await hf_client.chat_completion(messages, max_tokens=max_tokens, stream=False, temperature=temperature, top_p=top_p)
|
54 |
+
# 올바른 속성에 접근하여 응답 내용을 추출
|
55 |
+
return response.choices[0].text # 'delta' 대신 'text' 또는 API 문서에 따른 적절한 속성 사용
|
56 |
except Exception as e:
|
57 |
logging.error(f"An error occurred: {e}")
|
58 |
return "오류가 발생했습니다. 다시 시도해 주세요."
|
59 |
|
|
|
60 |
# 디스코드 봇 인스턴스 생성 및 실행
|
61 |
discord_client = MyClient(intents=intents)
|
62 |
discord_client.run(os.getenv('DISCORD_TOKEN'))
|