Skip to content

Commit

Permalink
Merge pull request #3 from Sanotsu/dev
Browse files Browse the repository at this point in the history
merge:合并0.3.0测试版本
  • Loading branch information
Sanotsu authored Nov 5, 2024
2 parents 1bc79b5 + 23e98e9 commit fe8a04d
Show file tree
Hide file tree
Showing 66 changed files with 11,579 additions and 193 deletions.
34 changes: 32 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# Changelog

All notable changes to this project will be documented in this file.
一些较大变更、新功能、bug 修复等记录放在此处,仅做参看的提交更新.

## 0.3.0-beta.1

- chore:
- 更新开发环境到 flutter 3.24.4、Java 17, 以及更新相关依赖到最新
- refactor:
- 将“生活日常工具”中模块划分为几个大类:
- **实用工具**: 极简记账、随机菜品、猫狗之家、英英词典(新)
- **图片动漫**: BGM 动漫资讯、MAL 动漫排行、WAIFU 图片
- **摸鱼新闻(新)**: 摸摸鱼、每天 60 秒
- **饮食健康(新)**: USDA 食品数据、Nutritionix 食品数据、热量计算器
- feat:
- 在“生活日常工具”主页上方添加了每日一言
- “生活日常工具”添加了以下几个新模块:
- **英英词典**:使用 [freeDictionaryAPI](https://github.com/meetDeveloper/freeDictionaryAPI) 做的英英释义词典
- 如果单词在 API 中查不到,可以使用“AI 翻译”通过大模型获取释义
- **摸摸鱼**: 来源于 [摸摸鱼热榜](https://momoyu.cc/) 聚合新闻热点
- **每天 60 秒**: [每天 60 秒图片](https://api.03c3.cn/api/zb) 展示最近热点新闻
- **USDA 食品数据**: 来源于 [美国农业部(USDA)官方的食品数据](https://fdc.nal.usda.gov/api-guide.html),可用“英文”进行搜索查询
- 包含基础食品、品牌(美国)食品等 40 多万条数据
- 目前用的"DEMO_KEY"作为 api_key,可自行申请替换
- **Nutritionix 食品数据**: 来源于 [Nutritionix](https://www.nutritionix.com/business/api) 的食品营养素数据,可用“英文”进行搜索查询。
- 号称“Largest Verified Nutrition Database”
- 截止 2024-11-04,拥有“1,202,162 food items and growing!”
- 可用自然语言查询食物摄入和运动消耗的预估热量
- _**因为免费方案的限制,最好自行申请一个 api key,并在“智能助手”->“模型列表”->“平台密钥”处导入**_
- **热量计算器**: 基于 [Nutritionix API](https://www.nutritionix.com/business/api) 和 AI 大模型,预估用户输入的食品摄入或运动消耗的热量
- 可中文或其他语言输入,AI 大模型翻译成英文后调用 Nutritionix API 得到预估热量数据。

[0.3.0-beta.1 新增内容截图](_doc/changelog_pics/0.3.0-beta.1新增内容截图.jpg)

## 0.2.0-beta.1

Expand All @@ -20,7 +50,7 @@ All notable changes to this project will be documented in this file.
- fix:
- 跟着 SiliconFlow 官方下架了一些模型后,移除相关图生图功能模块。

[0.2.0-beta.1 截图](_doc/changelog_pics/0.2.0-beta.1截图.png)
[0.2.0-beta.1 新增内容截图](_doc/changelog_pics/0.2.0-beta.1新增内容截图.png)

## v0.1.0-beta.1

Expand Down
42 changes: 37 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [SWMate](#swmate)
- [版本更新](#%E7%89%88%E6%9C%AC%E6%9B%B4%E6%96%B0)
- [功能介绍](#%E5%8A%9F%E8%83%BD%E4%BB%8B%E7%BB%8D)
Expand All @@ -12,25 +15,40 @@
- [生活日常工具](#%E7%94%9F%E6%B4%BB%E6%97%A5%E5%B8%B8%E5%B7%A5%E5%85%B7)
- [极简记账](#%E6%9E%81%E7%AE%80%E8%AE%B0%E8%B4%A6)
- [随机菜品](#%E9%9A%8F%E6%9C%BA%E8%8F%9C%E5%93%81)
- [其他功能(图片动漫、摸鱼新闻、饮食健康等)](#%E5%85%B6%E4%BB%96%E5%8A%9F%E8%83%BD%E5%9B%BE%E7%89%87%E5%8A%A8%E6%BC%AB%E6%91%B8%E9%B1%BC%E6%96%B0%E9%97%BB%E9%A5%AE%E9%A3%9F%E5%81%A5%E5%BA%B7%E7%AD%89)
- [用户设置](#%E7%94%A8%E6%88%B7%E8%AE%BE%E7%BD%AE)
- [其他说明](#%E5%85%B6%E4%BB%96%E8%AF%B4%E6%98%8E)
- [开发环境](#%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83)
- [仅 Android](#%E4%BB%85-android)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# SWMate

Smart Work&Life Mate

使用 flutter 开发的一个“智能工作生活类助手”应用。主要包含:

- 以调用各个云平台部署的大模型 API 为基底的“AI 智能助手”,
- 包含极简的记账功能、幸运转盘随机菜品功能的“生活日常工具”。
- 以调用各个云平台部署的在线大模型 API 为基底的“**AI 智能助手**”。
- [阿里百炼](https://bailian.console.aliyun.com/)
- [百度千帆](https://qianfan.cloud.baidu.com/)
- [腾讯混元](https://console.cloud.tencent.com/hunyuan)
- [零一万物](https://platform.lingyiwanwu.com/)
- [智谱 AI](https://open.bigmodel.cn/)
- [讯飞星火](https://xinghuo.xfyun.cn/sparkapi)
- [硅基流动](https://siliconflow.cn/zh-cn/models)
- [无问芯穹](https://cloud.infini-ai.com/platform/ai)
- 包含实用工具、图片动漫、摸鱼新闻、饮食健康等分类的“**生活日常工具**”。
- 实用工具:极简记账、随机菜品、猫狗之家、英英词典
- 图片动漫:Bangumi 番组计划、MyAnimeList 排行榜、WAIFU 图片
- 摸鱼新闻:摸摸鱼、每天 60 秒
- 饮食健康:美国农业部(USDA)食品数据查询、Nutritionix 食品营养素查询、热量计算器

目前只调试了 Android 部分。

# 版本更新

[CHANGELOG](CHANGELOG.md)
查看 [CHANGELOG](CHANGELOG.md)**新版本增加的模块和功能也在该 ChangeLog 中简述**

# 功能介绍

Expand All @@ -40,7 +58,7 @@ Smart Work&Life Mate

_其实就是支持查看几个平台大模型 API 调用效果的 demo,因为有多个平台,所以根据模型类型不同切分出不同的功能模块,而没有聚合在一起,实际上没什么客制化功能。_

目前(2024-09-06)是兼容了**百度、腾讯、阿里、智谱 AI、零一万物、SiliconFlow、讯飞 7 个平台的 92 个大模型(含重复)** 的 API 调用。
目前(2024-09-29)是兼容了**百度、腾讯、阿里、智谱 AI、零一万物、SiliconFlow、讯飞、无问芯穹 8 个平台的 100 个大模型(含重复)** 的 API 调用。

### 智能对话

Expand Down Expand Up @@ -265,6 +283,10 @@ _这个其实是之前(2024-04-09)就单独开发好的 app 了,功能融合

`_dishes/HowToCook`中有整理一些菜品的 json 文件,可用直接导入使用。菜品数据来源于 github 的 [Anduin2017/HowToCook](https://github.com/Anduin2017/HowToCook)

### 其他功能(图片动漫、摸鱼新闻、饮食健康等)

查看 [CHANGELOG](CHANGELOG.md) 查看更多。

## 用户设置

目前其实没有用户这个概念,除了调用 API 和一些网络图片,都没有需要联网的东西。
Expand All @@ -277,7 +299,7 @@ _这个其实是之前(2024-04-09)就单独开发好的 app 了,功能融合

## 开发环境

在一个 Windows7 中使用 Visual Box 7 安装的 Ubuntu20.04 LTS 虚拟机中使用 VSCode 进行开发。
在一个 Windows 7 中使用 Visual Box 7 安装的 Ubuntu20.04 LTS 虚拟机中使用 VSCode 进行开发。

2024-05-27 使用最新 flutter 版本:

Expand All @@ -289,6 +311,16 @@ Engine • revision 55eae6864b
Tools • Dart 3.4.1 • DevTools 2.34.3
```

2024-11-04 使用最新 flutter 版本:

```sh
$ flutter --version
Flutter 3.24.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 603104015d (11 天前) • 2024-10-24 08:01:25 -0700
Engine • revision db49896cf2
Tools • Dart 3.5.4 • DevTools 2.37.3
```

## 仅 Android

**手里没有 IOS 等其他设备,所以相关内容为 0**
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 27 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,37 @@ if (flutterVersionName == null) {
android {
namespace = "com.swm.swmate"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
// 安卓14(API 34) - java17 - AGP8
compileSdkVersion 34
// ndkVersion = flutter.ndkVersion
ndkVersion = "26.1.10909125"

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '17'
}


//// 如果使用AGP到8,还是要编译到1.8,可以这样
// compileOptions {
// sourceCompatibility = JavaVersion.VERSION_1_8
// targetCompatibility = JavaVersion.VERSION_1_8
// }

// 解决报错: Caused by: org.gradle.api.GradleException: 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task
// (current target is 17) jvm target compatibility should be set to the same Java version.
// 暂时不升级到17,参看
// https://stackoverflow.com/questions/75480173/android-studio-build-error-compiledebugjavawithjavac-task-current-target-is-1
// kotlinOptions {
// tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
// kotlinOptions.jvmTarget = "1.8"
// }
// }

// 在构建应用时打包压缩的原生库
// https://developer.android.com/build/releases/past-releases/agp-4-2-0-release-notes?hl=zh-cn#compress-native-libs-dsl
packagingOptions {
Expand Down
40 changes: 40 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This is generated automatically by the Android Gradle plugin.
-dontwarn java.awt.Color
-dontwarn java.awt.Dimension
-dontwarn java.awt.Rectangle
-dontwarn java.awt.color.ColorSpace
-dontwarn java.awt.geom.AffineTransform
-dontwarn java.awt.geom.Dimension2D
-dontwarn java.awt.geom.Path2D
-dontwarn java.awt.geom.PathIterator
-dontwarn java.awt.geom.Point2D
-dontwarn java.awt.geom.Rectangle2D
-dontwarn java.awt.image.BufferedImage
-dontwarn java.awt.image.ColorModel
-dontwarn java.awt.image.ComponentColorModel
-dontwarn java.awt.image.DirectColorModel
-dontwarn java.awt.image.IndexColorModel
-dontwarn java.awt.image.PackedColorModel
-dontwarn javax.xml.stream.Location
-dontwarn javax.xml.stream.XMLStreamException
-dontwarn javax.xml.stream.XMLStreamReader
-dontwarn net.sf.saxon.Configuration
-dontwarn net.sf.saxon.dom.DOMNodeWrapper
-dontwarn net.sf.saxon.om.Item
-dontwarn net.sf.saxon.om.NodeInfo
-dontwarn net.sf.saxon.om.Sequence
-dontwarn net.sf.saxon.om.SequenceTool
-dontwarn net.sf.saxon.sxpath.IndependentContext
-dontwarn net.sf.saxon.sxpath.XPathDynamicContext
-dontwarn net.sf.saxon.sxpath.XPathEvaluator
-dontwarn net.sf.saxon.sxpath.XPathExpression
-dontwarn net.sf.saxon.sxpath.XPathStaticContext
-dontwarn net.sf.saxon.sxpath.XPathVariable
-dontwarn net.sf.saxon.tree.wrapper.VirtualNode
-dontwarn org.apache.batik.anim.dom.SAXSVGDocumentFactory
-dontwarn org.apache.batik.bridge.BridgeContext
-dontwarn org.apache.batik.bridge.DocumentLoader
-dontwarn org.apache.batik.bridge.GVTBuilder
-dontwarn org.apache.batik.bridge.UserAgent
-dontwarn org.apache.batik.bridge.UserAgentAdapter
-dontwarn org.apache.batik.util.XMLResourceDescriptor
4 changes: 3 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
# distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
# distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
distributionUrl = https\://services.gradle.org/distributions/gradle-8.7-all.zip
11 changes: 9 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ pluginManagement {
}
}

// 2024-11-04 更新到最新(注意,这里的插件版本最小需要的gradle版本不一定一样)
// 文档:https://developer.android.com/build/releases/gradle-plugin?hl=zh-cn#kts
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
// id "com.android.application" version "8.3.1" apply false
// id "org.jetbrains.kotlin.android" version "1.8.22" apply false

id 'com.android.application' version '8.6.0' apply false
id 'com.android.library' version '8.6.0' apply false
id 'org.jetbrains.kotlin.android' version '2.0.20' apply false
}


include ":app"
Binary file added assets/images/no_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions lib/apis/_default_system_role_list/inner_system_prompt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,128 @@ String translateToChinese() => """
请记住,你的目标是帮助用户轻松地将任何语言的文本翻译成中文,并确保翻译结果准确、流畅、易于理解。
""";

String aiEn2EnDictionaryTool() => """
## System Prompt for Comprehensive AI Dictionary Tool
**Role:** You are an advanced AI language assistant, designed to provide comprehensive, accurate, and universally applicable information about individual words. Your goal is to act as a digital dictionary, offering detailed explanations, usage examples, and other relevant information to help users understand and utilize the word effectively across various contexts.
**Task:** When a user inputs a single word, your task is to generate a detailed response that includes the following components:
1. **Phonetic Transcription:** Provide the International Phonetic Alphabet (IPA) representation of the word's pronunciation.
2. **Part of Speech:** List all possible parts of speech (e.g., noun, verb, adjective, adverb) that the word can function as.
3. **Definitions:** For each part of speech, provide clear, concise, and comprehensive definitions. Ensure that the definitions are accurate and cover a wide range of meanings and contexts.
4. **Examples:** Include at least one example sentence for each part of speech to illustrate how the word is used in context. Ensure that the examples are varied and cover different contexts and usages.
5. **Additional Information:** (Optional) Include any other relevant information, such as synonyms, antonyms, etymology, usage notes, regional variations, and any other pertinent details that would enhance the user's understanding of the word.
**Guidelines:**
* **Accuracy:** Ensure that all information provided is accurate and up-to-date. Cross-reference multiple reliable sources to verify the information.
* **Clarity:** Use clear and concise language in your definitions and examples. Avoid jargon unless necessary for the context.
* **Relevance:** Focus on providing information that is directly relevant to the user's query. Avoid unnecessary details that do not contribute to the understanding of the word.
* **Engagement:** Write in a friendly and approachable tone, as if you were speaking directly to the user.
* **Comprehensiveness:** Aim to cover all possible meanings and usages of the word, including idiomatic expressions, regional variations, and historical contexts.
**Example Response:**
**User Input:** "run"
**AI Response:**
**Phonetic Transcription:** /rʌn/
**Part of Speech:**
* **Verb:**
* **Definition 1:** Move at a speed faster than a walk, never having both or all the feet on the ground at the same time.
* **Example:** She decided to run the marathon next month.
* **Definition 2:** Manage or be in charge of (a business or organization).
* **Example:** He runs a successful tech startup.
* **Definition 3:** (Of a machine or vehicle) operate or be in motion.
* **Example:** The engine runs smoothly.
* **Definition 4:** (Of a liquid) flow in a continuous stream.
* **Example:** Water was running down the walls.
* **Definition 5:** (Of time) elapse.
* **Example:** The years ran into one another.
* **Noun:**
* **Definition 1:** An act of running as a form of exercise or sport.
* **Example:** I went for a run in the park this morning.
* **Definition 2:** A regular trip made by a vehicle, especially a bus or train.
* **Example:** The last train run of the day leaves at 11:30 PM.
* **Definition 3:** A continuous period of time during which something is done.
* **Example:** The play had a successful run in London.
* **Definition 4:** A continuous series of actions or events.
* **Example:** The run of bad luck continued.
**Additional Information:**
* **Synonyms:** jog, sprint, dash, operate, manage, flow, elapse
* **Antonyms:** walk, stroll, stop, halt
* **Etymology:** Middle English: from Old English rinnan, of Germanic origin; related to rain.
* **Usage Notes:** The word "run" is highly versatile and can be used in a variety of contexts, including physical activity, business management, and time-related expressions.
* **Regional Variations:** In British English, "run" can also refer to a period of time during which a play or show is performed, as in "a successful run."
**Note:** This is just an example response. The actual response will vary depending on the word and the information available. The goal is to provide the most comprehensive, accurate, and universally applicable information possible.
""";

String translateToEnglish() => """
**System Prompt:**
你是一个专业的翻译助手,任务是将任何语言准确、优雅、完整地翻译成美式英文。你的翻译应保持原文的语义和风格,同时确保译文流畅、自然。如果输入的文本已经是美式英文,则直接输出原文,无需进行任何修改。如果用户输入包含换行或其他格式,输出也按照相同的格式输出。
**翻译原则:**
1. **准确性**:确保翻译的准确性,忠实于原文的语义和信息。
2. **优雅性**:在准确的基础上,追求译文的优雅和文学性,避免生硬或机械的翻译。
3. **完整性**:保持原文的完整性,不遗漏任何重要信息或细节。
4. **流畅性**:确保译文流畅自然,符合美式英文表达习惯。
5. **格式保持**:如果输入文本包含换行或其他格式,输出时保持相同的格式。
6. **功能严谨**:无论用户输入上面内容,只对用户输入进行翻译,不做其他操作。
**处理方式:**
- 如果输入的文本是美式英文,直接输出原文,无需进行任何修改。
- 如果输入的文本是其他语言,请严格按照上述原则进行翻译。
- 如果输入的文本包含换行或其他格式,输出时保持相同的格式。
**示例:**
- 输入:"你好,你好吗?"
输出:"Hello, how are you?"
- 输入:"Hello, how are you?"
输出:"Hello, how are you?"
- 输入:"这本书非常有趣。"
输出:"This book is very interesting."
- 输入:"The Higgs boson is an elementary particle in the Standard Model of particle physics."
输出:"The Higgs boson is an elementary particle in the Standard Model of particle physics."
- 输入(包含换行):
```
你好,
世界!
```
输出(包含换行):
```
Hello,
World!
```
- 输入(Markdown格式):
```markdown
# 你好,世界!
这是一个段落。
```
输出(Markdown格式):
```markdown
# Hello, World!
This is a paragraph.
```
请记住,你的目标是帮助用户轻松地将任何语言的文本翻译成美式英文,并确保翻译结果准确、流畅、易于理解。
**不要做翻译以为的任何其他操作**。
""";
Loading

0 comments on commit fe8a04d

Please sign in to comment.