Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加了对于本地Ollama模型的支持选项与基于中国国家气象局的天气接口 #91

Merged
merged 6 commits into from
Feb 3, 2025

Conversation

Horldsence
Copy link
Contributor

本地Ollama模型支持

添加了 base/func_ollama.py 文件实现具体功能

修改了robot.py 添加实现

天气接口

添加了 base/func_weather.py 实现具体功能

添加了 base/city.json 为接口实现自动城市码的查找

Copy link
Owner

@lich0821 lich0821 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢大佬 PR!

url = 'http://t.weather.sojson.com/api/weather/city/'

# 读取json文件
f = open('C:\\Users\\PengHeng\\Documents\\#appCode\\Python\\WeChatRobot\\base\\city.json', 'rb')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

路径这样写死了,其他用户基本上就会遇到找不到文件。
另外,自己维护一张映射表还是比较累的,现在只有400多个城市,很容易就有人来问为什么查不到xxx城市的天气。
建议找一个接口来管理。

robot.py Outdated
Comment on lines 123 to 125
rsp = "梅好事助手正在通知人工处理"
elif "天气" in msg.content: # 如果消息中含有"天气",则不使用ChatGPT
rsp = "梅好事助手查询到芜湖天气为:\n" + get_weather("芜湖")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里建议助手名称一般化,不同用户可能需要不同的助手名。

@Horldsence
Copy link
Contributor Author

就以上由于我个人疏忽造成的问题:

路径写死

这个确实是忘记改为相对路径了(

  1. 直接更换为城市码,城市码在互联网上可查,仍保留citycode作为参考文件
  2. 将该功能单独写了一个类,并在配置文件中加入对应的配置选项。现在基本与新闻使用体验类似
  3. 更改了configuration.py中Config,使reload后可以适用新配置
  4. 添加了日志输出

配置助手名称

  1. 忘记删了,已经删除并重新提交
  2. 修复了输出格式的一个小问题

Copy link
Owner

@lich0821 lich0821 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, ship~

@lich0821 lich0821 merged commit d883c6c into lich0821:master Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants