INFO: 192.168.1.8:49765 - "GET / HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi result = await app( # type: ignore[func-returns-value] File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__ return await self.app(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1106, in __call__ await super().__call__(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__ await self.middleware_stack(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__ raise exc File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__ await self.app(scope, receive, _send) File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__ raise exc File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__ await self.app(scope, receive, sender) File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__ raise e File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__ await self.app(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__ await route.handle(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 66, in app response = await func(request) File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 274, in app raw_response = await run_endpoint_function( File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(**values) File "/app/api/main.py", line 11, in root WechatChannel().send(reply , None) File "/app/channel/wechat/wechat_channel.py", line 295, in send itchat.send(reply.content, toUserName=receiver) File "/app/lib/itchat/components/messages.py", line 513, in send r = self.send_msg(msg, toUserName) File "/app/lib/itchat/components/messages.py", line 283, in send_msg r = self.send_raw_msg(1, msg, toUserName) File "/app/lib/itchat/components/messages.py", line 264, in send_raw_msg url = '%s/webwxsendmsg' % self.loginInfo['url'] KeyError: 'url'
⚠️ 搜索是否存在类似issue
总结
想在chatgpt-on-wechat中使用FastAPI启动接口服务,提供给第三方使用。 微信主要功能:给某个人或群组发送定时消息等。
举例
`import uvicorn from fastapi import FastAPI from bridge.reply import Reply, ReplyType from channel.wechat.wechat_channel import WechatChannel
app = FastAPI()
@app.get("/") async def root(): reply = Reply(ReplyType.TEXT, "你好!有什么问题或者需要帮助的吗?")
WechatChannel().send(reply , “如何封装Context?”)`
但是以上的做法会报错:
INFO: 192.168.1.8:49765 - "GET / HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi result = await app( # type: ignore[func-returns-value] File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__ return await self.app(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1106, in __call__ await super().__call__(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 122, in __call__ await self.middleware_stack(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__ raise exc File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__ await self.app(scope, receive, _send) File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__ raise exc File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__ await self.app(scope, receive, sender) File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__ raise e File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__ await self.app(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__ await route.handle(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 66, in app response = await func(request) File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 274, in app raw_response = await run_endpoint_function( File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function return await dependant.call(**values) File "/app/api/main.py", line 11, in root WechatChannel().send(reply , None) File "/app/channel/wechat/wechat_channel.py", line 295, in send itchat.send(reply.content, toUserName=receiver) File "/app/lib/itchat/components/messages.py", line 513, in send r = self.send_msg(msg, toUserName) File "/app/lib/itchat/components/messages.py", line 283, in send_msg r = self.send_raw_msg(1, msg, toUserName) File "/app/lib/itchat/components/messages.py", line 264, in send_raw_msg url = '%s/webwxsendmsg' % self.loginInfo['url'] KeyError: 'url'
动机
想在chatgpt-on-wechat中使用FastAPI启动接口服务,提供给第三方使用。 微信主要功能:给某个人或群组发送定时消息等。