bstraehle commited on
Commit
93bb5d3
·
1 Parent(s): 66535fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -34,6 +34,9 @@ config = {
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,11 +114,6 @@ def rag_chain(llm, prompt, db):
111
  completion = rag_chain({"query": prompt})
112
  return completion["result"]
113
 
114
- def log_wandb(prompt, completion, rag_option):
115
- wandb.login(key = wandb_api_key)
116
- wandb.init(project = "openai-llm-rag", config = config)
117
- wandb.log({"prompt": prompt, "completion": completion, "rag_option": rag_option})
118
-
119
  def invoke(openai_api_key, rag_option, prompt):
120
  if (openai_api_key == ""):
121
  raise gr.Error("OpenAI API Key is required.")
@@ -141,7 +139,7 @@ def invoke(openai_api_key, rag_option, prompt):
141
  completion = llm_chain(llm, prompt)
142
  except Exception as e:
143
  raise gr.Error(e)
144
- log_wandb(prompt, completion, rag_option)
145
  return completion
146
 
147
  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
+ wandb.login(key = wandb_api_key)
38
+ wandb.init(project = "openai-llm-rag", config = config)
39
+
40
  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
41
  "🧠 Thanks for using the app - Bernd" at the end of the answer. """
42
 
 
114
  completion = rag_chain({"query": prompt})
115
  return completion["result"]
116
 
 
 
 
 
 
117
  def invoke(openai_api_key, rag_option, prompt):
118
  if (openai_api_key == ""):
119
  raise gr.Error("OpenAI API Key is required.")
 
139
  completion = llm_chain(llm, prompt)
140
  except Exception as e:
141
  raise gr.Error(e)
142
+ wandb.log({"prompt": prompt, "completion": completion, "rag_option": rag_option})
143
  return completion
144
 
145
  description = """<strong>Overview:</strong> Context-aware multimodal reasoning application that demonstrates a <strong>large language model (LLM)</strong> with