Spaces:
Sleeping
Sleeping
try 2.4
Browse files- api/chain.go +22 -20
api/chain.go
CHANGED
|
@@ -31,10 +31,10 @@ func InvokeChain(apiKey string, userQuery string) (ChatOutput, error) {
|
|
| 31 |
prompt := string(systemPrompt) + "\n\nUser Query: " + userQuery
|
| 32 |
|
| 33 |
// Write prompt to log file ==> To be removed in production
|
| 34 |
-
err = writePromptToLogFile(prompt)
|
| 35 |
-
if err != nil {
|
| 36 |
-
|
| 37 |
-
}
|
| 38 |
|
| 39 |
ctx := context.Background()
|
| 40 |
|
|
@@ -47,6 +47,8 @@ func InvokeChain(apiKey string, userQuery string) (ChatOutput, error) {
|
|
| 47 |
llms.WithJSONMode(),
|
| 48 |
)
|
| 49 |
|
|
|
|
|
|
|
| 50 |
if err != nil {
|
| 51 |
return ChatOutput{}, fmt.Errorf("error in generating content: %v", err)
|
| 52 |
}
|
|
@@ -71,19 +73,19 @@ func extractResponse(responseContent string) string {
|
|
| 71 |
return responseContent
|
| 72 |
}
|
| 73 |
|
| 74 |
-
func writePromptToLogFile(prompt string) error {
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
}
|
|
|
|
| 31 |
prompt := string(systemPrompt) + "\n\nUser Query: " + userQuery
|
| 32 |
|
| 33 |
// Write prompt to log file ==> To be removed in production
|
| 34 |
+
// err = writePromptToLogFile(prompt)
|
| 35 |
+
// if err != nil {
|
| 36 |
+
// return ChatOutput{}, fmt.Errorf("error writing prompt to log file: %v", err)
|
| 37 |
+
// }
|
| 38 |
|
| 39 |
ctx := context.Background()
|
| 40 |
|
|
|
|
| 47 |
llms.WithJSONMode(),
|
| 48 |
)
|
| 49 |
|
| 50 |
+
log.Println("Response Content: ", responseContent)
|
| 51 |
+
|
| 52 |
if err != nil {
|
| 53 |
return ChatOutput{}, fmt.Errorf("error in generating content: %v", err)
|
| 54 |
}
|
|
|
|
| 73 |
return responseContent
|
| 74 |
}
|
| 75 |
|
| 76 |
+
// func writePromptToLogFile(prompt string) error {
|
| 77 |
+
// // if _, err := os.Stat("./log"); os.IsNotExist(err) {
|
| 78 |
+
// // os.Mkdir("./log", 0755)
|
| 79 |
+
// // }
|
| 80 |
+
// file, err := os.OpenFile("./prompt.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
| 81 |
+
// if err != nil {
|
| 82 |
+
// return fmt.Errorf("error opening log file: %v", err)
|
| 83 |
+
// }
|
| 84 |
+
// defer file.Close()
|
| 85 |
+
|
| 86 |
+
// if _, err := file.WriteString(prompt); err != nil {
|
| 87 |
+
// return fmt.Errorf("error writing to log file: %v", err)
|
| 88 |
+
// }
|
| 89 |
+
|
| 90 |
+
// return nil
|
| 91 |
+
// }
|