style: convert /home/gpu/ to /

This commit is contained in:
0Xiao0
2024-10-28 17:38:40 +08:00
parent f4b971d2fd
commit 8fe010bbbe
12 changed files with 49 additions and 49 deletions

View File

@ -70,7 +70,7 @@ def get_all_files(folder_path):
# 加载文档和拆分文档 # 加载文档和拆分文档
loader = TextLoader("/home/gpu/Workspace/jarvis-models/sample/RAG_zh.txt") loader = TextLoader("/Workspace/jarvis-models/sample/RAG_zh.txt")
documents = loader.load() documents = loader.load()
@ -84,8 +84,8 @@ ids = ["20240521_store"+str(i) for i in range(len(docs))]
# 加载embedding模型和chroma server # 加载embedding模型和chroma server
embedding_model = SentenceTransformerEmbeddings(model_name='/home/gpu/Workspace/Models/BAAI/bge-large-zh-v1.5', model_kwargs={"device": "cuda"}) embedding_model = SentenceTransformerEmbeddings(model_name='/Workspace/Models/BAAI/bge-large-zh-v1.5', model_kwargs={"device": "cuda"})
client = chromadb.HttpClient(host='10.6.81.119', port=7000) client = chromadb.HttpClient(host='192.168.0.200', port=7000)
id = "g2e" id = "g2e"
#client.delete_collection(id) #client.delete_collection(id)
@ -106,8 +106,8 @@ print("collection_number",collection_number)
# # chroma 召回 # # chroma 召回
# from chromadb.utils import embedding_functions # from chromadb.utils import embedding_functions
# embedding_model = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/home/gpu/Workspace/Models/BAAI/bge-large-zh-v1.5", device = "cuda") # embedding_model = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/Workspace/Models/BAAI/bge-large-zh-v1.5", device = "cuda")
# client = chromadb.HttpClient(host='10.6.81.119', port=7000) # client = chromadb.HttpClient(host='192.168.0.200', port=7000)
# collection = client.get_collection("g2e", embedding_function=embedding_model) # collection = client.get_collection("g2e", embedding_function=embedding_model)
# print(collection.count()) # print(collection.count())
@ -152,7 +152,7 @@ print("collection_number",collection_number)
# 'Content-Type': 'application/json', # 'Content-Type': 'application/json',
# 'Authorization': "Bearer " + key # 'Authorization': "Bearer " + key
# } # }
# url = "http://10.6.81.119:23333/v1/chat/completions" # url = "http://192.168.0.200:23333/v1/chat/completions"
# fastchat_response = requests.post(url, json=chat_inputs, headers=header) # fastchat_response = requests.post(url, json=chat_inputs, headers=header)
# # print(fastchat_response.json()) # # print(fastchat_response.json())

View File

