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:
Jin Hai
2026-07-17 21:28:43 +08:00
committed by GitHub
parent c420de0dc5
commit 8ebdc02cf6
7 changed files with 78 additions and 47 deletions

View File

@@ -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,