whyiyhw / chatgpt-wechat

企业微信/微信 安全使用的 ChatGPT 个人助手应用
Apache License 2.0
947 stars 195 forks source link

Gemini pro support #105

Closed ghost closed 9 months ago

ghost commented 9 months ago

Did not know how to switch AI from openAI to Gemini from the configuration below. https://github.com/whyiyhw/chatgpt-wechat/blob/main/doc/config.md

Is there a guide?

whyiyhw commented 9 months ago
ModelProvider:                                      # 服务提供者 可选择 openai 与 gemini  默认为 openai
  Company: "openai"                                 # openai / gemini

change Company to gemini and complement below configure

Gemini:
  Key: "AIzaxxxxx-xxxxx"                            # gemini key
  Temperature: 0.8                                  # 对话的创造性,当其逼近与0时,其响应的结果更加死板,当其趋近于1时,其对话更加符有跳跃与创造力
  Prompt: "xxxx"                                    # model 角色背景
ghost commented 9 months ago

modelprovider放在WeCom下面的?需要pull到最近的代码吗?

whyiyhw commented 9 months ago

我到时候改到上面去。是的,mian 分支就是开发中的版本

ghost commented 9 months ago

Thx.

Gemini有支持自定义的url吗?

ghost commented 9 months ago

我pull了最新的代码,改了下config,报错: root@VM-4-16-ubuntu:~/gemini/chatgpt-wechat/chat# docker logs chat-api

2024/01/15 14:52:45 /build/service/chat/api/internal/svc/servicecontext.go:33 [error] failed to initialize database, got error failed to connect to host=pgvector user=chat database=chat: server error (FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption (SQLSTATE 28000)) panic: failed to connect to host=pgvector user=chat database=chat: server error (FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption (SQLSTATE 28000))

goroutine 1 [running]: chat/service/chat/api/internal/svc.NewServiceContext({{{{0xc0002ed0e0, 0x8}, {{...}, {...}, {...}, {...}, {...}, {...}, 0x0, 0x0, ...}, ...}, ...}, ...}) /build/service/chat/api/internal/svc/servicecontext.go:43 +0x3b6 main.main() /build/service/chat/api/chat.go:49 +0x31b

Config:

Name: chat-api # 项目名称 Host: 0.0.0.0 # 项目监听地址 Port: 8888 # 项目监听端口

PGSql: DataSource: "host=pgvector user=chat password=Chat-gpt~wechat dbname=chat port=5432 sslmode=disable TimeZone=Asia/Shanghai"

RedisCache:

Log: stat: false

WeCom: CorpID: "xxxx" # 企业微信CorpID

ghost commented 9 months ago

root@VM-4-16-ubuntu:~/gemini/chatgpt-wechat/chat# docker logs pgvector

PostgreSQL Database directory appears to contain a database; Skipping initialization