@ -70,7 +70,7 @@ def get_all_files(folder_path):
# 加载文档和拆分文档 # 加载文档和拆分文档
loader = TextLoader("/home/gpu/Workspace/jarvis-models/sample/RAG_en.txt") loader = TextLoader("/Workspace/jarvis-models/sample/RAG_en.txt")
documents = loader.load() documents = loader.load()
@ -84,8 +84,8 @@ ids = ["20240521_store"+str(i) for i in range(len(docs))]
# 加载embedding模型和chroma server # 加载embedding模型和chroma server
embedding_model = SentenceTransformerEmbeddings(model_name='/home/gpu/Workspace/Models/BAAI/bge-small-en-v1.5', model_kwargs={"device": "cuda"}) embedding_model = SentenceTransformerEmbeddings(model_name='/Workspace/Models/BAAI/bge-small-en-v1.5', model_kwargs={"device": "cuda"})
client = chromadb.HttpClient(host='10.6.81.119', port=7000) client = chromadb.HttpClient(host='192.168.0.200', port=7000)
id = "g2e_english" id = "g2e_english"
client.delete_collection(id) client.delete_collection(id)
@ -106,8 +106,8 @@ print("collection_number",collection_number)
# # chroma 召回 # # chroma 召回
# from chromadb.utils import embedding_functions # from chromadb.utils import embedding_functions
# embedding_model = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/home/gpu/Workspace/Models/BAAI/bge-large-zh-v1.5", device = "cuda") # embedding_model = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/Workspace/Models/BAAI/bge-large-zh-v1.5", device = "cuda")
# client = chromadb.HttpClient(host='10.6.81.119', port=7000) # client = chromadb.HttpClient(host='192.168.0.200', port=7000)
# collection = client.get_collection("g2e", embedding_function=embedding_model) # collection = client.get_collection("g2e", embedding_function=embedding_model)
# print(collection.count()) # print(collection.count())
@ -152,7 +152,7 @@ print("collection_number",collection_number)
# 'Content-Type': 'application/json', # 'Content-Type': 'application/json',
# 'Authorization': "Bearer " + key # 'Authorization': "Bearer " + key
# } # }
# url = "http://10.6.81.119:23333/v1/chat/completions" # url = "http://192.168.0.200:23333/v1/chat/completions"
# fastchat_response = requests.post(url, json=chat_inputs, headers=header) # fastchat_response = requests.post(url, json=chat_inputs, headers=header)
# # print(fastchat_response.json()) # # print(fastchat_response.json())

View File

@ -66,7 +66,7 @@ def get_all_files(folder_path):
# 加载文档和拆分文档 # 加载文档和拆分文档
# loader = TextLoader("/home/gpu/Workspace/jarvis-models/sample/RAG_zh.txt") # loader = TextLoader("/Workspace/jarvis-models/sample/RAG_zh.txt")
# documents = loader.load() # documents = loader.load()
@ -80,8 +80,8 @@ def get_all_files(folder_path):
# # 加载embedding模型和chroma server # # 加载embedding模型和chroma server
# embedding_model = SentenceTransformerEmbeddings(model_name='/home/gpu/Workspace/Models/BAAI/bge-large-zh-v1.5', model_kwargs={"device": "cuda"}) # embedding_model = SentenceTransformerEmbeddings(model_name='/Workspace/Models/BAAI/bge-large-zh-v1.5', model_kwargs={"device": "cuda"})
# client = chromadb.HttpClient(host='10.6.81.119', port=7000) # client = chromadb.HttpClient(host='192.168.0.200', port=7000)
# id = "g2e" # id = "g2e"
# client.delete_collection(id) # client.delete_collection(id)
@ -102,8 +102,8 @@ def get_all_files(folder_path):
# chroma 召回 # chroma 召回
from chromadb.utils import embedding_functions from chromadb.utils import embedding_functions
embedding_model = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/home/gpu/Workspace/Models/BAAI/bge-large-zh-v1.5", device = "cuda") embedding_model = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/Workspace/Models/BAAI/bge-large-zh-v1.5", device = "cuda")
client = chromadb.HttpClient(host='10.6.81.119', port=7000) client = chromadb.HttpClient(host='192.168.0.200', port=7000)
collection = client.get_collection("g2e", embedding_function=embedding_model) collection = client.get_collection("g2e", embedding_function=embedding_model)
print(collection.count()) print(collection.count())
@ -148,7 +148,7 @@ print("time: ", time.time() - start_time)
# 'Content-Type': 'application/json', # 'Content-Type': 'application/json',
# 'Authorization': "Bearer " + key # 'Authorization': "Bearer " + key
# } # }
# url = "http://10.6.81.119:23333/v1/chat/completions" # url = "http://192.168.0.200:23333/v1/chat/completions"
# fastchat_response = requests.post(url, json=chat_inputs, headers=header) # fastchat_response = requests.post(url, json=chat_inputs, headers=header)
# # print(fastchat_response.json()) # # print(fastchat_response.json())

View File

