Update app.py
Browse files
app.py
CHANGED
|
@@ -8,19 +8,20 @@ from unstructured.chunking.title import chunk_by_title
|
|
| 8 |
import cohere
|
| 9 |
import requests
|
| 10 |
import json
|
|
|
|
| 11 |
|
| 12 |
co_embed = cohere.ClientV2(os.environ.get("COHERE_API_KEY"))
|
| 13 |
co_rerank = cohere.ClientV2(os.environ.get("COHERE_API_KEY"))
|
| 14 |
|
| 15 |
vectored = None
|
| 16 |
|
| 17 |
-
dataid = requests.get("https://www.ryhintl.com/dbjson/getjson?sqlcmd=select * from company_matters")
|
| 18 |
|
| 19 |
-
data_str = dataid.content.decode('utf-8')
|
| 20 |
-
data = json.loads(data_str)
|
| 21 |
|
| 22 |
# デコード関数
|
| 23 |
-
def decode_text(data):
|
| 24 |
for item in data:
|
| 25 |
try:
|
| 26 |
# latin1 でデコードし、utf-8に変換
|
|
@@ -28,7 +29,7 @@ def decode_text(data):
|
|
| 28 |
except UnicodeDecodeError as e:
|
| 29 |
print(f"エラー: {e}")
|
| 30 |
item['text'] = "[デコード失敗]"
|
| 31 |
-
return data
|
| 32 |
|
| 33 |
|
| 34 |
|
|
@@ -151,8 +152,8 @@ vectorstore = Vectorstore(raw_documents)
|
|
| 151 |
# Gradioの関数
|
| 152 |
def search(query):
|
| 153 |
results = vectorstore.retrieve(query)
|
| 154 |
-
decoded_data = decode_text(results)
|
| 155 |
-
print("decoded_data:",decoded_data)
|
| 156 |
return "\n\n".join([f"**Title**: {r['title']}\n**Text**: {r['text']}\n**URL**: {r['url']}" for r in decoded_data])
|
| 157 |
|
| 158 |
# Gradioインターフェース
|
|
|
|
| 8 |
import cohere
|
| 9 |
import requests
|
| 10 |
import json
|
| 11 |
+
import os
|
| 12 |
|
| 13 |
co_embed = cohere.ClientV2(os.environ.get("COHERE_API_KEY"))
|
| 14 |
co_rerank = cohere.ClientV2(os.environ.get("COHERE_API_KEY"))
|
| 15 |
|
| 16 |
vectored = None
|
| 17 |
|
| 18 |
+
#dataid = requests.get("https://www.ryhintl.com/dbjson/getjson?sqlcmd=select * from company_matters")
|
| 19 |
|
| 20 |
+
#data_str = dataid.content.decode('utf-8')
|
| 21 |
+
#data = json.loads(data_str)
|
| 22 |
|
| 23 |
# デコード関数
|
| 24 |
+
'''def decode_text(data):
|
| 25 |
for item in data:
|
| 26 |
try:
|
| 27 |
# latin1 でデコードし、utf-8に変換
|
|
|
|
| 29 |
except UnicodeDecodeError as e:
|
| 30 |
print(f"エラー: {e}")
|
| 31 |
item['text'] = "[デコード失敗]"
|
| 32 |
+
return data'''
|
| 33 |
|
| 34 |
|
| 35 |
|
|
|
|
| 152 |
# Gradioの関数
|
| 153 |
def search(query):
|
| 154 |
results = vectorstore.retrieve(query)
|
| 155 |
+
#decoded_data = decode_text(results)
|
| 156 |
+
#print("decoded_data:",decoded_data)
|
| 157 |
return "\n\n".join([f"**Title**: {r['title']}\n**Text**: {r['text']}\n**URL**: {r['url']}" for r in decoded_data])
|
| 158 |
|
| 159 |
# Gradioインターフェース
|