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

XFEstudio/gpt4free

Improve user identity header handling in Copilot provider by conditionally including it based on access token presence.

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

代码差异

1 个文件 +2 -2
Modified g4f/Provider/Copilot.py +2 -2
@@ -156,7 +156,7 @@ class Copilot(AsyncAuthedProvider, ProviderModelMixin):
156 156 else:
157 157 debug.log(f"Copilot: User: {user}")
158 158 if conversation is None:
159 response = await session.post(cls.conversation_url, headers={"x-useridentitytype": useridentitytype})
159 response = await session.post(cls.conversation_url, headers={"x-useridentitytype": useridentitytype} if cls._access_token else {})
160 160 response.raise_for_status()
161 161 conversation_id = response.json().get("id")
162 162 conversation = Conversation(conversation_id)
@@ -178,7 +178,7 @@ class Copilot(AsyncAuthedProvider, ProviderModelMixin):
178 178 headers={
179 179 "content-type": is_accepted_format(data),
180 180 "content-length": str(len(data)),
181 "x-useridentitytype": useridentitytype
181 **({"x-useridentitytype": useridentitytype} if cls._access_token else {})
182 182 },
183 183 data=data
184 184 )