Commit 8c52cd01 authored by Wade's avatar Wade

kc

parent 2337a5b9
This diff is collapsed.
...@@ -59,39 +59,6 @@ type simpleQaPromptInput struct { ...@@ -59,39 +59,6 @@ type simpleQaPromptInput struct {
Summary string `json:"summary"` Summary string `json:"summary"`
} }
// const simpleQaPromptTemplate = `
// You're a helpful agent that answers the user's questions with a tone and style shaped by the specified personality.
// Here is the user's query: {{query}}
// Here is the context you should use: {{context}} from Milvus
// Graph context: {{graph}}
// Previous conversation summary: {{summary}}
// Personality to adopt: {{personality}}
// Please provide a response that aligns with the given personality while leveraging the provided context, graph, and conversation summary.
// `
const simpleQaPromptTemplate = `
You're a helpful agent that answers the user's questions based on the provided context.
Here is the user's query: {{query}}
Here is the context you should use: {{context}} from Milvus
Graph context: {{graph}}
Previous conversation summary: {{summary}}
Instructions:
- If the query is related to a character's personality, adopt the tone and style specified in the Personality context, and generate a response using the Milvus and Graph contexts to inform the personality-driven content.
- For all other queries, provide a clear and accurate response using the Milvus and Graph contexts, without emphasizing the Personality context.
- Ensure responses leverage the Previous conversation summary when relevant.
`
func main() { func main() {
// Define command-line flags with hardcoded values as defaults // Define command-line flags with hardcoded values as defaults
...@@ -163,8 +130,6 @@ func main() { ...@@ -163,8 +130,6 @@ func main() {
log.Fatal().Msgf("graphrag.DefineIndexerAndRetriever failed: %v", err) log.Fatal().Msgf("graphrag.DefineIndexerAndRetriever failed: %v", err)
} }
DefineDocumentFlow(g, indexer) DefineDocumentFlow(g, indexer)
DefineGraphFlow(g, graphIndexer) DefineGraphFlow(g, graphIndexer)
DefineModelsFlow(g) DefineModelsFlow(g)
...@@ -179,8 +144,8 @@ func main() { ...@@ -179,8 +144,8 @@ func main() {
} }
log.Info().Msg("KnowledgeClient initialized successfully") log.Info().Msg("KnowledgeClient initialized successfully")
DefineChatFlow(g, retriever, graphRetriever, *pgConnString,kc) DefineChatFlow(g, retriever, graphRetriever, *pgConnString, kc)
DefineSplitDocFlow(g,kc) DefineSplitDocFlow(g, kc)
// 配置限速器:每秒 10 次请求,突发容量 20,最大并发 5 // 配置限速器:每秒 10 次请求,突发容量 20,最大并发 5
rl := NewRateLimiter(10, 20, 5) rl := NewRateLimiter(10, 20, 5)
...@@ -207,4 +172,3 @@ func main() { ...@@ -207,4 +172,3 @@ func main() {
log.Fatal().Msgf("Server failed: %v", err) log.Fatal().Msgf("Server failed: %v", err)
} }
} }
package main
import (
"fmt"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
lkeap "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/lkeap/v20240522"
)
func main() {
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性
// 以下代码示例仅供参考,建议采用更安全的方式来使用密钥
// 请参见:https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
credential := common.NewCredential(
"AKID64oLfmfLtESUJ6i8LPSM4gCVbiniQuBF",
"rX2JMBnBMJ2YqulOo37xa5OUMSN4Xnpd",
)
// 使用临时密钥示例
// credential := common.NewTokenCredential("SecretId", "SecretKey", "Token")
// 实例化一个client选项,可选的,没有特殊需求可以跳过
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "lkeap.tencentcloudapi.com"
// 实例化要请求产品的client对象,clientProfile是可选的
client, _ := lkeap.NewClient(credential, "ap-guangzhou", cpf)
// 实例化一个请求对象,每个接口都会对应一个request对象
request := lkeap.NewReconstructDocumentSSERequest()
request.FileType = common.StringPtr("TXT")
request.FileBase64 = common.StringPtr("data:application/octet-stream;base64,4oCc6L+Z5bCx6LGh6Iqx5LiA5qC344CC5aaC5p6c5L2g54ix5LiK5LqG5LiA5py155Sf6ZW/IArlnKjkuIDpopfmmJ/mmJ/kuIrnmoToirHvvIzpgqPkuYjlpJzpl7TvvIwgCuS9oOeci+edgOWkqeepuuWwseaEn+WIsOeUnOicnOaEiSAK5b+r44CC5omA5pyJ55qE5pif5pif5LiK6YO9CuWlveixoeW8gOedgOiKseOAguKAnQ==")
// 返回的resp是一个ReconstructDocumentSSEResponse的实例,与请求对象对应
response, err := client.ReconstructDocumentSSE(request)
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
if err != nil {
panic(err)
}
// 输出json格式的字符串回包
if response.Response != nil {
// 非流式响应
fmt.Println(response.ToJsonString())
} else {
// 流式响应
for event := range response.Events {
fmt.Println(string(event.Data))
}
}
}
\ No newline at end of file
This diff is collapsed.
...@@ -113,8 +113,6 @@ func TestKnowledgeClient_QueryRewrite(t *testing.T) { ...@@ -113,8 +113,6 @@ func TestKnowledgeClient_QueryRewrite(t *testing.T) {
} }
} }
// func TestKnowledgeClient_ReconstructDocumentSSE(t *testing.T) { // func TestKnowledgeClient_ReconstructDocumentSSE(t *testing.T) {
// // Warning: Do not hardcode credentials in production code. Use environment variables or a secure vault. // // Warning: Do not hardcode credentials in production code. Use environment variables or a secure vault.
// os.Setenv("TENCENTCLOUD_SECRET_ID", "AKID64oLfmfLtESUJ6i8LPSM4gCVbiniQuBF") // os.Setenv("TENCENTCLOUD_SECRET_ID", "AKID64oLfmfLtESUJ6i8LPSM4gCVbiniQuBF")
...@@ -208,4 +206,4 @@ func TestKnowledgeClient_QueryRewrite(t *testing.T) { ...@@ -208,4 +206,4 @@ func TestKnowledgeClient_QueryRewrite(t *testing.T) {
// Msg("Document reconstruction successful") // Msg("Document reconstruction successful")
// }) // })
// } // }
// } // }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment