refactor: 移除qianfan模型相关代码和依赖
This commit is contained in:
parent
93d2dac343
commit
7f1b4f4a59
@ -42,7 +42,6 @@ dependencies = [
|
|||||||
"python-jose[cryptography]>=3.4.0",
|
"python-jose[cryptography]>=3.4.0",
|
||||||
"python-multipart>=0.0.20",
|
"python-multipart>=0.0.20",
|
||||||
"pyyaml>=6.0.2",
|
"pyyaml>=6.0.2",
|
||||||
"qianfan>=0.4.12.3",
|
|
||||||
"rapidocr-onnxruntime>=1.4.4",
|
"rapidocr-onnxruntime>=1.4.4",
|
||||||
"tavily-python>=0.7.0",
|
"tavily-python>=0.7.0",
|
||||||
"unstructured>=0.17.2",
|
"unstructured>=0.17.2",
|
||||||
|
|||||||
@ -14,10 +14,6 @@ def select_model(model_provider, model_name=None):
|
|||||||
|
|
||||||
logger.info(f"Selecting model from `{model_provider}` with `{model_name}`")
|
logger.info(f"Selecting model from `{model_provider}` with `{model_name}`")
|
||||||
|
|
||||||
if model_provider == "qianfan":
|
|
||||||
from src.models.chat_model import Qianfan
|
|
||||||
return Qianfan(model_name)
|
|
||||||
|
|
||||||
if model_provider == "openai":
|
if model_provider == "openai":
|
||||||
from src.models.chat_model import OpenModel
|
from src.models.chat_model import OpenModel
|
||||||
return OpenModel(model_name)
|
return OpenModel(model_name)
|
||||||
|
|||||||
@ -83,45 +83,5 @@ class GeneralResponse:
|
|||||||
self.content = content
|
self.content = content
|
||||||
self.is_full = False
|
self.is_full = False
|
||||||
|
|
||||||
|
|
||||||
class Qianfan(OpenAIBase):
|
|
||||||
"""弃用"""
|
|
||||||
|
|
||||||
def __init__(self, model_name="ernie_speed") -> None:
|
|
||||||
import qianfan
|
|
||||||
self.model_name = model_name
|
|
||||||
access_key = os.getenv("QIANFAN_ACCESS_KEY")
|
|
||||||
secret_key = os.getenv("QIANFAN_SECRET_KEY")
|
|
||||||
self.client = qianfan.ChatCompletion(ak=access_key, sk=secret_key)
|
|
||||||
|
|
||||||
def predict(self, message, stream=False):
|
|
||||||
if isinstance(message, str):
|
|
||||||
messages=[{"role": "user", "content": message}]
|
|
||||||
else:
|
|
||||||
messages = message
|
|
||||||
|
|
||||||
if stream:
|
|
||||||
return self._stream_response(messages)
|
|
||||||
else:
|
|
||||||
return self._get_response(messages)
|
|
||||||
|
|
||||||
def _stream_response(self, messages):
|
|
||||||
response = self.client.do(
|
|
||||||
model=self.model_name,
|
|
||||||
messages=messages,
|
|
||||||
stream=True,
|
|
||||||
)
|
|
||||||
for chunk in response:
|
|
||||||
yield GeneralResponse(chunk["body"]["result"])
|
|
||||||
|
|
||||||
def _get_response(self, messages):
|
|
||||||
response = self.client.do(
|
|
||||||
model=self.model_name,
|
|
||||||
messages=messages,
|
|
||||||
stream=False,
|
|
||||||
)
|
|
||||||
return GeneralResponse(response["body"]["result"])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import openaiIcon from '@/assets/providers/openai.png'
|
import openaiIcon from '@/assets/providers/openai.png'
|
||||||
import qianfanIcon from '@/assets/providers/qianfan.png'
|
|
||||||
import dashscopeIcon from '@/assets/providers/dashscope.png'
|
import dashscopeIcon from '@/assets/providers/dashscope.png'
|
||||||
import togetherIcon from '@/assets/providers/together.ai.png'
|
import togetherIcon from '@/assets/providers/together.ai.png'
|
||||||
import deepseekIcon from '@/assets/providers/deepseek.png'
|
import deepseekIcon from '@/assets/providers/deepseek.png'
|
||||||
@ -11,7 +10,6 @@ import defaultIcon from '@/assets/providers/default.png'
|
|||||||
|
|
||||||
export const modelIcons = {
|
export const modelIcons = {
|
||||||
openai: openaiIcon,
|
openai: openaiIcon,
|
||||||
qianfan: qianfanIcon,
|
|
||||||
dashscope: dashscopeIcon,
|
dashscope: dashscopeIcon,
|
||||||
together: togetherIcon,
|
together: togetherIcon,
|
||||||
deepseek: deepseekIcon,
|
deepseek: deepseekIcon,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user