Spaces:
Runtime error
Runtime error
Delete CHATTS/experimental/llm.py
Browse files- CHATTS/experimental/llm.py +0 -40
CHATTS/experimental/llm.py
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
|
2 |
-
from openai import OpenAI
|
3 |
-
|
4 |
-
prompt_dict = {
|
5 |
-
'kimi': [ {"role": "system", "content": "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。"},
|
6 |
-
{"role": "user", "content": "你好,请注意你现在生成的文字要按照人日常生活的口吻,你的回复将会后续用TTS模型转为语音,并且请把回答控制在100字以内。并且标点符号仅包含逗号和句号,将数字等转为文字回答。"},
|
7 |
-
{"role": "assistant", "content": "好的,我现在生成的文字将按照人日常生活的口吻, 并且我会把回答控制在一百字以内, 标点符号仅包含逗号和句号,将阿拉伯数字等转为中文文字回答。下面请开始对话。"},],
|
8 |
-
'deepseek': [
|
9 |
-
{"role": "system", "content": "You are a helpful assistant"},
|
10 |
-
{"role": "user", "content": "你好,请注意你现在生成的文字要按照人日常生活的口吻,你的回复将会后续用TTS模型转为语音,并且请把回答控制在100字以内。并且标点符号仅包含逗号和句号,将数字等转为文字回答。"},
|
11 |
-
{"role": "assistant", "content": "好的,我现在生成的文字将按照人日常生活的口吻, 并且我会把回答控制在一百字以内, 标点符号仅包含逗号和句号,将阿拉伯数字等转为中文文字回答。下面请开始对话。"},],
|
12 |
-
'deepseek_TN': [
|
13 |
-
{"role": "system", "content": "You are a helpful assistant"},
|
14 |
-
{"role": "user", "content": "你好,现在我们在处理TTS的文本输入,下面将会给你输入一段文本,请你将其中的阿拉伯数字等等转为文字表达,并且输出的文本里仅包含逗号和句号这两个标点符号"},
|
15 |
-
{"role": "assistant", "content": "好的,我现在对TTS的文本输入进行处理。这一般叫做text normalization。下面请输入"},
|
16 |
-
{"role": "user", "content": "We paid $123 for this desk."},
|
17 |
-
{"role": "assistant", "content": "We paid one hundred and twenty three dollars for this desk."},
|
18 |
-
{"role": "user", "content": "详询请拨打010-724654"},
|
19 |
-
{"role": "assistant", "content": "详询请拨打零幺零,七二四六五四"},
|
20 |
-
{"role": "user", "content": "罗森宣布将于7月24日退市,在华门店超6000家!"},
|
21 |
-
{"role": "assistant", "content": "罗森宣布将于七月二十四日退市,在华门店超过六千家。"},
|
22 |
-
],
|
23 |
-
}
|
24 |
-
|
25 |
-
class llm_api:
|
26 |
-
def __init__(self, api_key, base_url, model):
|
27 |
-
self.client = OpenAI(
|
28 |
-
api_key = api_key,
|
29 |
-
base_url = base_url,
|
30 |
-
)
|
31 |
-
self.model = model
|
32 |
-
def call(self, user_question, temperature = 0.3, prompt_version='kimi', **kwargs):
|
33 |
-
|
34 |
-
completion = self.client.chat.completions.create(
|
35 |
-
model = self.model,
|
36 |
-
messages = prompt_dict[prompt_version]+[{"role": "user", "content": user_question},],
|
37 |
-
temperature = temperature,
|
38 |
-
**kwargs
|
39 |
-
)
|
40 |
-
return completion.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|