@ -9,16 +9,16 @@ from langchain_community.embeddings.sentence_transformer import SentenceTransfor
import time import time
# chroma run --path chroma_db/ --port 8000 --host 0.0.0.0 # chroma run --path chroma_db/ --port 8000 --host 0.0.0.0
# loader = TextLoader("/home/administrator/Workspace/chroma_data/粤语语料.txt",encoding="utf-8") # loader = TextLoader("/Workspace/chroma_data/粤语语料.txt",encoding="utf-8")
loader = TextLoader("/home/administrator/Workspace/jarvis-models/sample/RAG_boss.txt") loader = TextLoader("/Workspace/jarvis-models/sample/RAG_boss.txt")
documents = loader.load() documents = loader.load()
text_splitter = RecursiveCharacterTextSplitter(chunk_size=10, chunk_overlap=0, length_function=len, is_separator_regex=True,separators=['\n', '\n\n']) text_splitter = RecursiveCharacterTextSplitter(chunk_size=10, chunk_overlap=0, length_function=len, is_separator_regex=True,separators=['\n', '\n\n'])
docs = text_splitter.split_documents(documents) docs = text_splitter.split_documents(documents)
print("len(docs)", len(docs)) print("len(docs)", len(docs))
ids = ["粤语语料"+str(i) for i in range(len(docs))] ids = ["粤语语料"+str(i) for i in range(len(docs))]
embedding_model = SentenceTransformerEmbeddings(model_name='/home/administrator/Workspace/Models/BAAI/bge-m3', model_kwargs={"device": "cuda:1"}) embedding_model = SentenceTransformerEmbeddings(model_name='/Workspace/Models/BAAI/bge-m3', model_kwargs={"device": "cuda:1"})
client = chromadb.HttpClient(host='172.16.4.7', port=7000) client = chromadb.HttpClient(host='192.168.0.200', port=7000)
id = "boss" id = "boss"
client.delete_collection(id) client.delete_collection(id)
@ -28,13 +28,13 @@ db = Chroma.from_documents(documents=docs, embedding=embedding_model, ids=ids, c
embedding_model = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/home/administrator/Workspace/Models/BAAI/bge-m3", device = "cuda:1") embedding_model = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/Workspace/Models/BAAI/bge-m3", device = "cuda:1")
client = chromadb.HttpClient(host='172.16.4.7', port=7000) client = chromadb.HttpClient(host='192.168.0.200', port=7000)
collection = client.get_collection(id, embedding_function=embedding_model) collection = client.get_collection(id, embedding_function=embedding_model)
reranker_model = CrossEncoder("/home/administrator/Workspace/Models/BAAI/bge-reranker-v2-m3", max_length=512, device = "cuda:1") reranker_model = CrossEncoder("/Workspace/Models/BAAI/bge-reranker-v2-m3", max_length=512, device = "cuda:1")
while True: while True:
usr_question = input("\n 请输入问题: ") usr_question = input("\n 请输入问题: ")

View File

