Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import pandas as pd
|
|
| 6 |
import json
|
| 7 |
|
| 8 |
# Hugging Face 토큰 확인
|
| 9 |
-
hftoken = os.getenv("
|
| 10 |
|
| 11 |
if not hftoken:
|
| 12 |
raise ValueError("H 환경 변수가 설정되지 않았습니다.")
|
|
@@ -15,7 +15,7 @@ if not hftoken:
|
|
| 15 |
api = HfApi(token=hftoken)
|
| 16 |
|
| 17 |
try:
|
| 18 |
-
client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct", token="
|
| 19 |
except Exception as e:
|
| 20 |
print(f"rror initializing InferenceClient: {e}")
|
| 21 |
# 대체 모델을 사용하거나 오류 처리를 수행하세요.
|
|
@@ -24,7 +24,7 @@ except Exception as e:
|
|
| 24 |
# 현재 스크립트의 디렉토리를 기준으로 상대 경로 설정
|
| 25 |
currentdir = os.path.dirname(os.path.abspath(file))
|
| 26 |
csvpath = os.path.join(currentdir, 'prompts.csv')
|
| 27 |
-
datapath = os.path.join(currentdir, '
|
| 28 |
|
| 29 |
# CSV 파일 로드
|
| 30 |
promptsdf = pd.readcsv(csvpath)
|
|
@@ -48,9 +48,9 @@ def respond(
|
|
| 48 |
response = prompt # CSV에서 찾은 프롬프트를 직접 반환
|
| 49 |
else:
|
| 50 |
systemprefix = """
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
fullprompt = f"{systemprefix} {systemmessage}\n\n"
|
| 56 |
|
|
@@ -95,16 +95,15 @@ def respond(
|
|
| 95 |
|
| 96 |
demo = gr.ChatInterface(
|
| 97 |
respond,
|
| 98 |
-
title="
|
| 99 |
-
description= "
|
| 100 |
additionalinputs=[
|
| 101 |
gr.extbox(value="""
|
| 102 |
-
당신은
|
| 103 |
-
|
| 104 |
-
CSV 파일에 없는 내용에 대해서는 적절한 대답을 생성해 주세요.
|
| 105 |
""", label="시스템 프롬프트"),
|
| 106 |
-
gr.Slider(minimum=1, maximum=4000, value=
|
| 107 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0
|
| 108 |
gr.Slider(
|
| 109 |
minimum=0.1,
|
| 110 |
maximum=1.0,
|
|
|
|
| 6 |
import json
|
| 7 |
|
| 8 |
# Hugging Face 토큰 확인
|
| 9 |
+
hftoken = os.getenv("H")
|
| 10 |
|
| 11 |
if not hftoken:
|
| 12 |
raise ValueError("H 환경 변수가 설정되지 않았습니다.")
|
|
|
|
| 15 |
api = HfApi(token=hftoken)
|
| 16 |
|
| 17 |
try:
|
| 18 |
+
client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct", token="H")
|
| 19 |
except Exception as e:
|
| 20 |
print(f"rror initializing InferenceClient: {e}")
|
| 21 |
# 대체 모델을 사용하거나 오류 처리를 수행하세요.
|
|
|
|
| 24 |
# 현재 스크립트의 디렉토리를 기준으로 상대 경로 설정
|
| 25 |
currentdir = os.path.dirname(os.path.abspath(file))
|
| 26 |
csvpath = os.path.join(currentdir, 'prompts.csv')
|
| 27 |
+
datapath = os.path.join(currentdir, 'newdataset.parquet')
|
| 28 |
|
| 29 |
# CSV 파일 로드
|
| 30 |
promptsdf = pd.readcsv(csvpath)
|
|
|
|
| 48 |
response = prompt # CSV에서 찾은 프롬프트를 직접 반환
|
| 49 |
else:
|
| 50 |
systemprefix = """
|
| 51 |
+
당신은 챗봇입니다. 모든 질문에 대해 친절하고 정확한 답변을 제공하세요.
|
| 52 |
+
질문에 대한 답변을 찾을 수 없는 경우, 적절한 대안을 제공해 주세요.
|
| 53 |
+
"""
|
| 54 |
|
| 55 |
fullprompt = f"{systemprefix} {systemmessage}\n\n"
|
| 56 |
|
|
|
|
| 95 |
|
| 96 |
demo = gr.ChatInterface(
|
| 97 |
respond,
|
| 98 |
+
title="My Chatbot",
|
| 99 |
+
description= "his is my chatbot!",
|
| 100 |
additionalinputs=[
|
| 101 |
gr.extbox(value="""
|
| 102 |
+
당신은 챗봇입니다. 모든 질문에 대해 친절하고 정확한 답변을 제공하세요.
|
| 103 |
+
질문에 대한 답변을 찾을 수 없는 경우, 적절한 대안을 제공해 주세요.
|
|
|
|
| 104 |
""", label="시스템 프롬프트"),
|
| 105 |
+
gr.Slider(minimum=1, maximum=4000, value=2000, step=1, label="Max new tokens"),
|
| 106 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=1.0, step=0.1, label="temperature"),
|
| 107 |
gr.Slider(
|
| 108 |
minimum=0.1,
|
| 109 |
maximum=1.0,
|