XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

Support novita in HuggingFace

6ccdb9d4
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

2 个文件 +7 -4
Modified g4f/Provider/needs_auth/GeminiPro.py +2 -1
@@ -116,6 +116,7 @@ class GeminiPro(AsyncGeneratorProvider, ProviderModelMixin):
116 116 "data": base64.b64encode(media_data).decode()
117 117 }
118 118 })
119 responseModalities = {"responseModalities": ["AUDIO"]} if "tts" in model else {}
119 120 data = {
120 121 "contents": contents,
121 122 "generationConfig": {
@@ -124,7 +125,7 @@ class GeminiPro(AsyncGeneratorProvider, ProviderModelMixin):
124 125 "maxOutputTokens": kwargs.get("max_tokens"),
125 126 "topP": kwargs.get("top_p"),
126 127 "topK": kwargs.get("top_k"),
127 **{"responseModalities": ["AUDIO"]} if "tts" in model else {},
128 **responseModalities,
128 129 },
129 130 "tools": [{
130 131 "function_declarations": [{
Modified g4f/Provider/needs_auth/hf/HuggingFaceAPI.py +5 -3
@@ -90,13 +90,12 @@ class HuggingFaceAPI(OpenaiTemplate):
90 90 raise ModelNotFoundError(f"Model is not supported: {model} in: {cls.__name__}")
91 91 error = None
92 92 for provider_key in provider_mapping:
93 api_path = provider_key if provider_key == "novita" else f"{provider_key}/v1"
93 api_path = "novita/v3/openai" if provider_key == "novita" else f"{provider_key}/v1"
94 94 api_base = f"https://router.huggingface.co/{api_path}"
95 95 task = provider_mapping[provider_key]["task"]
96 96 if task != "conversational":
97 97 raise ModelNotFoundError(f"Model is not supported: {model} in: {cls.__name__} task: {task}")
98 98 model = provider_mapping[provider_key]["providerId"]
99 yield ProviderInfo(**{**cls.get_dict(), "label": f"HuggingFace ({provider_key})"})
100 99 # start = calculate_lenght(messages)
101 100 # if start > max_inputs_lenght:
102 101 # if len(messages) > 6:
@@ -110,7 +109,10 @@ class HuggingFaceAPI(OpenaiTemplate):
110 109 # debug.log(f"Messages trimmed from: {start} to: {calculate_lenght(messages)}")
111 110 try:
112 111 async for chunk in super().create_async_generator(model, messages, api_base=api_base, api_key=api_key, max_tokens=max_tokens, media=media, **kwargs):
113 yield chunk
112 if isinstance(chunk, ProviderInfo):
113 yield ProviderInfo(**{**chunk.get_dict(), "label": f"HuggingFace ({provider_key})"})
114 else:
115 yield chunk
114 116 return
115 117 except PaymentRequiredError as e:
116 118 error = e