2024-01-15 14:52:41.997 CST [1] LOG: starting PostgreSQL 15.4 (Debian 15.4-2.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-01-15 14:52:41.999 CST [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-01-15 14:52:41.999 CST [1] LOG: listening on IPv6 address "::", port 5432 2024-01-15 14:52:42.009 CST [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-01-15 14:52:42.026 CST [28] LOG: database system was shut down at 2024-01-15 14:22:25 CST 2024-01-15 14:52:42.060 CST [1] LOG: database system is ready to accept connections 2024-01-15 14:52:45.017 CST [32] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:52:52.905 CST [33] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:53:00.884 CST [34] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:53:08.672 CST [35] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:53:16.650 CST [36] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:53:24.426 CST [37] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:53:32.754 CST [38] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:53:44.201 CST [40] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:54:01.997 CST [41] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:54:32.658 CST [42] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:55:28.896 CST [44] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:56:33.991 CST [46] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:57:39.033 CST [48] FATAL: no pg_hba.conf entry for host "172.18.0.2", user "chat", database "chat", no encryption 2024-01-15 14:57:42.125 CST [26] LOG: checkpoint starting: time 2024-01-15 14:57:46.167 CST [26] LOG: checkpoint complete: wrote 43 buffers (0.3%); 0 WAL file(s) added, 0 removed, 0 recycled; write=4.017 s, sync=0.010 s, total=4.042 s; sync files=11, longest=0.005 s, average=0.001 s; distance=252 kB, estimate=252 kB

whyiyhw commented 9 months ago

emmmm 看起来是 db 初始化失败了,导致用户没生成,或者是 在外部网络调用 pgsql 被拒绝了,要不删掉本地数据 chat/build/pgvector/data 重新再 docker compose down && docker compose up -d 启动下试试呢?

ghost commented 9 months ago

按你的方法可以了,但是发消息有报错。我就在企业微信上发了个”你好“:

root@VM-4-16-ubuntu:~/gemini/chatgpt-wechat/chat# docker logs chat-api Starting server at 0.0.0.0:8888... incoming message: RxMessage { FromUserID: "XXX", SendTime: 1705305902000000000, MsgType: "text", MsgID: 7324233080369418025, AgentID: 1000004, Event: "", ChangeType: "", Content: "你好" } 上下文请求信息: collection.Promptdoctor [{user {text/plain doctor}} {model {text/plain 好的,收到!}} {user { }} {assistant { }} {user { }} {assistant { }} {user {text/plain 你好}}] {"@timestamp":"2024-01-15T16:05:02.751+08:00","caller":"response/response.go:63","content":"","level":"info","response":{"code":200,"msg":"成功","data":{"message":"ok"}},"span":"433a27867839e0d0","trace":"1ddbfac6bb9204cba9fbb78a96a7bf07"} {"@timestamp":"2024-01-15T16:05:02.752+08:00","caller":"accesslog/accesslog.go:29","content":"","level":"info","request":{"url":"/api/msg/push","method":"POST","query":"","body":"{\"channel\":\"gemini\",\"msg\":\"你好\",\"user_id\":\"XXX\",\"agent_id\":1000004}","header":{"Accept-Encoding":["gzip"],"Authorization":["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzEyMjU4NDAsImlhdCI6MTcwNTMwNTg0MCwidXNlcklkIjoxfQ.u7m6mWtppQLV1TM5AXA0YdofGjwpRn_l-SevUeoYD6k"],"Content-Length":["76"],"Content-Type":["application/json"],"User-Agent":["Go-http-client/1.1"]},"const":20},"span":"433a27867839e0d0","trace":"1ddbfac6bb9204cba9fbb78a96a7bf07"} {"@timestamp":"2024-01-15T16:05:02.753+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - POST /api/msg/push - 127.0.0.1:46848 - Go-http-client/1.1","duration":"22.5ms","level":"info","span":"433a27867839e0d0","trace":"1ddbfac6bb9204cba9fbb78a96a7bf07"} start: 0 body{"contents":[{"parts":[{"text":"doctor"}],"role":"user"},{"parts":[{"text":"好的,收到!"}],"role":"model"},{"parts":[{"text":"你好"},{"inline_data":{"mime_type":"","data":""}},{"inline_data":{"mime_type":"","data":""}},{"inline_data":{"mime_type":"","data":""}},{"inline_data":{"mime_type":"","data":""}}],"role":"user"}]} gemini stream response:[{ gemini stream response:"error": { gemini stream response:"code": 400, gemini stream response:"message": "Request contains an invalid argument.", gemini stream response:"status": "INVALID_ARGUMENT" gemini stream response:} gemini stream response:} gemini stream response:] {"@timestamp":"2024-01-15T16:05:03.944+08:00","caller":"gemini/chat.go:274","content":"Stream finished","level":"info"} --------接受到数据: s: pk:false 2024/01/15 16:05:03 /build/service/chat/dao/chat.gen.go:227 [10.551ms] [rows:1] INSERT INTO "chat" ("user","message_id","open_kf_id","agent_id","req_content","res_content") VALUES ('XXX','','',1000004,'你好','') RETURNING "id","created_at","updated_at"

whyiyhw commented 9 months ago

clear 重新清理下上下文就可以了

ghost commented 9 months ago

我在微信上执行了#clear,再发了一个“你是谁?”,还是报错呢:

{"@timestamp":"2024-01-15T16:12:33.653+08:00","caller":"accesslog/accesslog.go:29","content":"","level":"info","request":{"url":"/","method":"GET","query":"","body":"","header":{"Accept":["/"],"Accept-Encoding":["gzip"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15"]},"const":-1},"span":"f7f3263b5ffcef8b","trace":"afbe26e820254d5ff877dcb5e5efd796"} {"@timestamp":"2024-01-15T16:12:33.653+08:00","caller":"response/response.go:63","content":"","level":"info","response":{"code":404,"msg":"请求资源不存在","data":{}},"span":"f7f3263b5ffcef8b","trace":"afbe26e820254d5ff877dcb5e5efd796"} {"@timestamp":"2024-01-15T16:12:33.653+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - GET / - 64.62.197.28:22117 - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15","duration":"0.3ms","level":"info","span":"f7f3263b5ffcef8b","trace":"afbe26e820254d5ff877dcb5e5efd796"} {"@timestamp":"2024-01-15T16:12:33.653+08:00","caller":"response/response.go:42","content":"【API-ERR】 : ErrCode:404,ErrMsg:请求资源不存在\n接口不存在\nmain.(NotFoundHandler).ServeHTTP\n\t/build/service/chat/api/chat.go:81\ngithub.com/zeromicro/go-zero/rest/handler.LogHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/loghandler.go:42\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/handler.TraceHandler.func1.1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/tracehandler.go:64\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest.(engine).notFoundHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/engine.go:231\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).handleNotFound\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:95\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).ServeHTTP\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:73\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2938\nnet/http.(conn).serve\n\t/usr/local/go/src/net/http/server.go:2009\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650 ","level":"error","span":"f7f3263b5ffcef8b","trace":"afbe26e820254d5ff877dcb5e5efd796"} {"@timestamp":"2024-01-15T16:12:46.454+08:00","caller":"response/response.go:42","content":"【API-ERR】 : ErrCode:404,ErrMsg:请求资源不存在\n接口不存在\nmain.(NotFoundHandler).ServeHTTP\n\t/build/service/chat/api/chat.go:81\ngithub.com/zeromicro/go-zero/rest/handler.LogHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/loghandler.go:42\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/handler.TraceHandler.func1.1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/tracehandler.go:64\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest.(engine).notFoundHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/engine.go:231\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).handleNotFound\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:95\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).ServeHTTP\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:73\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2938\nnet/http.(conn).serve\n\t/usr/local/go/src/net/http/server.go:2009\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650 ","level":"error","span":"2a74b41f7a4a882a","trace":"76e83f0c97e2c33bc7a4b0a1afa5fc63"} {"@timestamp":"2024-01-15T16:12:46.454+08:00","caller":"accesslog/accesslog.go:29","content":"","level":"info","request":{"url":"/favicon.ico","method":"GET","query":"","body":"","header":{"Accept":["/"],"Accept-Encoding":["gzip"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"]},"const":-1},"span":"2a74b41f7a4a882a","trace":"76e83f0c97e2c33bc7a4b0a1afa5fc63"} {"@timestamp":"2024-01-15T16:12:46.454+08:00","caller":"response/response.go:63","content":"","level":"info","response":{"code":404,"msg":"请求资源不存在","data":{}},"span":"2a74b41f7a4a882a","trace":"76e83f0c97e2c33bc7a4b0a1afa5fc63"} {"@timestamp":"2024-01-15T16:12:46.455+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - GET /favicon.ico - 64.62.197.25:32515 - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36","duration":"0.2ms","level":"info","span":"2a74b41f7a4a882a","trace":"76e83f0c97e2c33bc7a4b0a1afa5fc63"} {"@timestamp":"2024-01-15T16:12:51.672+08:00","caller":"accesslog/accesslog.go:29","content":"","level":"info","request":{"url":"/","method":"GET","query":"format=json","body":"","header":{"User-Agent":["Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"]},"const":-1},"span":"c7b463c7a0df6fdb","trace":"af61beca004c3df9a55bec658f1f9254"} {"@timestamp":"2024-01-15T16:12:51.672+08:00","caller":"response/response.go:63","content":"","level":"info","response":{"code":404,"msg":"请求资源不存在","data":{}},"span":"c7b463c7a0df6fdb","trace":"af61beca004c3df9a55bec658f1f9254"} {"@timestamp":"2024-01-15T16:12:51.672+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - GET http://api.ipify.org/?format=json - 64.62.197.24:17853 - Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0","duration":"0.2ms","level":"info","span":"c7b463c7a0df6fdb","trace":"af61beca004c3df9a55bec658f1f9254"} {"@timestamp":"2024-01-15T16:12:51.672+08:00","caller":"response/response.go:42","content":"【API-ERR】 : ErrCode:404,ErrMsg:请求资源不存在\n接口不存在\nmain.(NotFoundHandler).ServeHTTP\n\t/build/service/chat/api/chat.go:81\ngithub.com/zeromicro/go-zero/rest/handler.LogHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/loghandler.go:42\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/handler.TraceHandler.func1.1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/tracehandler.go:64\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest.(engine).notFoundHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/engine.go:231\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).handleNotFound\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:95\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).ServeHTTP\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:73\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2938\nnet/http.(conn).serve\n\t/usr/local/go/src/net/http/server.go:2009\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650 ","level":"error","span":"c7b463c7a0df6fdb","trace":"af61beca004c3df9a55bec658f1f9254"} {"@timestamp":"2024-01-15T16:12:58.813+08:00","caller":"response/response.go:42","content":"【API-ERR】 : ErrCode:404,ErrMsg:请求资源不存在\n接口不存在\nmain.(NotFoundHandler).ServeHTTP\n\t/build/service/chat/api/chat.go:81\ngithub.com/zeromicro/go-zero/rest/handler.LogHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/loghandler.go:42\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/handler.TraceHandler.func1.1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/tracehandler.go:64\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest.(engine).notFoundHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/engine.go:231\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).handleNotFound\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:95\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).ServeHTTP\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:73\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2938\nnet/http.(conn).serve\n\t/usr/local/go/src/net/http/server.go:2009\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650 ","level":"error","span":"de9e2c14272effe6","trace":"0cdd4a89d75bd2bac17e6ab3cfada9c6"} {"@timestamp":"2024-01-15T16:12:58.813+08:00","caller":"accesslog/accesslog.go:29","content":"","level":"info","request":{"url":"","method":"CONNECT","query":"","body":"","header":{"Cache-Control":["no-cache"],"Connection":["Keep-Alive"],"Pragma":["no-cache"],"Proxy-Connection":["Keep-Alive"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"]},"const":-1},"span":"de9e2c14272effe6","trace":"0cdd4a89d75bd2bac17e6ab3cfada9c6"} {"@timestamp":"2024-01-15T16:12:58.813+08:00","caller":"response/response.go:63","content":"","level":"info","response":{"code":404,"msg":"请求资源不存在","data":{}},"span":"de9e2c14272effe6","trace":"0cdd4a89d75bd2bac17e6ab3cfada9c6"} {"@timestamp":"2024-01-15T16:12:58.814+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - CONNECT www.shadowserver.org:443 - 64.62.197.21:47405 - Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0","duration":"0.2ms","level":"info","span":"de9e2c14272effe6","trace":"0cdd4a89d75bd2bac17e6ab3cfada9c6"} {"@timestamp":"2024-01-15T16:53:11.377+08:00","caller":"accesslog/accesslog.go:29","content":"","level":"info","request":{"url":"/","method":"GET","query":"","body":"","header":{"Accept":["/"],"User-Agent":["Expanse, a Palo Alto Networks company, searches across the global IPv4 space multiple times per day to identify customers\u0026#39; presences on the Internet. If you would like to be excluded from our scans, please send IP addresses/domains to: scaninfo@paloaltonetworks.com"]},"const":-1},"span":"71aee5a484d96603","trace":"b4a43eed9523513c047be09983dc47b3"} {"@timestamp":"2024-01-15T16:53:11.377+08:00","caller":"response/response.go:63","content":"","level":"info","response":{"code":404,"msg":"请求资源不存在","data":{}},"span":"71aee5a484d96603","trace":"b4a43eed9523513c047be09983dc47b3"} {"@timestamp":"2024-01-15T16:53:11.377+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - GET / - 205.210.31.241:56712 - Expanse, a Palo Alto Networks company, searches across the global IPv4 space multiple times per day to identify customers\u0026#39; presences on the Internet. If you would like to be excluded from our scans, please send IP addresses/domains to: scaninfo@paloaltonetworks.com","duration":"0.3ms","level":"info","span":"71aee5a484d96603","trace":"b4a43eed9523513c047be09983dc47b3"} {"@timestamp":"2024-01-15T16:53:11.377+08:00","caller":"response/response.go:42","content":"【API-ERR】 : ErrCode:404,ErrMsg:请求资源不存在\n接口不存在\nmain.(NotFoundHandler).ServeHTTP\n\t/build/service/chat/api/chat.go:81\ngithub.com/zeromicro/go-zero/rest/handler.LogHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/loghandler.go:42\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/handler.TraceHandler.func1.1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/handler/tracehandler.go:64\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest.(engine).notFoundHandler.func1\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/engine.go:231\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2136\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).handleNotFound\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:95\ngithub.com/zeromicro/go-zero/rest/router.(patRouter).ServeHTTP\n\t/go/pkg/mod/github.com/zeromicro/go-zero@v1.6.1/rest/router/patrouter.go:73\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2938\nnet/http.(*conn).serve\n\t/usr/local/go/src/net/http/server.go:2009\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1650 ","level":"error","span":"71aee5a484d96603","trace":"b4a43eed9523513c047be09983dc47b3"} incoming message: RxMessage { FromUserID: "XXX", SendTime: 1705309353000000000, MsgType: "text", MsgID: 7324247901988682025, AgentID: 1000004, Event: "", ChangeType: "", Content: "#clear" } {"@timestamp":"2024-01-15T17:02:33.628+08:00","caller":"response/response.go:63","content":"","level":"info","response":{"code":200,"msg":"成功","data":{"message":"ok"}},"span":"e78378d7b978fc88","trace":"28de3dd11090dbddcb643dd5f6bef677"} {"@timestamp":"2024-01-15T17:02:33.628+08:00","caller":"accesslog/accesslog.go:29","content":"","level":"info","request":{"url":"/api/msg/push","method":"POST","query":"","body":"{\"channel\":\"gemini\",\"msg\":\"#clear\",\"user_id\":\"XXX\",\"agent_id\":1000004}","header":{"Accept-Encoding":["gzip"],"Authorization":["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzEyMjU4NDAsImlhdCI6MTcwNTMwNTg0MCwidXNlcklkIjoxfQ.u7m6mWtppQLV1TM5AXA0YdofGjwpRn_l-SevUeoYD6k"],"Content-Length":["76"],"Content-Type":["application/json"],"User-Agent":["Go-http-client/1.1"]},"const":6},"span":"e78378d7b978fc88","trace":"28de3dd11090dbddcb643dd5f6bef677"} {"@timestamp":"2024-01-15T17:02:33.628+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - POST /api/msg/push - 127.0.0.1:51516 - Go-http-client/1.1","duration":"6.3ms","level":"info","span":"e78378d7b978fc88","trace":"28de3dd11090dbddcb643dd5f6bef677"} incoming message: RxMessage { FromUserID: "XXX", SendTime: 1705309362000000000, MsgType: "text", MsgID: 7324247942792590121, AgentID: 1000004, Event: "", ChangeType: "", Content: "你是谁?" } 上下文请求信息: collection.Promptdoctor [{user {text/plain doctor}} {model {text/plain 好的,收到!}} {user {text/plain 你是谁?}}] {"@timestamp":"2024-01-15T17:02:42.906+08:00","caller":"response/response.go:63","content":"","level":"info","response":{"code":200,"msg":"成功","data":{"message":"ok"}},"span":"b652a08ba2c3fe14","trace":"94af1789b82e2bfd05fed3abc370f837"} {"@timestamp":"2024-01-15T17:02:42.906+08:00","caller":"accesslog/accesslog.go:29","content":"","level":"info","request":{"url":"/api/msg/push","method":"POST","query":"","body":"{\"channel\":\"gemini\",\"msg\":\"你是谁?\",\"user_id\":\"XXX\",\"agent_id\":1000004}","header":{"Accept-Encoding":["gzip"],"Authorization":["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzEyMjU4NDAsImlhdCI6MTcwNTMwNTg0MCwidXNlcklkIjoxfQ.u7m6mWtppQLV1TM5AXA0YdofGjwpRn_l-SevUeoYD6k"],"Content-Length":["82"],"Content-Type":["application/json"],"User-Agent":["Go-http-client/1.1"]},"const":3},"span":"b652a08ba2c3fe14","trace":"94af1789b82e2bfd05fed3abc370f837"} {"@timestamp":"2024-01-15T17:02:42.906+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - POST /api/msg/push - 127.0.0.1:50322 - Go-http-client/1.1","duration":"3.8ms","level":"info","span":"b652a08ba2c3fe14","trace":"94af1789b82e2bfd05fed3abc370f837"} start: 0 body{"contents":[{"parts":[{"text":"doctor"}],"role":"user"},{"parts":[{"text":"好的,收到!"}],"role":"model"},{"parts":[{"text":"你是谁?"}],"role":"user"}]} gemini stream response:[{ gemini stream response:"error": { gemini stream response:"code": 400, gemini stream response:"message": "User location is not supported for the API use.", gemini stream response:"status": "FAILED_PRECONDITION" gemini stream response:} gemini stream response:} gemini stream response:] {"@timestamp":"2024-01-15T17:02:43.975+08:00","caller":"gemini/chat.go:274","content":"Stream finished","level":"info"} --------接受到数据: s: pk:false 2024/01/15 17:02:43 /build/service/chat/dao/chat.gen.go:227

whyiyhw commented 9 months ago

User location is not supported for the API use

emmmm , 你不会用的香港的机器访问的吧 , 我还是第一次见,能访问 api , google 主动拒绝的

ghost commented 9 months ago

哦哦,这样啊。我去美国服务器上试试。 能不能配置gemini URL嘛? 我之前用这个项目https://github.com/babaohuang/GeminiProChat 做了个vercel代理。

ghost commented 9 months ago

捕获

希望可以配置GEMINI BASE URL。谢谢啦。

或者用Socks5 proxy,Config里是OpenAI一样的用法吗?

Gemini:
  Key: "AIxxxxx"                            # gemini key
  Temperature: 0.8                                  # 对话的创造性,当其逼近与0时,其响应的结果更加死板,当其趋近于1时,其对话更加符有跳跃与创造力
  Prompt: "doctor"
  Proxy: "http://127.0.0.1:1080"                    # (可选)http/socks5 代理(可选)
whyiyhw commented 9 months ago

已补充自定义 Gemini host, proxy 是公用配置,在每个模型下可以自行开关

ghost commented 9 months ago

谢谢。我放在usa server上就可以了。 我想问一下,Gemini的prompt怎么写?可以写中文吗?

whyiyhw commented 9 months ago

中文是没问题的,但是比起 openai 的 prompt , 指令性的内容,它是很难做到完全遵循,目前我的做法 还是 #角色 ##技能 ##限制 .... 这种方式来书写,不过效果没那么好, 完全的文本描述跟大量的例子提示会更好一点,反正它上下文窗口大

ghost commented 9 months ago

谢谢这么好的项目!感谢