Giter Club home page Giter Club logo

aidea-server's Introduction

AIdea 服务端 - AI 聊天、协作、图像生成

mylxsw%2Faidea-server | Trendshift

一款集成了主流大语言模型以及绘图模型的 APP 服务端,使用 Golang 开发,代码完全开源,支持以下功能:

  • 支持 OpenAI 的 GPT-3.5,GPT-4 大语言模型
  • 支持 Anthropic 的 Claude instant,Claude 2.1 大语言模型
  • 支持 Google 的 Gemini Pro 以及视觉大语言模型
  • 支持国产模型:通义千问,文心一言,讯飞星火,商汤日日新,腾讯混元,百川53B,360智脑,天工,智谱,月之暗面等
  • 支持开源大模型:Yi 34B,Llama2,ChatGLM2,AquilaChat 7B,Bloomz 7B,轩辕 70B,ChatLaw,Mixtral 等,后续还将开放更多
  • 支持文生图、图生图、超分辨率、黑白图片上色、艺术字、艺术二维码等功能,支持 SDXL 1.0、Dall·E 3 等

image

下载体验地址:

https://aidea.aicode.cc

开源代码:

私有化部署

如果你不想使用托管的云服务,可以自己部署服务端,部署请看这里

不想自己折腾,可以找我来帮你部署,详情参考 服务器代部署说明

技术交流

  • 微信技术交流群:

    如果无法加入,请添加微信号 x-prometheus 为好友,拉你进群。

  • 微信公众号

  • 电报群:点此加入

关于代码

目前代码注释、技术文档还比较少,后续有时间会进行补充,敬请见谅。另外以下几点请大家注意,以免造成困扰:

  • 代码中 Room顾问团 均代表 数字人,因项目经过多次改版和迭代,经历了 房间 -> 顾问团 -> 数字人 的名称调整
  • 代码中 v1 版本的 创作岛 与 v2 版本截然不同,其中 v1 版本服务于 App 1.0.1 及之前版本,从 1.0.2 开始,这部分不再使用,所以就有了 v2 版本

项目所用的框架

  • Glacier Framework: 自研的一款支持依赖注入的模块化的应用开发框架,它以 go-ioc 依赖注入容器核心,为 Go 应用开发解决了依赖传递和模块化的问题
  • Eloquent ORM 自研的一款基于代码生成的数据库 ORM 框架,它的设计灵感来源于著名的 PHP 开发框架 Laravel,支持 MySQL 等数据库

代码结构如下

目录 说明
api OpenAI兼容的 API,这里的接口可供第三方支持 OpenAI API 协议的软件直接使用
server 为 AIdea 客户端软件提供的的 API 接口
config 配置定义、管理
migrate 数据库迁移文件,SQL 文件
cmd 程序入口
pkg 对外公开的包,其它项目可以直接引用
⌞ ai 不同厂商的 AI 模型接口实现
⌞ ai/chat 聊天模型抽象接口,所有聊天模型都在这里封装为兼容 OpenAI Chat Stream 协议的实现
⌞ aliyun 阿里云短信、内容安全服务实现
⌞ dingding 钉钉通知机器人
⌞ misc 部分助手函数
⌞ jobs 定时任务,用户每日智慧果消耗额度统计等
⌞ mail 邮件发送
⌞ proxy Socks5 代理实现
⌞ rate 流控实现
⌞ redis Redis 实例
⌞ repo 数据模型层,封装了对数据库的操作
⌞ repo/model 数据模型定义,使用了 mylxsw/eloquent 来创建数据模型
⌞ service Service 层,部分不适合放在 Controller 和 Repo 层的代码,在这里进行封装
⌞ sms 统一的短信服务封装,对上层业务屏蔽了底层的短信服务商实现
⌞ tencent 腾讯语音转文本、短信服务实现
⌞ token JWT Token
⌞ uploader 基于七牛云存储实现的文件上传下载
⌞ voice 基于七牛云的文本转语音实现,暂时未启用
⌞ youdao 有道翻译服务 API 实现
internal 内部包,只有本项目可用
⌞ queue 任务队列实现,所有异步处理的任务都在这里定义
⌞ queue/consumer 任务队列消费者
⌞ payment 在线支付服务实现,如支付宝,Apple
⌞ coins 服务定价、收费策略
config.yaml 配置文件示例
coins-table.yaml 价格表配置示例
nginx.conf Nginx 配置示例
systemd.service Systemd 服务配置示例

