Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -95,8 +95,12 @@ def generate(
|
|
95 |
include_values=False,
|
96 |
include_metadata=True
|
97 |
)
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
100 |
|
101 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt", add_generation_prompt=True)
|
102 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
|
|
95 |
include_values=False,
|
96 |
include_metadata=True
|
97 |
)
|
98 |
+
|
99 |
+
results = [result for result in results["matches"] if result["score"] > 0.6]
|
100 |
+
if len(results) > 0:
|
101 |
+
message = results[0]["metadata"]["text"] + f"\n\n위 문맥을 참고하여 질문 '{message}'에 답하면?"
|
102 |
+
|
103 |
+
conversation.append({"role": "user", "content": message })
|
104 |
|
105 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt", add_generation_prompt=True)
|
106 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|