@ -43,7 +43,7 @@ class ASR(Blackbox):
config = read_yaml(".env.yaml") config = read_yaml(".env.yaml")
self.paraformer = RapidParaformer(config) self.paraformer = RapidParaformer(config)
model_dir = "/home/gpu/Workspace/Models/SenseVoice/SenseVoiceSmall" model_dir = "/Workspace/Models/SenseVoice/SenseVoiceSmall"
self.speed = sensevoice_config.speed self.speed = sensevoice_config.speed
self.device = sensevoice_config.device self.device = sensevoice_config.device
@ -59,7 +59,7 @@ class ASR(Blackbox):
self.asr = AutoModel( self.asr = AutoModel(
model=model_dir, model=model_dir,
trust_remote_code=True, trust_remote_code=True,
remote_code= "/home/gpu/Workspace/SenseVoice/model.py", remote_code= "/Workspace/SenseVoice/model.py",
vad_model="fsmn-vad", vad_model="fsmn-vad",
vad_kwargs={"max_single_segment_time": 30000}, vad_kwargs={"max_single_segment_time": 30000},
device=self.device, device=self.device,

View File

@ -98,7 +98,7 @@ class Chat(Blackbox):
#user_presence_penalty = 0.8 #user_presence_penalty = 0.8
if user_model_url is None or user_model_url.isspace() or user_model_url == "": if user_model_url is None or user_model_url.isspace() or user_model_url == "":
user_model_url = "http://10.6.81.119:23333/v1/chat/completions" user_model_url = "http://192.168.0.200:23333/v1/chat/completions"
if user_model_key is None or user_model_key.isspace() or user_model_key == "": if user_model_key is None or user_model_key.isspace() or user_model_key == "":
user_model_key = "YOUR_API_KEY" user_model_key = "YOUR_API_KEY"

View File

@ -22,12 +22,12 @@ class ChromaQuery(Blackbox):
def __init__(self, *args, **kwargs) -> None: def __init__(self, *args, **kwargs) -> None:
# config = read_yaml(args[0]) # config = read_yaml(args[0])
# load chromadb and embedding model # load chromadb and embedding model
self.embedding_model_1 = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/home/administrator/Workspace/Models/BAAI/bge-large-zh-v1.5", device = "cuda:0") self.embedding_model_1 = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/Workspace/Models/BAAI/bge-large-zh-v1.5", device = "cuda:0")
self.embedding_model_2 = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/home/administrator/Workspace/Models/BAAI/bge-small-en-v1.5", device = "cuda:0") self.embedding_model_2 = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/Workspace/Models/BAAI/bge-small-en-v1.5", device = "cuda:0")
self.embedding_model_3 = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/home/administrator/Workspace/Models/BAAI/bge-m3", device = "cuda:0") self.embedding_model_3 = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="/Workspace/Models/BAAI/bge-m3", device = "cuda:0")
self.client_1 = chromadb.HttpClient(host='172.16.4.7', port=7000) self.client_1 = chromadb.HttpClient(host='192.168.0.200', port=7000)
# self.client_2 = chromadb.HttpClient(host='10.6.82.192', port=8000) # self.client_2 = chromadb.HttpClient(host='10.6.82.192', port=8000)
self.reranker_model_1 = CrossEncoder("/home/administrator/Workspace/Models/BAAI/bge-reranker-v2-m3", max_length=512, device = "cuda") self.reranker_model_1 = CrossEncoder("/Workspace/Models/BAAI/bge-reranker-v2-m3", max_length=512, device = "cuda")
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
return self.processing(*args, **kwargs) return self.processing(*args, **kwargs)
@ -57,10 +57,10 @@ class ChromaQuery(Blackbox):
return JSONResponse(content={"error": "question is required"}, status_code=status.HTTP_400_BAD_REQUEST) return JSONResponse(content={"error": "question is required"}, status_code=status.HTTP_400_BAD_REQUEST)
if chroma_embedding_model is None or chroma_embedding_model.isspace() or chroma_embedding_model == "": if chroma_embedding_model is None or chroma_embedding_model.isspace() or chroma_embedding_model == "":
chroma_embedding_model = "/home/administrator/Workspace/Models/BAAI/bge-large-zh-v1.5" chroma_embedding_model = "/Workspace/Models/BAAI/bge-large-zh-v1.5"
if chroma_host is None or chroma_host.isspace() or chroma_host == "": if chroma_host is None or chroma_host.isspace() or chroma_host == "":
chroma_host = "172.16.4.7" chroma_host = "192.168.0.200"
if chroma_port is None or chroma_port.isspace() or chroma_port == "": if chroma_port is None or chroma_port.isspace() or chroma_port == "":
chroma_port = "7000" chroma_port = "7000"
@ -72,7 +72,7 @@ class ChromaQuery(Blackbox):
chroma_n_results = 10 chroma_n_results = 10
# load client and embedding model from init # load client and embedding model from init
if re.search(r"172.16.4.7", chroma_host) and re.search(r"7000", chroma_port): if re.search(r"192.168.0.200", chroma_host) and re.search(r"7000", chroma_port):
client = self.client_1 client = self.client_1
else: else:
try: try:
@ -80,11 +80,11 @@ class ChromaQuery(Blackbox):
except: except:
return JSONResponse(content={"error": "chroma client not found"}, status_code=status.HTTP_400_BAD_REQUEST) return JSONResponse(content={"error": "chroma client not found"}, status_code=status.HTTP_400_BAD_REQUEST)
if re.search(r"/home/administrator/Workspace/Models/BAAI/bge-large-zh-v1.5", chroma_embedding_model): if re.search(r"/Workspace/Models/BAAI/bge-large-zh-v1.5", chroma_embedding_model):
embedding_model = self.embedding_model_1 embedding_model = self.embedding_model_1
elif re.search(r"/home/administrator/Workspace/Models/BAAI/bge-small-en-v1.5", chroma_embedding_model): elif re.search(r"/Workspace/Models/BAAI/bge-small-en-v1.5", chroma_embedding_model):
embedding_model = self.embedding_model_2 embedding_model = self.embedding_model_2
elif re.search(r"/home/administrator/Workspace/Models/BAAI/bge-m3", chroma_embedding_model): elif re.search(r"/Workspace/Models/BAAI/bge-m3", chroma_embedding_model):
embedding_model = self.embedding_model_3 embedding_model = self.embedding_model_3
else: else:
try: try:
@ -123,7 +123,7 @@ class ChromaQuery(Blackbox):
final_result = str(results["documents"]) final_result = str(results["documents"])
if chroma_reranker_model: if chroma_reranker_model:
if re.search(r"/home/administrator/Workspace/Models/BAAI/bge-reranker-v2-m3", chroma_reranker_model): if re.search(r"/Workspace/Models/BAAI/bge-reranker-v2-m3", chroma_reranker_model):
reranker_model = self.reranker_model_1 reranker_model = self.reranker_model_1
else: else:
try: try:

View File

@ -31,9 +31,9 @@ class ChromaUpsert(Blackbox):
def __init__(self, *args, **kwargs) -> None: def __init__(self, *args, **kwargs) -> None:
# config = read_yaml(args[0]) # config = read_yaml(args[0])
# load embedding model # load embedding model
self.embedding_model_1 = SentenceTransformerEmbeddings(model_name="/home/gpu/Workspace/Models/BAAI/bge-large-zh-v1.5", model_kwargs={"device": "cuda"}) self.embedding_model_1 = SentenceTransformerEmbeddings(model_name="/Workspace/Models/BAAI/bge-large-zh-v1.5", model_kwargs={"device": "cuda"})
# load chroma db # load chroma db
self.client_1 = chromadb.HttpClient(host='10.6.81.119', port=7000) self.client_1 = chromadb.HttpClient(host='192.168.0.200', port=7000)
def __call__(self, *args, **kwargs): def __call__(self, *args, **kwargs):
return self.processing(*args, **kwargs) return self.processing(*args, **kwargs)
@ -79,7 +79,7 @@ class ChromaUpsert(Blackbox):
chroma_collection_id = settings.get("chroma_collection_id") chroma_collection_id = settings.get("chroma_collection_id")
if chroma_embedding_model is None or chroma_embedding_model.isspace() or chroma_embedding_model == "": if chroma_embedding_model is None or chroma_embedding_model.isspace() or chroma_embedding_model == "":
chroma_embedding_model = "/home/gpu/Workspace/Models/BAAI/bge-large-zh-v1.5" chroma_embedding_model = "/Workspace/Models/BAAI/bge-large-zh-v1.5"
if chroma_host is None or chroma_host.isspace() or chroma_host == "": if chroma_host is None or chroma_host.isspace() or chroma_host == "":
chroma_host = "10.6.82.192" chroma_host = "10.6.82.192"
@ -96,7 +96,7 @@ class ChromaUpsert(Blackbox):
else: else:
client = chromadb.HttpClient(host=chroma_host, port=chroma_port) client = chromadb.HttpClient(host=chroma_host, port=chroma_port)
print(f"chroma_embedding_model: {chroma_embedding_model}") print(f"chroma_embedding_model: {chroma_embedding_model}")
if re.search(r"/home/gpu/Workspace/Models/BAAI/bge-large-zh-v1.5", chroma_embedding_model): if re.search(r"/Workspace/Models/BAAI/bge-large-zh-v1.5", chroma_embedding_model):
embedding_model = self.embedding_model_1 embedding_model = self.embedding_model_1
else: else:
embedding_model = SentenceTransformerEmbeddings(model_name=chroma_embedding_model, device = "cuda:0") embedding_model = SentenceTransformerEmbeddings(model_name=chroma_embedding_model, device = "cuda:0")

View File

@ -23,7 +23,7 @@ class G2E(Blackbox):
if context == None: if context == None:
context = [] context = []
#url = 'http://120.196.116.194:48890/v1' #url = 'http://120.196.116.194:48890/v1'
url = 'http://10.6.81.119:23333/v1' url = 'http://192.168.0.200:23333/v1'
background_prompt = '''KOMBUKIKI是一款茶饮料目标受众 年龄20-35岁 性别:女性 地点:一线城市、二线城市 职业:精英中产、都市白领 收入水平:中高收入,有一定消费能力 兴趣和爱好:注重健康,有运动习惯 background_prompt = '''KOMBUKIKI是一款茶饮料目标受众 年龄20-35岁 性别:女性 地点:一线城市、二线城市 职业:精英中产、都市白领 收入水平:中高收入,有一定消费能力 兴趣和爱好:注重健康,有运动习惯

View File

@ -13,7 +13,7 @@ from injector import inject
from injector import singleton from injector import singleton
import sys,os import sys,os
sys.path.append('/home/gpu/Workspace/CosyVoice') sys.path.append('/Workspace/CosyVoice')
from cosyvoice.cli.cosyvoice import CosyVoice from cosyvoice.cli.cosyvoice import CosyVoice
# from cosyvoice.utils.file_utils import load_wav, speed_change # from cosyvoice.utils.file_utils import load_wav, speed_change
@ -81,7 +81,7 @@ class TTS(Blackbox):
self.cosyvoicetts = None self.cosyvoicetts = None
# os.environ['CUDA_VISIBLE_DEVICES'] = str(cosyvoice_config.device) # os.environ['CUDA_VISIBLE_DEVICES'] = str(cosyvoice_config.device)
if self.cosyvoice_mode == 'local': if self.cosyvoice_mode == 'local':
self.cosyvoicetts = CosyVoice('/home/gpu/Workspace/Models/CosyVoice/pretrained_models/CosyVoice-300M') self.cosyvoicetts = CosyVoice('/Workspace/Models/CosyVoice/pretrained_models/CosyVoice-300M')
else: else:
self.cosyvoice_url = cosyvoice_config.url self.cosyvoice_url = cosyvoice_config.url

View File

@ -5,7 +5,7 @@ from transformers import BertTokenizer
import numpy as np import numpy as np
dirabspath = __file__.split("\\")[1:-1] dirabspath = __file__.split("\\")[1:-1]
dirabspath= "/home/gpu/Workspace/jarvis-models/src/sentiment_engine" + "/".join(dirabspath) dirabspath= "/Workspace/jarvis-models/src/sentiment_engine" + "/".join(dirabspath)
default_path = dirabspath + "/models/paimon_sentiment.onnx" default_path = dirabspath + "/models/paimon_sentiment.onnx"

View File

@ -19,7 +19,7 @@ import logging
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
dirbaspath = __file__.split("\\")[1:-1] dirbaspath = __file__.split("\\")[1:-1]
dirbaspath= "/home/gpu/Workspace/jarvis-models/src/tts" + "/".join(dirbaspath) dirbaspath= "/Workspace/jarvis-models/src/tts" + "/".join(dirbaspath)
config = { config = {
'ayaka': { 'ayaka': {
'cfg': dirbaspath + '/models/ayaka.json', 'cfg': dirbaspath + '/models/ayaka.json',