solve env conflict
Browse files- agent/wulewule_agent.py +0 -2
- app.py +45 -0
- requirements.txt +30 -22
agent/wulewule_agent.py
CHANGED
@@ -4,7 +4,6 @@ import requests
|
|
4 |
from typing import List, Dict, Any, Optional, Iterator
|
5 |
from PIL import Image
|
6 |
import re
|
7 |
-
import torch
|
8 |
|
9 |
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
|
10 |
# from llama_index.core.postprocessor import LLMRerank
|
@@ -300,4 +299,3 @@ if __name__ == "__main__":
|
|
300 |
# 使用st.audio函数播放音频
|
301 |
st.audio("audio.mp3")
|
302 |
st.write(f"语音内容为: {audio_text}")
|
303 |
-
torch.cuda.empty_cache()
|
|
|
4 |
from typing import List, Dict, Any, Optional, Iterator
|
5 |
from PIL import Image
|
6 |
import re
|
|
|
7 |
|
8 |
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
|
9 |
# from llama_index.core.postprocessor import LLMRerank
|
|
|
299 |
# 使用st.audio函数播放音频
|
300 |
st.audio("audio.mp3")
|
301 |
st.write(f"语音内容为: {audio_text}")
|
|
app.py
CHANGED
@@ -33,6 +33,51 @@ def load_simple_rag(config, used_lmdeploy=False):
|
|
33 |
wulewule_rag = WuleRAG(data_source_dir, db_persist_directory, base_mode, embeddings_model, reranker_model, rag_prompt_template)
|
34 |
return wulewule_rag
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
GlobalHydra.instance().clear()
|
37 |
@hydra.main(version_base=None, config_path="./configs", config_name="model_cfg")
|
38 |
def main(cfg):
|
|
|
33 |
wulewule_rag = WuleRAG(data_source_dir, db_persist_directory, base_mode, embeddings_model, reranker_model, rag_prompt_template)
|
34 |
return wulewule_rag
|
35 |
|
36 |
+
|
37 |
+
@st.cache_resource
|
38 |
+
def load_wulewule_agent(config):
|
39 |
+
from agent.wulewule_agent import MultiModalAssistant, Settings
|
40 |
+
use_remote = config["use_remote"]
|
41 |
+
SiliconFlow_api = config["SiliconFlow_api"]
|
42 |
+
data_source_dir = config["data_source_dir"]
|
43 |
+
if len(SiliconFlow_api)<51 and os.environ.get('SiliconFlow_api', ""):
|
44 |
+
SiliconFlow_api = os.environ.get('SiliconFlow_api')
|
45 |
+
|
46 |
+
print(f"======= loading llm =======")
|
47 |
+
if use_remote:
|
48 |
+
from llama_index.llms.siliconflow import SiliconFlow
|
49 |
+
from llama_index.embeddings.siliconflow import SiliconFlowEmbedding
|
50 |
+
api_base_url = "https://api.siliconflow.cn/v1/chat/completions"
|
51 |
+
# model = "Qwen/Qwen2.5-72B-Instruct"
|
52 |
+
# model = "deepseek-ai/DeepSeek-V2.5"
|
53 |
+
remote_llm = config["remote_llm"]
|
54 |
+
remote_embeddings_model = config["remote_embeddings_model"]
|
55 |
+
llm = SiliconFlow( model=remote_llm, base_url=api_base_url, api_key=SiliconFlow_api, max_tokens=4096)
|
56 |
+
embed_model = SiliconFlowEmbedding( model=remote_embeddings_model, api_key=SiliconFlow_api)
|
57 |
+
else:
|
58 |
+
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
|
59 |
+
from llama_index.llms.huggingface import HuggingFaceLLM
|
60 |
+
local_llm = config["llm_model"]
|
61 |
+
local_embeddings_model = config["agent_embeddings_model"]
|
62 |
+
llm = HuggingFaceLLM(
|
63 |
+
model_name=local_llm,
|
64 |
+
tokenizer_name=local_llm,
|
65 |
+
model_kwargs={"trust_remote_code":True},
|
66 |
+
tokenizer_kwargs={"trust_remote_code":True},
|
67 |
+
# context_window=4096,
|
68 |
+
# max_new_tokens=4096,
|
69 |
+
)
|
70 |
+
embed_model = HuggingFaceEmbedding(
|
71 |
+
model_name=local_embeddings_model
|
72 |
+
)
|
73 |
+
# settings
|
74 |
+
Settings.llm = llm
|
75 |
+
Settings.embed_model = embed_model
|
76 |
+
wulewule_assistant = MultiModalAssistant(data_source_dir, llm, SiliconFlow_api)
|
77 |
+
print(f"======= finished loading ! =======")
|
78 |
+
return wulewule_assistant
|
79 |
+
|
80 |
+
|
81 |
GlobalHydra.instance().clear()
|
82 |
@hydra.main(version_base=None, config_path="./configs", config_name="model_cfg")
|
83 |
def main(cfg):
|
requirements.txt
CHANGED
@@ -1,29 +1,37 @@
|
|
1 |
-
BCEmbedding
|
2 |
transformers==4.45.0
|
3 |
streamlit==1.36.0
|
4 |
-
gradio==5.0.2
|
5 |
-
sentencepiece==0.2.0
|
6 |
-
accelerate==0.30.1
|
7 |
transformers_stream_generator==0.0.5
|
8 |
-
sentence-transformers==3.0.1
|
9 |
-
peft==0.11.1
|
10 |
-
xtuner==0.1.23
|
11 |
openxlab
|
12 |
-
tiktoken
|
13 |
-
einops
|
14 |
-
oss2
|
15 |
requests
|
16 |
-
langchain==0.2.10
|
17 |
-
langchain_community==0.2.9
|
18 |
-
langchain_core
|
19 |
-
langchain-huggingface==0.0.3
|
20 |
-
langchain_text_splitters==0.2.2
|
21 |
-
chromadb==0.5.0
|
22 |
-
loguru==0.7.2
|
23 |
modelscope==1.18.0
|
24 |
-
numpy==1.26.4
|
25 |
-
pandas==2.2.2
|
26 |
-
timm==1.0.8
|
27 |
openai==1.40.3
|
28 |
-
lmdeploy[all]==0.5.3
|
29 |
-
hydra-core==1.3.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# BCEmbedding
|
2 |
transformers==4.45.0
|
3 |
streamlit==1.36.0
|
4 |
+
# gradio==5.0.2
|
5 |
+
# sentencepiece==0.2.0
|
6 |
+
# accelerate==0.30.1
|
7 |
transformers_stream_generator==0.0.5
|
8 |
+
# sentence-transformers==3.0.1
|
9 |
+
# peft==0.11.1
|
10 |
+
# xtuner==0.1.23
|
11 |
openxlab
|
12 |
+
# tiktoken
|
13 |
+
# einops
|
14 |
+
# oss2
|
15 |
requests
|
16 |
+
# langchain==0.2.10
|
17 |
+
# langchain_community==0.2.9
|
18 |
+
# langchain_core
|
19 |
+
# langchain-huggingface==0.0.3
|
20 |
+
# langchain_text_splitters==0.2.2
|
21 |
+
# chromadb==0.5.0
|
22 |
+
# loguru==0.7.2
|
23 |
modelscope==1.18.0
|
24 |
+
# numpy==1.26.4
|
25 |
+
# pandas==2.2.2
|
26 |
+
# timm==1.0.8
|
27 |
openai==1.40.3
|
28 |
+
# lmdeploy[all]==0.5.3
|
29 |
+
hydra-core==1.3.2
|
30 |
+
## agent used
|
31 |
+
llama-index
|
32 |
+
llama-index-core
|
33 |
+
llama-index-llms-huggingface
|
34 |
+
llama-index-embeddings-huggingface
|
35 |
+
llama-index-llms-siliconflow
|
36 |
+
llama-index-embeddings-siliconflow
|
37 |
+
# huggingface-hub==0.27.0
|