项目编译:

go build -o build/debug/aidea-server cmd/main.go

APP 预览图

亮色系

image

暗色系

image

Star History

Star History Chart

License

MIT

Copyright (c) 2023, mylxsw

aidea-server's People

Contributors

alcoholtobaccocode avatar bitqiu avatar happyue avatar huangxi1020 avatar llgoer avatar mylxsw avatar wuxingzhong avatar xixingya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aidea-server's Issues

默认未设置百度ai的key,服务启动后,系统会初始化调用刷新百度ai token的接口并报错

默认未设置百度ai的key,服务启动后,系统会初始化调用刷新百度ai token的接口并报错
日志里的报错内容如下

{"module":"main","level_name":"ERROR","level":4,"context":{"#package":"github.com/mylxsw/aidea-server/internal/ai/baidu","#file":"D:/go/aidea-server/internal/ai/baidu/badiu.go","#line":32},"message":"refresh baidu ai access token failed: refresh access token failed, status code: 400","datetime":"2023-09-18T08:30:46+08:00"}

绘图里面分享报错

resolve dependency error: args not instanced: not found in container: key=*auth.UserOptional not found, may be you want auth.UserOptional

编译文件报错 cannot load embed: malformed module path "embed": missing dot in first path element

master 分支执行 go build -o build/debug/aidea-server cmd/main.go 报错:

build command-line-arguments: cannot load embed: malformed module path "embed": missing dot in first path element

执行 go mod tidy,报错如下:

github.com/mylxsw/aidea-server/internal/ai/baidu imports
        gopkg.in/resty.v1 imports
        golang.org/x/net/publicsuffix imports
        embed: malformed module path "embed": missing dot in first path element
github.com/mylxsw/aidea-server/cmd imports
        github.com/mylxsw/glacier/starter/app imports
        github.com/urfave/cli/v2/altsrc imports
        github.com/BurntSushi/toml imports
        io/fs: malformed module path "io/fs": missing dot in first path element
github.com/mylxsw/aidea-server/cmd imports
        github.com/mylxsw/glacier/starter/app imports
        github.com/urfave/cli/v2/altsrc imports
        github.com/BurntSushi/toml tested by
        github.com/BurntSushi/toml.test imports
        testing/fstest: malformed module path "testing/fstest": missing dot in first path element

部分接口存在跨域错误

之前所有的接口均会报跨域错误,研究了下框架的问题,新增了代码mw.CORS("*"),(加完了发现代码里面本身就是解决跨域的地方,即第二个红框圈出来的地方),注册阶段的跨域错误解决了,但是需要登录的接口仍然存在跨域错误。
image

image

服务端运行一段时间后,登录验证码就发送不了

日志如下

{"module":"main","level_name":"DEBUG","level":8,"context":{},"message":"Start processing "sms:verify_code:send"","datetime":"2024-07-10T06:58:54+08:00"}
{"module":"main","level_name":"DEBUG","level":8,"context":{},"message":"send sms to 13454310***, verify code 987891","datetime":"2024-07-10T06:58:54+08:00"}
{"module":"main","level_name":"ERROR","level":4,"context":{"@":{},"#file":"G:/dev_root/aidea-server/internal/queue/sms.go","#line":64,"#package":"github.com/mylxsw/aidea-server/internal/queue"},"message":"panic: runtime error: invalid memory address or nil pointer dereference","datetime":"2024-07-10T06:58:54+08:00"}
{"module":"main","level_name":"WARNING","level":5,"context":{},"message":"task process failed: "sms:verify_code:send", runtime error: invalid memory address or nil pointer dereference","datetime":"2024-07-10T06:58:54+08:00"}
{"module":"main","level_name":"WARNING","level":5,"context":{},"message":"[queue] Retry exhausted for task id=88e97a8a-7d6a-47f9-a422-13a052e9cf84","datetime":"2024-07-10T06:58:54+08:00"}

redis记录
IMG_20240710_074840

图片转视频功能报文件不存在错误

BuildImageToVideoCompletionHandler 函数中,
targetImage, err := uploader.DownloadRemoteFile(ctx, payload.Image)
if err != nil {
log.WithFields(log.Fields{"payload": payload}).Errorf("download remote file failed: %s", err)
panic(err)
}
报错,文件不存在。
查看七牛云,有原始文件,没有resize之后的tagetimage, ImageToVideo函数中resize之后,有上传七牛吗?

讯飞星火一直提示hmac报错?

你好,使用一下你的写的这个chatgpt认为挺好的,谢谢分享出来,昨天都搭建好了,就是在讯飞星火一直提示hmac报错?相关接口apikey都成功申请,并且在他们官方测试的代码都可以使用。就是在我们这个代码不能正常使用为什么。

阿里云的短信通道不好设置验证码的模板ID

我设置的aliyun 作为单独的短信发送通道
失败提示
{"module":"main","level_name":"ERROR","level":4,"context":{"#file":"D:/go/aidea-server/internal/queue/consumer/provider.go","#line":61,"#package":"github.com/mylxsw/aidea-server/internal/queue/consumer"},"message":"Error processing "sms:verify_code:send": isv.SMS_TEMPLATE_ILLEGAL: 该账号下找不到对应模板","datetime":"2023-09-18T09:52:56+08:00"}

但是前端还是会收到提示 短信发送成功

本地客户端一直连不上本地启动的服务端

服务端成功启动
{"module":"main","level_name":"INFO","level":7,"context":{},"message":"服务启动成功,监听地址为 :8080","datetime":"2024-03-02T21:06:51+09:00"}
客户端也配置好了服务器地址
/// 默认 API 服务器地址
/// 注意:当你使用自己的服务器时,请修改该地址为你自己的服务器地址
//const defaultAPIServerURL = 'https://ai-api.aicode.cc';
const defaultAPIServerURL = 'http://127.0.0.1:8080';

/// API 服务器地址
String get apiServerURL {
var url = const String.fromEnvironment(
'API_SERVER_URL',
defaultValue: defaultAPIServerURL,
);

但是客户端的请求一直连不上服务器,客户端报错信息如下图:
client

图生图运行之后报错

图生图运行之后,七牛回调接口报"token":"","err_code":401,"error":"auth failed: invalid auth type"

make build-release出错

项目根目录下执行 make build-release

错误信息:
pkg/misc/misc.go:305:156: cannot use 9999999999 (untyped int constant) as int value in argument to rand.Intn (overflows)

修改:
Line305: rand.Intn(9999999999) -> rand.Int63n(9999999999)

另外在mac下make build 编译成功,但是在ubuntu下编译失败,错误信息:
~/aidea-server# make build
go build -race -ldflags "-s -w -X main.Version=202401171548 -X main.GitCommit=3a4805df090e055c55703f27bd4d34f802846b62 -X main.DEBUG=true" -o build/debug/aidea-server cmd/main.go
build command-line-arguments: cannot load embed: malformed module path "embed": missing dot in first path element
make: *** [Makefile:7: build] Error 1

go开发入门新手,不知道这个怎么解决?
谢谢!

支持gpt4all文件解析模型

可以支持gpt4all模型吗?可以加入文件上传分析模型这个现在是很多同类软件的主流。另外那个模型是否可以在管理员客户端设置隐藏或者是显示呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.