Skip to content

Commit

Permalink
Merge pull request #255 from tigergraph/fix-alias-ecc
Browse files Browse the repository at this point in the history
Fix alias in ecc
  • Loading branch information
billshitg authored Aug 2, 2024
2 parents 9b920dc + 27c6b61 commit c9a6cdd
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion chat-history/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type TgDbConfig struct {
Username string `json:"username"`
Password string `json:"password"`
GsPort string `json:"gsPort"`
TgCloud bool `json:"tgCloud"`
// GetToken string `json:"getToken"`
// DefaultTimeout string `json:"default_timeout"`
// DefaultMemThreshold string `json:"default_mem_threshold"`
Expand Down
6 changes: 2 additions & 4 deletions chat-history/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ func TestLoadConfig(t *testing.T) {
}

if cfg.TgDbConfig.Hostname != "https://tg-0cdef603-3760-41c3-af6f-41e95afc40de.us-east-1.i.tgcloud.io" ||
cfg.TgDbConfig.GsPort != "14240" ||
cfg.TgDbConfig.TgCloud != true {
cfg.TgDbConfig.GsPort != "14240" {
t.Fatalf("TigerGraph config is wrong, %v", cfg.TgDbConfig)
}
}
Expand Down Expand Up @@ -54,8 +53,7 @@ func setup(t *testing.T) (string, string) {
"hostname": "https://tg-0cdef603-3760-41c3-af6f-41e95afc40de.us-east-1.i.tgcloud.io",
"gsPort": "14240",
"username": "supportai",
"password": "supportai",
"tgCloud": true
"password": "supportai"
}`
if err := os.WriteFile(tgConfigPath, []byte(tgConfigData), 0644); err != nil {
t.Fatal("error setting up tg_config.json")
Expand Down
2 changes: 1 addition & 1 deletion chat-history/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
router.HandleFunc("GET /user/{userId}", routes.GetUserConversations)
router.HandleFunc("GET /conversation/{conversationId}", routes.GetConversation)
router.HandleFunc("POST /conversation", routes.UpdateConversation)
router.HandleFunc("GET /get_feedback", routes.GetFeedback(cfg.TgDbConfig.Hostname, cfg.TgDbConfig.GsPort, cfg.ChatDbConfig.ConversationAccessRoles, cfg.TgDbConfig.TgCloud))
router.HandleFunc("GET /get_feedback", routes.GetFeedback(cfg.TgDbConfig.Hostname, cfg.TgDbConfig.GsPort, cfg.ChatDbConfig.ConversationAccessRoles))

// create server with middleware
dev := strings.ToLower(os.Getenv("DEV")) == "true"
Expand Down
7 changes: 4 additions & 3 deletions chat-history/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ func auth(userId string, r *http.Request) (string, int, []byte, bool) {
}

// executeGSQL sends a GSQL query to TigerGraph with basic authentication and returns the response
func executeGSQL(hostname, username, password, query, gsPort string, tgcloud bool) (string, error) {
func executeGSQL(hostname, username, password, query, gsPort string) (string, error) {
var requestURL string
tgcloud := strings.Contains(hostname, "tgcloud")
// Construct the URL for the GSQL query endpoint
if tgcloud {
requestURL = fmt.Sprintf("%s:443/gsqlserver/gsql/file", hostname)
Expand Down Expand Up @@ -235,7 +236,7 @@ func parseUserRoles(userInfo string, userName string) []string {

// GetFeedback retrieves feedback data for conversations
// "Get /get_feedback"
func GetFeedback(hostname, gsPort string, conversationAccessRoles []string, tgCloud bool) http.HandlerFunc {
func GetFeedback(hostname, gsPort string, conversationAccessRoles []string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
usr, pass, ok := r.BasicAuth()
if !ok {
Expand All @@ -246,7 +247,7 @@ func GetFeedback(hostname, gsPort string, conversationAccessRoles []string, tgCl
}

// Verify if the user has the required role
userInfo, err := executeGSQL(hostname, usr, pass, "SHOW USER", gsPort, tgCloud)
userInfo, err := executeGSQL(hostname, usr, pass, "SHOW USER", gsPort)
if err != nil {
reason := []byte(`{"reason":"failed to retrieve feedback data"}`)
w.Header().Add("Content-Type", "application/json")
Expand Down
4 changes: 2 additions & 2 deletions chat-history/routes/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func TestExecuteGSQL(t *testing.T) {
}
query := "SHOW USER"

response, err := executeGSQL(cfg.TgDbConfig.Hostname, cfg.TgDbConfig.Username, cfg.TgDbConfig.Password, query, cfg.TgDbConfig.GsPort, cfg.TgDbConfig.TgCloud)
response, err := executeGSQL(cfg.TgDbConfig.Hostname, cfg.TgDbConfig.Username, cfg.TgDbConfig.Password, query, cfg.TgDbConfig.GsPort)
if err != nil {
t.Fatalf("Failed to execute GSQL query: %v", err)
}
Expand Down Expand Up @@ -518,7 +518,7 @@ func TestGetFeedback(t *testing.T) {

// Record the response
rr := httptest.NewRecorder()
handler := http.HandlerFunc(GetFeedback(cfg.TgDbConfig.Hostname, cfg.TgDbConfig.GsPort, cfg.ChatDbConfig.ConversationAccessRoles, cfg.TgDbConfig.TgCloud))
handler := http.HandlerFunc(GetFeedback(cfg.TgDbConfig.Hostname, cfg.TgDbConfig.GsPort, cfg.ChatDbConfig.ConversationAccessRoles))

// Serve the request
handler.ServeHTTP(rr, req)
Expand Down
2 changes: 1 addition & 1 deletion copilot/app/routers/supportai.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def ecc(
from httpx import get as http_get

ecc = (
db_config.get("ecc", "http://localhost:8001")
db_config.get("ecc", "http://eventual-consistency-service:8001")
+ f"/{graphname}/consistency_status"
)
LogWriter.info(f"Sending ECC request to: {ecc}")
Expand Down
3 changes: 2 additions & 1 deletion eventual-consistency-service/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def initialize_eventual_consistency_checker(graphname: str, conn: TigerGraphConn
password=milvus_config.get("password", ""),
vector_field=milvus_config.get("vector_field", "document_vector"),
text_field=milvus_config.get("text_field", "document_content"),
vertex_field=vertex_field
vertex_field=vertex_field,
alias=milvus_config.get("alias", "default")
)

if doc_processing_config.get("chunker") == "semantic":
Expand Down

0 comments on commit c9a6cdd

Please sign in to comment.