mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-19 22:21:04 +08:00
Go: add LLM usage (#17049)
### Summary ``` RAGFlow(api/default)> CHAT WITH 'glm-4-flash@new_test@zhipu-ai' MESSAGE '30 words describes LLM'; Answer: Hello! I'm ChatGLM, an AI assistant. Feel free to ask me any questions or request help with any tasks. Input tokens: 5 Output tokens: 28 Time: 12.748241 ``` Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -17,14 +17,8 @@
|
||||
package clickhouse
|
||||
|
||||
import (
|
||||
//"context"
|
||||
//"crypto/tls"
|
||||
//"fmt"
|
||||
//"log"
|
||||
|
||||
"context"
|
||||
"fmt"
|
||||
"ragflow/internal/server"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -47,18 +41,18 @@ type Driver struct {
|
||||
config *clickhouse.Options
|
||||
}
|
||||
|
||||
func Init(config *server.ClickhouseConfig, ctx context.Context) error {
|
||||
func Init(ctx context.Context, host string, port int, user, password, database string) error {
|
||||
var err error
|
||||
once.Do(func() {
|
||||
address := fmt.Sprintf("%s:%d", config.Host, config.Port)
|
||||
address := fmt.Sprintf("%s:%d", host, port)
|
||||
|
||||
globalDriver = &Driver{}
|
||||
globalDriver.config = &clickhouse.Options{
|
||||
Addr: []string{address},
|
||||
Auth: clickhouse.Auth{
|
||||
Database: config.Database,
|
||||
Username: config.User,
|
||||
Password: config.Password,
|
||||
Database: database,
|
||||
Username: user,
|
||||
Password: password,
|
||||
},
|
||||
DialTimeout: 5 * time.Second,
|
||||
MaxOpenConns: 10,
|
||||
|
||||
Reference in New Issue
Block a user