Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -111,11 +111,10 @@ def rag_chain(llm, prompt, db):
|
|
111 |
completion = rag_chain({"query": prompt})
|
112 |
return completion["result"]
|
113 |
|
114 |
-
def
|
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 |
-
wandb.logout()
|
119 |
|
120 |
def invoke(openai_api_key, rag_option, prompt):
|
121 |
if (openai_api_key == ""):
|
@@ -142,7 +141,7 @@ def invoke(openai_api_key, rag_option, prompt):
|
|
142 |
completion = llm_chain(llm, prompt)
|
143 |
except Exception as e:
|
144 |
raise gr.Error(e)
|
145 |
-
|
146 |
return completion
|
147 |
|
148 |
description = """<strong>Overview:</strong> Context-aware multimodal reasoning application that demonstrates a <strong>large language model (LLM)</strong> with
|
@@ -167,7 +166,7 @@ description = """<strong>Overview:</strong> Context-aware multimodal reasoning a
|
|
167 |
<strong>Speech-to-text</strong> via <a href='https://openai.com/research/whisper'>whisper-1</a> model, <strong>text embedding</strong> via
|
168 |
<a href='https://openai.com/blog/new-and-improved-embedding-model'>text-embedding-ada-002</a> model, and <strong>text generation</strong> via
|
169 |
<a href='""" + WEB_URL + """'>gpt-4</a> model. Implementation via AI-first <a href='https://www.langchain.com/'>LangChain</a> toolkit.
|
170 |
-
|
171 |
|
172 |
gr.close_all()
|
173 |
demo = gr.Interface(fn=invoke,
|
|
|
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 == ""):
|
|
|
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
|
|
|
166 |
<strong>Speech-to-text</strong> via <a href='https://openai.com/research/whisper'>whisper-1</a> model, <strong>text embedding</strong> via
|
167 |
<a href='https://openai.com/blog/new-and-improved-embedding-model'>text-embedding-ada-002</a> model, and <strong>text generation</strong> via
|
168 |
<a href='""" + WEB_URL + """'>gpt-4</a> model. Implementation via AI-first <a href='https://www.langchain.com/'>LangChain</a> toolkit.
|
169 |
+
RAG evaluation via <a href='https://wandb.ai/bstraehle'>Weights & Biases</a>."""
|
170 |
|
171 |
gr.close_all()
|
172 |
demo = gr.Interface(fn=invoke,
|