Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -34,10 +34,6 @@ config = {
|
|
34 |
"temperature": 0,
|
35 |
}
|
36 |
|
37 |
-
wandb.login(key = wandb_api_key)
|
38 |
-
wandb.init(project = "openai-llm-rag", config = config)
|
39 |
-
config = wandb.config
|
40 |
-
|
41 |
template = """If you don't know the answer, just say that you don't know, don't try to make up an answer. Keep the answer as concise as possible. Always say
|
42 |
"🧠 Thanks for using the app - Bernd" at the end of the answer. """
|
43 |
|
@@ -115,6 +111,18 @@ def rag_chain(llm, prompt, db):
|
|
115 |
completion = rag_chain({"query": prompt})
|
116 |
return completion["result"]
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
def invoke(openai_api_key, rag_option, prompt):
|
119 |
if (openai_api_key == ""):
|
120 |
raise gr.Error("OpenAI API Key is required.")
|
@@ -140,7 +148,7 @@ def invoke(openai_api_key, rag_option, prompt):
|
|
140 |
completion = llm_chain(llm, prompt)
|
141 |
except Exception as e:
|
142 |
raise gr.Error(e)
|
143 |
-
|
144 |
return completion
|
145 |
|
146 |
description = """<strong>Overview:</strong> Context-aware multimodal reasoning application that demonstrates a <strong>large language model (LLM)</strong> with
|
|
|
34 |
"temperature": 0,
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
37 |
template = """If you don't know the answer, just say that you don't know, don't try to make up an answer. Keep the answer as concise as possible. Always say
|
38 |
"🧠 Thanks for using the app - Bernd" at the end of the answer. """
|
39 |
|
|
|
111 |
completion = rag_chain({"query": prompt})
|
112 |
return completion["result"]
|
113 |
|
114 |
+
def evaluate(prompt, completion, rag_option):
|
115 |
+
wandb.login(key = wandb_api_key)
|
116 |
+
wandb.config["model"] = config.model
|
117 |
+
wandb.config["temperature"] = config.temperature
|
118 |
+
wandb.config["rag_option"] = rag_option
|
119 |
+
wandb.config["prompt"] = prompt
|
120 |
+
wandb.config["completion"] = completion
|
121 |
+
wandb.init(project = "openai-llm-rag", config = config)
|
122 |
+
#config = wandb.config
|
123 |
+
wandb.log({"prompt": prompt, "completion": completion})
|
124 |
+
wandb.logout()
|
125 |
+
|
126 |
def invoke(openai_api_key, rag_option, prompt):
|
127 |
if (openai_api_key == ""):
|
128 |
raise gr.Error("OpenAI API Key is required.")
|
|
|
148 |
completion = llm_chain(llm, prompt)
|
149 |
except Exception as e:
|
150 |
raise gr.Error(e)
|
151 |
+
evaluate(prompt, completion, rag_option)
|
152 |
return completion
|
153 |
|
154 |
description = """<strong>Overview:</strong> Context-aware multimodal reasoning application that demonstrates a <strong>large language model (LLM)</strong> with
|