ai-vtuber 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2025 小ber <a0968066786b@gmail.com>
2
+
3
+ 此軟體為專有軟體,未經授權不得使用、修改、分發或商業化。
4
+
5
+ 由於此軟體是我們小組的畢業專題,
6
+ 我們希望能夠保護我們的智慧財產權,
7
+ 因此我們暫先選擇使用專有軟體授權。
8
+
9
+ 您可以:
10
+ - 僅在獲得授權的情況下使用此軟體。
11
+
12
+ 您不得:
13
+ - 未經授權修改、分發或商業化此軟體。
14
+ - 將此軟體用於任何非法用途。
15
+
16
+ 如需授權或其他問題,請聯絡作者:a0968066786b@gmail.com
17
+
18
+ 未來可能方向:
19
+ - 考慮在未來釋出開源版本,屆時若開源將會更新授權條款。
20
+ - 歡迎聯絡我們討論合作或授權事宜。
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai_vtuber
3
+ Version: 0.1.0
4
+ Summary: 整個套件為包含一整個可用的ai vtuber,會包括思考、說話及接收我們對話內容手段等工具
5
+ Author-email: 小ber <a0968066786b@gmail.com>
6
+ License: Copyright (c) 2025 小ber <a0968066786b@gmail.com>
7
+
8
+ 此軟體為專有軟體,未經授權不得使用、修改、分發或商業化。
9
+
10
+ 由於此軟體是我們小組的畢業專題,
11
+ 我們希望能夠保護我們的智慧財產權,
12
+ 因此我們暫先選擇使用專有軟體授權。
13
+
14
+ 您可以:
15
+ - 僅在獲得授權的情況下使用此軟體。
16
+
17
+ 您不得:
18
+ - 未經授權修改、分發或商業化此軟體。
19
+ - 將此軟體用於任何非法用途。
20
+
21
+ 如需授權或其他問題,請聯絡作者:a0968066786b@gmail.com
22
+
23
+ 未來可能方向:
24
+ - 考慮在未來釋出開源版本,屆時若開源將會更新授權條款。
25
+ - 歡迎聯絡我們討論合作或授權事宜。
26
+
27
+ Project-URL: Homepage, https://github.com/Super-Boy-1/ai_vtuber.git
28
+ Project-URL: Source, https://github.com/Super-Boy-1/ai_vtuber.git
29
+ Keywords: ai,vtuber,ai vtuber,python
30
+ Classifier: Development Status :: 2 - Pre-Alpha
31
+ Classifier: Intended Audience :: End Users/Desktop
32
+ Classifier: Intended Audience :: Science/Research
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: License :: Other/Proprietary License
36
+ Classifier: Operating System :: OS Independent
37
+ Requires-Python: ~=3.10
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: numpy<2.0,>=1.22.0
41
+ Requires-Dist: tqdm<5.0.0,>=4.64.0
42
+ Requires-Dist: langchain<0.3.0,>=0.1.0
43
+ Requires-Dist: langchain-ollama
44
+ Requires-Dist: langchain-core
45
+ Requires-Dist: langchain-community
46
+ Requires-Dist: ollama<1.0,>=0.0.5
47
+ Requires-Dist: tavily-python<1.0.0,>=0.3.0
48
+ Requires-Dist: requests<3.0,>=2.28
49
+ Requires-Dist: beautifulsoup4<5.0,>=4.11
50
+ Requires-Dist: pytz<2025.0,>=2022.1
51
+ Requires-Dist: pydantic<3.0,>=2.0.0
52
+ Requires-Dist: TTS<1.0,>=0.22.0
53
+ Requires-Dist: torch<3.0,>=2.0.0
54
+ Requires-Dist: transformers<4.40.0,>=4.33.0
55
+ Requires-Dist: torchcodec
56
+ Requires-Dist: langdetect<2.0,>=1.0.9
57
+ Requires-Dist: sounddevice<1.0,>=0.4.6
58
+ Requires-Dist: vosk<0.4,>=0.3.38
59
+ Requires-Dist: huggingface-hub<1.0,>=0.20.0
60
+ Provides-Extra: dev
61
+ Requires-Dist: pytest; extra == "dev"
62
+ Requires-Dist: twine; extra == "dev"
63
+ Requires-Dist: build; extra == "dev"
64
+ Requires-Dist: soundfile<1.0,>=0.10.3; extra == "dev"
65
+ Dynamic: license-file
66
+
67
+ # ai_vtuber
68
+
69
+ > 一個整合 AI 思考、語音辨識、語音合成、網路搜尋、爬蟲等多功能的 AI VTuber 工具包,支援多種工具與本地 LLM,適合自動化對話、語音互動與多模態應用。
70
+
71
+ ---
72
+
73
+ **授權**:詳見 LICENSE
74
+ **Python 版本需求**:3.10.x
75
+
76
+ ## 主要特色
77
+ - 整合 LLM(Ollama)、語音辨識(Vosk)、語音合成(TTS)、網路搜尋(Tavily)、網頁爬蟲等多種工具
78
+ - 支援多語系語音合成與語音克隆
79
+ - 具備短期記憶、多輪對話、工具自定義與擴充能力
80
+ - 適合本地端部署,無需雲端依賴
81
+
82
+ ## 安裝與環境建議
83
+
84
+ - **Python 版本**:需 3.10.x
85
+ - **建議使用虛擬環境**(如 venv、conda、pyenv 等)以避免套件衝突
86
+ - **Ollama 安裝**:
87
+ - 前往 Ollama 官網下載並安裝 Ollama( https://ollama.com/ )
88
+ - Linux 可用:
89
+ ```sh
90
+ curl -fsSL https://ollama.ai/install.sh | sh
91
+ ```
92
+ - Ubuntu 也可用 snap:
93
+ ```sh
94
+ sudo snap install ollama
95
+ ```
96
+ - Windows 可用:
97
+ ```powershell
98
+ irm https://ollama.com/install.ps1 | iex
99
+ ```
100
+
101
+ - **FFmpeg 安裝**:
102
+ - Linux 可用:
103
+ ```sh
104
+ sudo apt update
105
+ sudo apt install ffmpeg
106
+ ```
107
+ - macOS 可用:
108
+ ```sh
109
+ brew install ffmpeg
110
+ ```
111
+ - Windows 可用:
112
+ - 使用 Scoop 安裝:
113
+ ```powershell
114
+ scoop install ffmpeg
115
+ ```
116
+
117
+ - 或使用 Conda 安裝:
118
+ ```powershell
119
+ conda install -c conda-forge ffmpeg
120
+ ```
121
+
122
+ - **PortAudio 安裝**:
123
+ - Linux 可用:
124
+ ```sh
125
+ sudo apt update
126
+ sudo apt install portaudio19-dev
127
+ ```
128
+ - macOS 可用:
129
+ ```sh
130
+ brew install portaudio
131
+ ```
132
+ - Windows 可用:
133
+ ```powershell
134
+ scoop install portaudio
135
+ ```
136
+
137
+ - **安裝依賴套件**:
138
+ - 於專案根目錄執行:
139
+ ```sh
140
+ pip install ai_vtuber
141
+ ```
142
+
143
+ - **下載 LLM 模型**:
144
+ - 於命令列執行:
145
+ ```sh
146
+ ollama pull <model>
147
+ ```
148
+ - 可至 Ollama 官網查詢更多模型
149
+
150
+ ---
151
+
152
+ ## 使用方式
153
+
154
+ - 啟動虛擬環境(如有)
155
+ - 執行主程式(請依你的主程式檔名調整):
156
+ ```sh
157
+ python your_main.py
158
+ ```
159
+
160
+ ## 主要功能簡介
161
+
162
+ - 支援文字與語音互動,具備短期記憶
163
+ - 可使用agent
164
+ - 工具可擴充,支援自訂函式註冊
165
+ - 內建多種常用工具(時間查詢、打招呼、搜尋、爬蟲、語音辨識、語音合成等)
166
+
167
+ ---
168
+
169
+ ## 其他
170
+
171
+ - 詳細 API 與工具用法請參考 API_DOC.md
172
+ - 有任何問題歡迎聯絡作者
@@ -0,0 +1,106 @@
1
+ # ai_vtuber
2
+
3
+ > 一個整合 AI 思考、語音辨識、語音合成、網路搜尋、爬蟲等多功能的 AI VTuber 工具包,支援多種工具與本地 LLM,適合自動化對話、語音互動與多模態應用。
4
+
5
+ ---
6
+
7
+ **授權**:詳見 LICENSE
8
+ **Python 版本需求**:3.10.x
9
+
10
+ ## 主要特色
11
+ - 整合 LLM(Ollama)、語音辨識(Vosk)、語音合成(TTS)、網路搜尋(Tavily)、網頁爬蟲等多種工具
12
+ - 支援多語系語音合成與語音克隆
13
+ - 具備短期記憶、多輪對話、工具自定義與擴充能力
14
+ - 適合本地端部署,無需雲端依賴
15
+
16
+ ## 安裝與環境建議
17
+
18
+ - **Python 版本**:需 3.10.x
19
+ - **建議使用虛擬環境**(如 venv、conda、pyenv 等)以避免套件衝突
20
+ - **Ollama 安裝**:
21
+ - 前往 Ollama 官網下載並安裝 Ollama( https://ollama.com/ )
22
+ - Linux 可用:
23
+ ```sh
24
+ curl -fsSL https://ollama.ai/install.sh | sh
25
+ ```
26
+ - Ubuntu 也可用 snap:
27
+ ```sh
28
+ sudo snap install ollama
29
+ ```
30
+ - Windows 可用:
31
+ ```powershell
32
+ irm https://ollama.com/install.ps1 | iex
33
+ ```
34
+
35
+ - **FFmpeg 安裝**:
36
+ - Linux 可用:
37
+ ```sh
38
+ sudo apt update
39
+ sudo apt install ffmpeg
40
+ ```
41
+ - macOS 可用:
42
+ ```sh
43
+ brew install ffmpeg
44
+ ```
45
+ - Windows 可用:
46
+ - 使用 Scoop 安裝:
47
+ ```powershell
48
+ scoop install ffmpeg
49
+ ```
50
+
51
+ - 或使用 Conda 安裝:
52
+ ```powershell
53
+ conda install -c conda-forge ffmpeg
54
+ ```
55
+
56
+ - **PortAudio 安裝**:
57
+ - Linux 可用:
58
+ ```sh
59
+ sudo apt update
60
+ sudo apt install portaudio19-dev
61
+ ```
62
+ - macOS 可用:
63
+ ```sh
64
+ brew install portaudio
65
+ ```
66
+ - Windows 可用:
67
+ ```powershell
68
+ scoop install portaudio
69
+ ```
70
+
71
+ - **安裝依賴套件**:
72
+ - 於專案根目錄執行:
73
+ ```sh
74
+ pip install ai_vtuber
75
+ ```
76
+
77
+ - **下載 LLM 模型**:
78
+ - 於命令列執行:
79
+ ```sh
80
+ ollama pull <model>
81
+ ```
82
+ - 可至 Ollama 官網查詢更多模型
83
+
84
+ ---
85
+
86
+ ## 使用方式
87
+
88
+ - 啟動虛擬環境(如有)
89
+ - 執行主程式(請依你的主程式檔名調整):
90
+ ```sh
91
+ python your_main.py
92
+ ```
93
+
94
+ ## 主要功能簡介
95
+
96
+ - 支援文字與語音互動,具備短期記憶
97
+ - 可使用agent
98
+ - 工具可擴充,支援自訂函式註冊
99
+ - 內建多種常用工具(時間查詢、打招呼、搜尋、爬蟲、語音辨識、語音合成等)
100
+
101
+ ---
102
+
103
+ ## 其他
104
+
105
+ - 詳細 API 與工具用法請參考 API_DOC.md
106
+ - 有任何問題歡迎聯絡作者
@@ -0,0 +1,4 @@
1
+ from .llm import agent ,BaseOutput,OutputAgent
2
+ from .tool import ALL_TOOLS ,TOOLS_PACKAGE
3
+ from . import tts_module
4
+ from . import asr_module
@@ -0,0 +1,135 @@
1
+ import os
2
+ from queue import Queue
3
+ #匯入該套件直接執行
4
+ from ai_vtuber import agent , TOOLS_PACKAGE
5
+ from ai_vtuber.tts_module import TTSInterface
6
+ from ai_vtuber.asr_module import ASR
7
+ import numpy as np
8
+ import sounddevice as sd
9
+ import soundfile as sf
10
+
11
+ # ── 最後介面互動用 ──
12
+ # import gradio as gr
13
+
14
+ help='''
15
+ help 為看所有指令
16
+ exit 為離開程式
17
+ agent 為測試agent的部分
18
+ tts 為測試tts的部分
19
+ asr 為測試asr的部分
20
+ '''
21
+ while True:
22
+ instruction=input("請輸入指令,不知道可以輸入'help':").lower()
23
+ if instruction == "help":
24
+ print(help)
25
+ elif instruction=="exit":
26
+ exit()
27
+ elif instruction=="agent":
28
+ agent=agent("qwen2.5:7b",list(TOOLS_PACKAGE.get("agent",[]) ),max_memory_rounds=20)
29
+ while True:
30
+ text=input("請輸入文本,(輸入exit離開):")
31
+ if text.lower()=="exit":
32
+ exit()
33
+ result=agent.invoke(text,True)
34
+ print(result)
35
+ print('-'*30)
36
+ print(result.get("output", "No output found")) # type: ignore
37
+ elif instruction=="tts":
38
+ save=(
39
+ input("你想要保存音訊嘛?還是想直接播放(想保存請輸入yes,直接播放則輸入no):").lower()
40
+ =="yes")
41
+ while True:
42
+ wav_path=input("請輸入該參考聲音的wav音訊檔案的路徑 : ")
43
+ if os.path.exists(wav_path):
44
+ break
45
+ else:
46
+ print("路徑輸入錯誤,重新輸入")
47
+ tts=TTSInterface(cuda=False)
48
+ print("開始嘗試生成,接下來請你輸入內容,然後一一生成內容")
49
+ while True:
50
+ text=input("請輸入文本,(輸入exit離開):")
51
+ if text.lower()=="exit":
52
+ exit()
53
+ if save:
54
+ tts.tts_to_file(text,reference_wav_path=wav_path)
55
+ else:
56
+ tts.tts(text,reference_wav_path=wav_path)
57
+ elif instruction=="asr":
58
+ if(input("請輸入是否要自動管理模型(yes/no) : ").lower()=="yes"):
59
+ try:
60
+ model_name=input("請輸入模型名稱 (例如: vosk-model-cn-0.22 ) : ")
61
+ asr=ASR(model_name=model_name)
62
+ print("模型載入成功")
63
+ except Exception as e:
64
+ print(f"錯誤如下:{e}")
65
+ break
66
+ else:
67
+ try:
68
+ model_path=input("請輸入模型路徑 : ")
69
+ asr=ASR(model_path=model_path)
70
+ print("模型載入成功")
71
+ except Exception as e:
72
+ print(f"模型載入失敗{e}")
73
+ break
74
+ if(input("請輸入是要從音訊檔案辨識還是直接從麥克風辨識(file/mic) : ").lower()=="file"):
75
+ while True:
76
+ audio_path=input("請輸入音訊檔案路徑 : ")
77
+ if os.path.exists(audio_path):
78
+ break
79
+ else:
80
+ print("路徑輸入錯誤,重新輸入")
81
+ print("開始嘗試辨識,接下來請你輸入內容,然後一一辨識內容")
82
+ try:
83
+ #讀取音訊檔案(資料、取樣率)
84
+ audio,samplerate=sf.read(
85
+ audio_path,
86
+ dtype="int16"
87
+ )
88
+ text=asr.speach_to_text(audio,samplerate=samplerate)
89
+ print(f"辨識結果為 : {text}")
90
+ except Exception as e:
91
+ print(f"錯誤如下:{e}")
92
+ else:
93
+ # print("敬請期待")
94
+ # pass
95
+ try:
96
+ print("開始從麥克風辨識,按下 enter 結束")
97
+ data=Queue()
98
+ all_data=[]
99
+ def callback(indata, frames, time, status):
100
+ if status:
101
+ print(status)
102
+ data.put(indata.copy())
103
+
104
+ samplerate=16000
105
+ channels=1
106
+ with sd.InputStream(
107
+ samplerate=samplerate,
108
+ channels=channels,
109
+ dtype="int16",
110
+ callback=callback
111
+ ):
112
+ input()
113
+
114
+ while not data.empty():
115
+ all_data.append(data.get())
116
+
117
+ audio=np.concatenate(all_data,axis=0).ravel()
118
+ print("錄音結束,開始辨識")
119
+ text=asr.speach_to_text(audio,samplerate=16000)
120
+ print(f"辨識結果為 : {text}")
121
+
122
+ except Exception as e:
123
+ print(f"錯誤如下:{e}")
124
+ else:
125
+ print("你輸入個無效的指令,請重新輸入")
126
+
127
+ # #介面
128
+ # demo = gr.ChatInterface(
129
+ # fn=agent.agent_chat,
130
+ # title="AI — 多輪對話記憶 (使用 Agent)",
131
+ # description="試試與具備工具使用能力的 AI 聊天。",
132
+ # autofocus=True
133
+ # )
134
+
135
+ # demo.launch(share=True)
@@ -0,0 +1,359 @@
1
+ '''
2
+ 用於agent以及內部提供個llm類別,供後續需要ollama載入llm來使用的人
3
+ 提供兩個類別
4
+ agent 代理人
5
+ _llm 僅載入llm用,不提供相關函式
6
+ '''
7
+ import os
8
+ from typing import Any , List , Tuple , Optional ,Type
9
+ import weakref
10
+ import asyncio
11
+ import json
12
+
13
+ from pydantic import BaseModel,Field
14
+ # ── Ollama模型控制 ──────────────────────────
15
+ import ollama
16
+
17
+ # ── 自訂工具模組載入 ──────────────────────────
18
+ from . import tool
19
+ from langchain_core.tools import BaseTool
20
+
21
+ # ── LangChain: LLM / Agent / 記憶 ───────────────────────────
22
+ from langchain_ollama import ChatOllama
23
+ # from langchain_core.language_models import BaseChatModel
24
+ from langchain.agents import AgentExecutor, create_tool_calling_agent
25
+ from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
26
+
27
+ # 進度條顯示
28
+ from tqdm import tqdm
29
+
30
+ #from langchain.schema.messages import SystemMessage
31
+
32
+ _llm_cache=weakref.WeakValueDictionary()
33
+
34
+ class _llm:
35
+ '''
36
+ 外部使用者請勿使用該類別,此類別僅用於ollama載入llm用
37
+
38
+ **內部成員**
39
+
40
+ :param _system_prompt: 基本prompt
41
+
42
+ :param llm: 載入好的ollama物件
43
+ '''
44
+
45
+ @staticmethod
46
+ def get_model(
47
+ model: str ,
48
+ ):
49
+ llm =_llm_cache.get(model)
50
+ if llm is None:#沒有模型就下載下來並存放到暫存
51
+ #先確認本地端是否有模型,有就不必下載
52
+ try:
53
+ ollama.show(model)
54
+ except ollama.ResponseError as e:
55
+ # 如果報錯且狀態碼是 404,代表模型不在
56
+ if e.status_code == 404:
57
+ print(f"模型 {model} 不存在,正在下載...")
58
+ _llm.download_model(model)
59
+ else:
60
+ raise e
61
+ #設定llm,請自己確保有裝對應的llm model
62
+ llm = ChatOllama(model=model)
63
+ _llm_cache[model]=llm
64
+ return llm
65
+
66
+ @staticmethod
67
+ def download_model(model_name:str):
68
+ print(f"📦 準備下載模型: {model_name}")
69
+
70
+ pbar = None
71
+ last_value = 0
72
+
73
+ try:
74
+ for part in ollama.pull(model_name, stream=True):
75
+ # 使用 .get() 確保找不到 key 時不會崩潰
76
+ status = part.get('status', '')
77
+ total = part.get('total')
78
+ completed = part.get('completed')
79
+
80
+ # 只有當「總量」和「已完成量」都有數字時,才更新進度條
81
+ if total is not None and completed is not None:
82
+ if pbar is None:
83
+ pbar = tqdm(
84
+ total=total,
85
+ unit='B',
86
+ unit_scale=True,
87
+ desc=f"下載中",
88
+ leave=True
89
+ )
90
+
91
+ pbar.update(completed - last_value)
92
+ last_value = completed
93
+
94
+ # 如果還沒開始下載,或者正在驗證,就印出文字狀態
95
+ else:
96
+ # 這裡不使用 print 是為了避免文字跟進度條打架
97
+ if pbar:
98
+ pbar.set_postfix(status=status)
99
+ else:
100
+ print(f"🕒 當前狀態: {status}")
101
+
102
+ if status == 'success':
103
+ if pbar: pbar.close()
104
+ print(f"\n✅ {model_name} 下載完成!")
105
+ return
106
+
107
+ except Exception as e:
108
+ if pbar:
109
+ pbar.close()
110
+ print(f"\n❌ 發生錯誤: {e}")
111
+
112
+
113
+ #直接統整成一個 agent 物件,需要即呼叫該物件即可
114
+ class agent:
115
+ '''
116
+ 統整 llm、agent、記憶 體系的物件
117
+ 用於多輪對話
118
+ 具備短期記憶功能
119
+ 具備工具使用能力
120
+ 請在有ollama的前提下使用它
121
+
122
+ :param model: 使用的 ollama 模型名稱,自行提供
123
+ :type model: str
124
+
125
+ :param prompt: 系統提示prompt,有提供初始值,請自行提供時,
126
+ 請給基本身分、名字、擅長甚麼事情、回答內容長度跟回答語言等資訊
127
+ :type prompt: str
128
+
129
+ **prompt範本列表**
130
+ 1. 傲嬌貓咪平平
131
+
132
+ 你是一個是個傲嬌的貓咪,
133
+ 名字是平平。你擅長於產生貓咪擬人化的文章,\n
134
+ 用來溫柔撫慰人心,文章長度限定在100字以內,
135
+ 請用繁體中文回答。\n
136
+ ...(之後的範本之後添加)
137
+
138
+ :param temperature: 生成文本的溫度,預設為 0.75
139
+ :type temperature: float
140
+
141
+ :param repeat_penalty: 重複懲罰參數,預設為 1.1
142
+ :type repeat_penalty: float
143
+
144
+ :param max_memory_rounds: 設置短期記憶的記憶長度,預設為10輪
145
+ :type max_memory_rounds: int
146
+ '''
147
+
148
+ prompt_list=[
149
+ """
150
+ 你是一個是個傲嬌的貓咪,
151
+ 名字是平平。你擅長於產生貓咪擬人化的文章,
152
+ 用來溫柔撫慰人心,文章長度限定在100字以內,
153
+ 請用繁體中文回答。
154
+ """
155
+ ,
156
+ ]
157
+
158
+ def __init__(
159
+ self ,
160
+ model: str ,
161
+ tools: list[BaseTool],
162
+ prompt: str = prompt_list[0],
163
+ temperature: float = 0.75,
164
+ repeat_penalty: float = 1.1,
165
+ max_memory_rounds: int=10,
166
+ ):
167
+ #初始化到載入llm
168
+ self.llm:Any=(
169
+ _llm.get_model(model)
170
+ .bind(
171
+ temperature=temperature,
172
+ repeat_penalty= repeat_penalty,
173
+ )
174
+ )
175
+
176
+ #設定基本的system prompt
177
+ self._system_prompt = prompt
178
+
179
+ self.prompt_template=ChatPromptTemplate.from_messages(
180
+ messages=[
181
+ #基本的prompt
182
+ ("system", self._system_prompt),
183
+
184
+ # 這裡是一個「標籤」,告訴agent:對話紀錄等一下塞這
185
+ MessagesPlaceholder(variable_name="chat_history"),
186
+
187
+ # 這裡代表使用者輸入的問題
188
+ ("human", "{input}"),
189
+
190
+ # 這裡告訴 Agent:你的思考筆記(工具呼叫)放這
191
+ MessagesPlaceholder(variable_name="agent_scratchpad"),
192
+ ]
193
+
194
+ )
195
+
196
+ #初始化agent的部份前置參數設定等
197
+ agent_logic=create_tool_calling_agent(
198
+ llm=self.llm,
199
+ tools=tools,
200
+ prompt=self.prompt_template
201
+ )
202
+
203
+ #初始化 agent,結合 llm、工具、記憶 體系
204
+ self.agent = AgentExecutor(
205
+ agent=agent_logic,
206
+ tools=tools,
207
+ verbose=True,
208
+ return_intermediate_steps=True,#是否回傳中間步驟
209
+ handle_parsing_errors=True
210
+ )
211
+ #設定記憶功能(並設定自動更新輪數)
212
+ self.memory :List[Tuple[str, str]]= []
213
+ self.max_memory_rounds :int =max_memory_rounds
214
+
215
+ def _trim_history(self)->None:
216
+ """
217
+ 內部方法,用於翻新聊天紀錄,刪除過舊的聊天紀錄用的
218
+ """
219
+ if len(self.memory) > self.max_memory_rounds * 2:
220
+ #如果聊天的次數超過max_memory_rounds就開始翻新聊天紀錄,未超過則無事發生
221
+ # 永遠保留第一輪(通常是自我介紹或重要設定)
222
+ permanent_memory = self.memory[:2]
223
+ # 只滾動更新後面的對話
224
+ recent_memory = self.memory[-(self.max_memory_rounds*2-2):]
225
+ self.memory = permanent_memory + recent_memory
226
+
227
+ def invoke(self, user_message: str, return_steps: bool = False) -> str | dict[str,Any]:
228
+ '''
229
+ :param user_message: 使用者輸入
230
+ :param return_steps: 是否要回傳內心戲 (預設為 False 只給答案)
231
+ '''
232
+ try:
233
+ #推理結果
234
+ result:dict = self.agent.invoke({
235
+ "input": user_message,
236
+ "chat_history": self.memory
237
+ })
238
+
239
+ answer = result["output"]
240
+
241
+ # 更新記憶
242
+ self.memory.append(("human", user_message))
243
+ self.memory.append(("ai", answer))
244
+ self._trim_history()
245
+
246
+ # --- 根據參數決定回傳格式 ---
247
+ return result if return_steps else answer
248
+
249
+ except Exception as e:
250
+ return f"發生錯誤:{e}"
251
+
252
+ async def ainvoke(self, user_message: str, return_steps: bool = False) -> str | dict[str,Any] :
253
+ '''
254
+ :param user_message: 使用者輸入
255
+ :param return_steps: 是否要回傳內心戲 (預設為 False 只給答案)
256
+ '''
257
+ try:
258
+ #推理結果
259
+ result:dict = await self.agent.ainvoke({
260
+ "input": user_message,
261
+ "chat_history": self.memory
262
+ })
263
+
264
+ answer = result["output"]
265
+
266
+ # 更新記憶
267
+ self.memory.append(("human", user_message))
268
+ self.memory.append(("ai", answer))
269
+ self._trim_history()
270
+
271
+ # --- 根據參數決定回傳格式 ---
272
+ return result if return_steps else answer
273
+
274
+ except Exception as e:
275
+ return f"發生錯誤:{e}"
276
+
277
+ class BaseOutput(BaseModel):
278
+ """
279
+ 這是pydantic繼承Basemodel下來的基礎格式化輸出格式,該類別預設僅包含以下欄位
280
+
281
+ Args:
282
+ speech (_str_): 預設內容如下-> Field(default="", description="AI 的回覆文字")
283
+ """
284
+ speech: str = Field(default="", description="AI 的回覆文字")
285
+
286
+ class OutputAgent:
287
+ def __init__(
288
+ self,
289
+ model:str,
290
+ args_schema:Type[BaseOutput] = BaseOutput,
291
+ ):
292
+
293
+ #保存格式
294
+ self.args_schema=args_schema
295
+
296
+ schema_str = json.dumps(self.args_schema.model_json_schema(), ensure_ascii=False)
297
+ safe_schema = schema_str.replace("{", "{{").replace("}", "}}")
298
+
299
+ # 載入prompt
300
+ prompt=f"""
301
+ 你是一個嚴格的格式化工具。
302
+ 你的唯一任務是將原始文字精確拆解,並填入下方指定的 JSON 格式中。
303
+
304
+ ## 輸出格式要求:
305
+ {safe_schema}
306
+
307
+ ## 嚴格規則:
308
+ 1. 必須逐字複製,嚴禁縮減或修改原文。
309
+ 2. 輸出必須是純 JSON 格式,且符合上述結構。
310
+ 3. 嚴禁任何解釋性文字。
311
+ """
312
+ self.prompt = ChatPromptTemplate.from_messages([
313
+ ("system", prompt),
314
+ ("human", "【原始文字】:\n{input}")
315
+ ])
316
+
317
+ #載入llm
318
+ self.llm:Any=(
319
+ self.prompt|
320
+ _llm.get_model(model).with_structured_output(self.args_schema).bind(
321
+ temperature = 0,
322
+ repeat_penalty= 1.2,
323
+ top_p=0.1,
324
+ )
325
+ )
326
+
327
+ def invoke(self, text: str, max_round: int = 5) -> dict:
328
+ for i in range(max_round):
329
+ try:
330
+ result=self.llm.invoke({"input":text})
331
+ if isinstance(result,dict):
332
+ return result
333
+ elif isinstance(result,BaseModel):#雖然最低規格是要給到BaseOutput,但是他的輸出是可能包含BaseModel
334
+ return result.model_dump()
335
+ else:
336
+ print(f"Output,第{i+1}輪格式化後格式不對,其資料型態為:{type(result)}")
337
+ except Exception as e:
338
+ print(f"發生錯誤:{e}")
339
+ try:
340
+ return self.args_schema(speech=text).model_dump()
341
+ except:
342
+ return {"speech": text}
343
+
344
+ async def ainvoke(self, text: str, max_round: int = 5) -> dict:
345
+ for i in range(max_round):
346
+ try:
347
+ result=await self.llm.ainvoke({"input":text})
348
+ if isinstance(result,dict):
349
+ return result
350
+ elif isinstance(result,BaseModel):#雖然最低規格是要給到BaseOutput,但是他的輸出是可能包含BaseModel
351
+ return result.model_dump()
352
+ else:
353
+ print(f"Output,第{i+1}輪格式化後格式不對,其資料型態為:{type(result)}")
354
+ except Exception as e:
355
+ print(f"發生錯誤:{e}")
356
+ try:
357
+ return self.args_schema(speech=text).model_dump()
358
+ except:
359
+ return {"speech": text}
@@ -0,0 +1,151 @@
1
+ '''
2
+ 這是自訂的工具模組,用來給 LangChain Agent 使用的工具集合
3
+ '''
4
+
5
+ # ── 工具創建成對應物件處理 ────────────────────────────────────────
6
+ from langchain_core.tools import tool,BaseTool
7
+ from pydantic import BaseModel,Field
8
+
9
+
10
+ # ── 網路爬蟲 ────────────────────────────────────────
11
+ import requests
12
+ from bs4 import BeautifulSoup
13
+
14
+ # ──取得當下時間用得函示庫 ──────────────────────────────────
15
+ import pytz
16
+ from datetime import datetime#,timedelta
17
+ import time
18
+ import random
19
+ # ──其他 ──────────────────────────────────
20
+ from typing import Callable,Type,Any,Optional
21
+
22
+ ALL_TOOLS:dict[str,Callable]={}
23
+
24
+ def register_tool(func):
25
+ name=getattr(func, "name", None) or getattr(func, "__name__", None)
26
+ if name:
27
+ ALL_TOOLS[name] = func
28
+ else:
29
+ print(f"工具註冊 {func} 失敗,因為找不到工具名字,所以這裡會跳過該工具的註冊")
30
+ return func
31
+
32
+ class TimeToolInput(BaseModel):
33
+ tz_name: Optional[str] = Field(default="Asia/Taipei",description="時區名稱,例如 Asia/Taipei")
34
+
35
+ @register_tool
36
+ @tool(args_schema=TimeToolInput)
37
+ def get_time_tool(tz_name: str ="Asia/Taipei" ) -> str:
38
+ '''
39
+ 該工具負責用於取得指定時區的當下時間,當然如果只是想取得純粹的當下時間,那可以不輸入時區參數,使用預設的台北時間
40
+
41
+ :param tz_name: 時區名稱,例如 Asia/Taipei
42
+ :type tz_name: str
43
+ :return: 指定時區的當下時間字串(格式為 YYYY-MM-DD HH:MM:SS)
44
+ :rtype: str
45
+ '''
46
+ utc_now=datetime.now(pytz.utc)
47
+ try:
48
+ tz = pytz.timezone(tz_name)
49
+ except Exception:
50
+ # 如果時區名稱打錯,預設回傳台北,避免程式報錯當掉
51
+ tz = pytz.timezone("Asia/Taipei")
52
+ now=utc_now.astimezone(tz)
53
+ #new_taipei_now=taipei_now-timedelta(minutes=0)
54
+ return f"現在時間是:{now.strftime('%Y-%m-%d %H:%M:%S')}"
55
+
56
+ class HelloToolInput(BaseModel):
57
+ name: str = Field(description="要打招呼的人的名字")
58
+
59
+ @register_tool
60
+ @tool(args_schema=HelloToolInput) # return_direct=True)#該工具直接回傳打招呼的結果就好了
61
+ def hello_tool(name: str) -> str:
62
+ '''
63
+ 該工具負責用於跟某人說聲你好,像是打招呼的時候就會使用這個工具
64
+
65
+ :param name: 要打招呼的人的名字
66
+ :type name: str
67
+ :return: 打招呼的結果
68
+ :rtype: str
69
+ '''
70
+ return f"你好 {name}! 我是你的AI agent."
71
+
72
+ class WebScraperInput(BaseModel):
73
+ url: str = Field(description="要爬取的網址")
74
+
75
+ # 優化後的網路爬蟲工具,提取文字內容
76
+ @register_tool
77
+ @tool("web_scraper_tool", args_schema=WebScraperInput)
78
+ def web_scraper_tool(url: str) -> str:
79
+ """
80
+ 【深度閱讀工具】
81
+ 抓取指定網址的完整文字。當你需要針對特定文章做『深入摘要』或『完整理解』時使用。
82
+ 輸入來源通常是從ddgs_tool得到的網址。
83
+
84
+ 注意:請提供包含 http 或 https 的有效完整網址。
85
+
86
+ :param url: 要爬取的網址
87
+ :type url: str
88
+ :return: 網頁的標題和部分文字內容
89
+ :rtype: str
90
+ """
91
+
92
+ # 防反爬蟲:隨機 User-Agent、可選代理、隨機延遲
93
+ USER_AGENTS = [
94
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
95
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15',
96
+ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
97
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
98
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0',
99
+ ]
100
+ headers = {
101
+ 'User-Agent': random.choice(USER_AGENTS),
102
+ 'Accept-Language': 'zh-TW,zh;q=0.9,en;q=0.8',
103
+ 'Referer': url,
104
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
105
+ # 你可以根據需要增加更多 header
106
+ }
107
+ # 可選:使用代理伺服器(如有需要)
108
+ proxies = None
109
+ # proxies = {"http": "http://你的代理:端口", "https": "http://你的代理:端口"}
110
+
111
+ # 隨機延遲 1~3 秒,模擬人類行為
112
+ time.sleep(random.uniform(1, 3))
113
+ try:
114
+ response = requests.get(url, headers=headers, timeout=10, proxies=proxies) # 開始請求
115
+ response.raise_for_status() # 檢查請求是否成功
116
+
117
+ # 使用 BeautifulSoup 解析 HTML
118
+ soup = BeautifulSoup(response.content, 'html.parser')
119
+
120
+ # 提取網頁標題
121
+ title = soup.title.string if soup.title else "無標題"
122
+
123
+ # 提取網頁主要文字內容 (移除 script 和 style 標籤)
124
+ for script in soup(["script", "style"]):
125
+ script.extract() #移除這些標籤
126
+
127
+ text = soup.get_text() # 提取所有文字
128
+
129
+ # 清理多餘的空白行
130
+ lines = (line.strip() for line in text.splitlines())
131
+ chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
132
+ text = '\n'.join(chunk for chunk in chunks if chunk)
133
+
134
+ # 回傳標題和部分文字內容
135
+ return f"網頁標題:{title}\n\n網頁內容:\n{text[:2000]}..." # 回傳前2000個字元,若太少可再增加看看
136
+ except requests.exceptions.RequestException as e:
137
+ return f"網路爬蟲錯誤: {e}"
138
+ except Exception as e:
139
+ return f"解析網頁內容錯誤: {e}"
140
+
141
+ TOOLS_PACKAGE:dict[str,tuple]={
142
+ "agent":(
143
+ get_time_tool,
144
+ # hello_tool,
145
+ # ddgs_tool,
146
+ # google_tool,
147
+ # SearXNG_search,
148
+ web_scraper_tool,
149
+ ),
150
+ "all":tuple(ALL_TOOLS.values() )
151
+ }
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai_vtuber
3
+ Version: 0.1.0
4
+ Summary: 整個套件為包含一整個可用的ai vtuber,會包括思考、說話及接收我們對話內容手段等工具
5
+ Author-email: 小ber <a0968066786b@gmail.com>
6
+ License: Copyright (c) 2025 小ber <a0968066786b@gmail.com>
7
+
8
+ 此軟體為專有軟體,未經授權不得使用、修改、分發或商業化。
9
+
10
+ 由於此軟體是我們小組的畢業專題,
11
+ 我們希望能夠保護我們的智慧財產權,
12
+ 因此我們暫先選擇使用專有軟體授權。
13
+
14
+ 您可以:
15
+ - 僅在獲得授權的情況下使用此軟體。
16
+
17
+ 您不得:
18
+ - 未經授權修改、分發或商業化此軟體。
19
+ - 將此軟體用於任何非法用途。
20
+
21
+ 如需授權或其他問題,請聯絡作者:a0968066786b@gmail.com
22
+
23
+ 未來可能方向:
24
+ - 考慮在未來釋出開源版本,屆時若開源將會更新授權條款。
25
+ - 歡迎聯絡我們討論合作或授權事宜。
26
+
27
+ Project-URL: Homepage, https://github.com/Super-Boy-1/ai_vtuber.git
28
+ Project-URL: Source, https://github.com/Super-Boy-1/ai_vtuber.git
29
+ Keywords: ai,vtuber,ai vtuber,python
30
+ Classifier: Development Status :: 2 - Pre-Alpha
31
+ Classifier: Intended Audience :: End Users/Desktop
32
+ Classifier: Intended Audience :: Science/Research
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: License :: Other/Proprietary License
36
+ Classifier: Operating System :: OS Independent
37
+ Requires-Python: ~=3.10
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: numpy<2.0,>=1.22.0
41
+ Requires-Dist: tqdm<5.0.0,>=4.64.0
42
+ Requires-Dist: langchain<0.3.0,>=0.1.0
43
+ Requires-Dist: langchain-ollama
44
+ Requires-Dist: langchain-core
45
+ Requires-Dist: langchain-community
46
+ Requires-Dist: ollama<1.0,>=0.0.5
47
+ Requires-Dist: tavily-python<1.0.0,>=0.3.0
48
+ Requires-Dist: requests<3.0,>=2.28
49
+ Requires-Dist: beautifulsoup4<5.0,>=4.11
50
+ Requires-Dist: pytz<2025.0,>=2022.1
51
+ Requires-Dist: pydantic<3.0,>=2.0.0
52
+ Requires-Dist: TTS<1.0,>=0.22.0
53
+ Requires-Dist: torch<3.0,>=2.0.0
54
+ Requires-Dist: transformers<4.40.0,>=4.33.0
55
+ Requires-Dist: torchcodec
56
+ Requires-Dist: langdetect<2.0,>=1.0.9
57
+ Requires-Dist: sounddevice<1.0,>=0.4.6
58
+ Requires-Dist: vosk<0.4,>=0.3.38
59
+ Requires-Dist: huggingface-hub<1.0,>=0.20.0
60
+ Provides-Extra: dev
61
+ Requires-Dist: pytest; extra == "dev"
62
+ Requires-Dist: twine; extra == "dev"
63
+ Requires-Dist: build; extra == "dev"
64
+ Requires-Dist: soundfile<1.0,>=0.10.3; extra == "dev"
65
+ Dynamic: license-file
66
+
67
+ # ai_vtuber
68
+
69
+ > 一個整合 AI 思考、語音辨識、語音合成、網路搜尋、爬蟲等多功能的 AI VTuber 工具包,支援多種工具與本地 LLM,適合自動化對話、語音互動與多模態應用。
70
+
71
+ ---
72
+
73
+ **授權**:詳見 LICENSE
74
+ **Python 版本需求**:3.10.x
75
+
76
+ ## 主要特色
77
+ - 整合 LLM(Ollama)、語音辨識(Vosk)、語音合成(TTS)、網路搜尋(Tavily)、網頁爬蟲等多種工具
78
+ - 支援多語系語音合成與語音克隆
79
+ - 具備短期記憶、多輪對話、工具自定義與擴充能力
80
+ - 適合本地端部署,無需雲端依賴
81
+
82
+ ## 安裝與環境建議
83
+
84
+ - **Python 版本**:需 3.10.x
85
+ - **建議使用虛擬環境**(如 venv、conda、pyenv 等)以避免套件衝突
86
+ - **Ollama 安裝**:
87
+ - 前往 Ollama 官網下載並安裝 Ollama( https://ollama.com/ )
88
+ - Linux 可用:
89
+ ```sh
90
+ curl -fsSL https://ollama.ai/install.sh | sh
91
+ ```
92
+ - Ubuntu 也可用 snap:
93
+ ```sh
94
+ sudo snap install ollama
95
+ ```
96
+ - Windows 可用:
97
+ ```powershell
98
+ irm https://ollama.com/install.ps1 | iex
99
+ ```
100
+
101
+ - **FFmpeg 安裝**:
102
+ - Linux 可用:
103
+ ```sh
104
+ sudo apt update
105
+ sudo apt install ffmpeg
106
+ ```
107
+ - macOS 可用:
108
+ ```sh
109
+ brew install ffmpeg
110
+ ```
111
+ - Windows 可用:
112
+ - 使用 Scoop 安裝:
113
+ ```powershell
114
+ scoop install ffmpeg
115
+ ```
116
+
117
+ - 或使用 Conda 安裝:
118
+ ```powershell
119
+ conda install -c conda-forge ffmpeg
120
+ ```
121
+
122
+ - **PortAudio 安裝**:
123
+ - Linux 可用:
124
+ ```sh
125
+ sudo apt update
126
+ sudo apt install portaudio19-dev
127
+ ```
128
+ - macOS 可用:
129
+ ```sh
130
+ brew install portaudio
131
+ ```
132
+ - Windows 可用:
133
+ ```powershell
134
+ scoop install portaudio
135
+ ```
136
+
137
+ - **安裝依賴套件**:
138
+ - 於專案根目錄執行:
139
+ ```sh
140
+ pip install ai_vtuber
141
+ ```
142
+
143
+ - **下載 LLM 模型**:
144
+ - 於命令列執行:
145
+ ```sh
146
+ ollama pull <model>
147
+ ```
148
+ - 可至 Ollama 官網查詢更多模型
149
+
150
+ ---
151
+
152
+ ## 使用方式
153
+
154
+ - 啟動虛擬環境(如有)
155
+ - 執行主程式(請依你的主程式檔名調整):
156
+ ```sh
157
+ python your_main.py
158
+ ```
159
+
160
+ ## 主要功能簡介
161
+
162
+ - 支援文字與語音互動,具備短期記憶
163
+ - 可使用agent
164
+ - 工具可擴充,支援自訂函式註冊
165
+ - 內建多種常用工具(時間查詢、打招呼、搜尋、爬蟲、語音辨識、語音合成等)
166
+
167
+ ---
168
+
169
+ ## 其他
170
+
171
+ - 詳細 API 與工具用法請參考 API_DOC.md
172
+ - 有任何問題歡迎聯絡作者
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ ai_vtuber/__init__.py
5
+ ai_vtuber/__main__.py
6
+ ai_vtuber/llm.py
7
+ ai_vtuber/tool.py
8
+ ai_vtuber.egg-info/PKG-INFO
9
+ ai_vtuber.egg-info/SOURCES.txt
10
+ ai_vtuber.egg-info/dependency_links.txt
11
+ ai_vtuber.egg-info/requires.txt
12
+ ai_vtuber.egg-info/top_level.txt
@@ -0,0 +1,26 @@
1
+ numpy<2.0,>=1.22.0
2
+ tqdm<5.0.0,>=4.64.0
3
+ langchain<0.3.0,>=0.1.0
4
+ langchain-ollama
5
+ langchain-core
6
+ langchain-community
7
+ ollama<1.0,>=0.0.5
8
+ tavily-python<1.0.0,>=0.3.0
9
+ requests<3.0,>=2.28
10
+ beautifulsoup4<5.0,>=4.11
11
+ pytz<2025.0,>=2022.1
12
+ pydantic<3.0,>=2.0.0
13
+ TTS<1.0,>=0.22.0
14
+ torch<3.0,>=2.0.0
15
+ transformers<4.40.0,>=4.33.0
16
+ torchcodec
17
+ langdetect<2.0,>=1.0.9
18
+ sounddevice<1.0,>=0.4.6
19
+ vosk<0.4,>=0.3.38
20
+ huggingface-hub<1.0,>=0.20.0
21
+
22
+ [dev]
23
+ pytest
24
+ twine
25
+ build
26
+ soundfile<1.0,>=0.10.3
@@ -0,0 +1 @@
1
+ ai_vtuber
@@ -0,0 +1,114 @@
1
+ [build-system]
2
+ # 告訴 pip 和建構工具 (如 build) 應該使用 setuptools 來建構你的套件
3
+ requires = ["setuptools>=61.0.0", "wheel"]# 指定打包時的建構版本
4
+ build-backend = "setuptools.build_meta"
5
+
6
+ [project]
7
+ # ====================================================================
8
+ # 核心元資料 (Metadata) 區塊
9
+ # ====================================================================
10
+
11
+ name = "ai_vtuber" # "<您的-套件-名稱-用-連字號-小寫>", 範例: my-mc-toolkit
12
+ version = "0.1.0" # 初始版本號,發佈前務必更新
13
+ description = " 整個套件為包含一整個可用的ai vtuber,會包括思考、說話及接收我們對話內容手段等工具"
14
+ # 簡短描述您的套件功能
15
+ readme = "README.md" # 指向您的說明文件
16
+ authors = [{name = "小ber", email = "a0968066786b@gmail.com"}]
17
+ license = {file = "LICENSE"} # 指向您的授權檔案
18
+
19
+ # 套件運行所需的 Python 版本
20
+ requires-python = "~=3.10"
21
+
22
+ # 關鍵字,幫助使用者在 PyPI 上搜尋您的套件
23
+ keywords = ["ai", "vtuber","ai vtuber", "python"]
24
+
25
+ # 核心依賴項:套件運行時必須安裝的外部套件
26
+ dependencies = [
27
+ #==base部分==
28
+ "numpy>=1.22.0,<2.0", # 數值計算
29
+ "tqdm>=4.64.0,<5.0.0", # 進度條顯示
30
+ #== LLM部分 ==
31
+ "langchain>=0.1.0,<0.3.0", # LangChain 主套件
32
+ "langchain-ollama", #langchain作者把ollama相關功能包成新的該套件並優化了,所以高版本的langchain需要用他(因為好像不自帶)
33
+ "langchain-core", # 若使用新架構需 core 套件
34
+ "langchain-community", # community 擴充(Ollama adapter 等)
35
+ "ollama>=0.0.5,<1.0", # Ollama client(與本地 Ollama 互動)
36
+ #== 搜尋、爬蟲等外部聯網部分
37
+ "tavily-python>=0.3.0,<1.0.0", # Tavily 搜尋工具(使用api的,運行較ddgs穩定)
38
+ "requests>=2.28,<3.0", # HTTP 請求
39
+ "beautifulsoup4>=4.11,<5.0", # HTML 解析
40
+ "pytz>=2022.1,<2025.0", # 時區處理
41
+ "pydantic>=2.0.0,<3.0", #資料格式化用
42
+ #== TTS部分 ==
43
+ "TTS>=0.22.0,<1.0",
44
+ "torch>=2.0.0,<3.0", #可能會有問題,會需要先手動安裝他
45
+ "transformers>=4.33.0,<4.40.0", #指定特定版本給他,不然版本不相容
46
+ "torchcodec",
47
+ "langdetect>=1.0.9,<2.0", #語言檢測使用
48
+ "sounddevice>=0.4.6,<1.0", #播放音訊用
49
+ #== ASR部分 ==
50
+ "vosk>=0.3.38,<0.4", # Vosk 語音辨識引擎
51
+ "huggingface-hub>=0.20.0,<1.0", # 用於下載模型(因為vosk預設為手動管理模型,我們要升級成自動管理)
52
+ ]
53
+
54
+ # ====================================================================
55
+ # 外部環境依賴與必要服務 (非 Python 套件,需手動安裝)
56
+ # --------------------------------------------------------------------
57
+ # 這些組件無法透過 pip 或 conda 直接安裝,是運行本專案的必要條件。
58
+ # 請務必在啟動專案前完成安裝與設定。
59
+
60
+ # [外部依賴 1:FFmpeg (多媒體處理)]
61
+ # XTTS 語音合成需要系統中安裝 FFmpeg 函式庫來處理音訊編解碼。
62
+ # 建議安裝方式 (擇一):
63
+ # 1. Conda環境 (推薦): conda install -c conda-forge ffmpeg
64
+ # 2. Linux (Debian/Ubuntu): sudo apt update && sudo apt install ffmpeg
65
+
66
+ # [外部服務 2:Ollama (LLM 推理服務)]
67
+ # 思考與問答功能依賴 Ollama 服務來運行 gemma:4b 或其他大型語言模型。
68
+ # 1. 安裝 Ollama 服務:請參考 Ollama 官方網站 (https://ollama.com/) 下載並安裝。
69
+ # 2. 啟動模型:確保服務運行後,執行指令載入模型:ollama run gemma:4b
70
+ # 3. 確保服務在本地端口 (預設 11434) 運行。
71
+ #
72
+ # 外部服務 3: PortAudio
73
+ # sounddevice 需要底層的 PortAudio 函式庫才能在 Linux/macOS 上運作。
74
+ # 建議安裝方式:
75
+ # 1.Liunx(Ubuntu): sudo apt install libportaudio2
76
+ # 在 macOS 上 (使用 Homebrew):$ brew install portaudio
77
+ # ====================================================================
78
+
79
+ # 分類標籤:描述套件的狀態、授權等,幫助 PyPI 分類
80
+ classifiers = [
81
+ "Development Status :: 2 - Pre-Alpha",#llm測試環節,其他部分還沒開發?
82
+ # 開發狀態:1-計畫中,3-測試中,5-穩定
83
+
84
+ # "Intended Audience :: Developers", #到目前都還不怎麼面向開發者,暫不放這個
85
+ "Intended Audience :: End Users/Desktop", #面向普通終端使用者
86
+ "Intended Audience :: Science/Research", #面向科學研究用途
87
+
88
+ "Programming Language :: Python :: 3",
89
+ "Programming Language :: Python :: 3.10",
90
+
91
+ "License :: Other/Proprietary License",
92
+
93
+ "Operating System :: OS Independent",
94
+ ]
95
+
96
+ [project.urls]
97
+ # 專案相關連結
98
+ Homepage = "https://github.com/Super-Boy-1/ai_vtuber.git"
99
+ Source = "https://github.com/Super-Boy-1/ai_vtuber.git"
100
+
101
+ [tool.setuptools]
102
+ # 告訴 setuptools 您的 Python 原始碼放在哪裡
103
+ # 這裡必須是您的套件目錄名稱 (例如: my_mc_toolkit)
104
+ packages = ["ai_vtuber"]
105
+
106
+ # 可選依賴項:使用者可以選擇性安裝 (例如用於開發或特定功能)
107
+ [project.optional-dependencies]
108
+ dev = [
109
+ "pytest", # 測試工具
110
+ "twine", # 發佈工具
111
+ "build", # 打包工具
112
+ # "black", # 程式碼格式化工具
113
+ "soundfile>=0.10.3,<1.0", # 用於處理音訊檔案
114
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+