Update app.py
Browse files
app.py
CHANGED
@@ -30,6 +30,8 @@ MONGODB_COLLECTION_NAME = "gpt-4"
|
|
30 |
MONGODB_COLLECTION = client[MONGODB_DB_NAME][MONGODB_COLLECTION_NAME]
|
31 |
MONGODB_INDEX_NAME = "default"
|
32 |
|
|
|
|
|
33 |
config = {
|
34 |
"chunk_overlap": 150,
|
35 |
"chunk_size": 1500,
|
@@ -183,30 +185,6 @@ def invoke(openai_api_key, rag_option, prompt):
|
|
183 |
wandb_trace(rag_option, prompt, prompt_template, result, completion, chain_name, status_msg, start_time_ms, end_time_ms)
|
184 |
return result
|
185 |
|
186 |
-
description = """<strong>Overview:</strong> Context-aware multimodal reasoning application using a <strong>large language model (LLM)</strong> with
|
187 |
-
<strong>retrieval augmented generation (RAG)</strong>.
|
188 |
-
See the <a href='https://raw.githubusercontent.com/bstraehle/ai-ml-dl/main/hugging-face/openai-llm-rag.png'>architecture diagram</a>.\n\n
|
189 |
-
<strong>Instructions:</strong> Enter an OpenAI API key and perform text generation use cases on <a href='""" + YOUTUBE_URL_1 + """'>YouTube</a>,
|
190 |
-
<a href='""" + PDF_URL + """'>PDF</a>, and <a href='""" + WEB_URL + """'>web</a> data published after LLM knowledge cutoff (example: GPT-4 data).
|
191 |
-
<ul style="list-style-type:square;">
|
192 |
-
<li>Set "Retrieval Augmented Generation" to "<strong>Off</strong>" and submit prompt "What is GPT-4?" The <strong>LLM without RAG</strong> does not know the answer.</li>
|
193 |
-
<li>Set "Retrieval Augmented Generation" to "<strong>Chroma</strong>" or "<strong>MongoDB</strong>" and experiment with prompts. The <strong>LLM with RAG</strong> knows the answer:</li>
|
194 |
-
<ol>
|
195 |
-
<li>What are GPT-4's media capabilities in 5 emojis and 1 sentence?</li>
|
196 |
-
<li>List GPT-4's exam scores and benchmark results.</li>
|
197 |
-
<li>Compare GPT-4 to GPT-3.5 in markdown table format.</li>
|
198 |
-
<li>Write a Python program that calls the GPT-4 API.</li>
|
199 |
-
<li>What is the GPT-4 API's cost and rate limit? Answer in English, Arabic, Chinese, Hindi, and Russian in JSON format.</li>
|
200 |
-
</ol>
|
201 |
-
</ul>\n\n
|
202 |
-
<strong>Technology:</strong> <a href='https://www.gradio.app/'>Gradio</a> UI using the <a href='https://openai.com/'>OpenAI</a> API and
|
203 |
-
AI-native <a href='https://www.trychroma.com/'>Chroma</a> embedding database or
|
204 |
-
<a href='https://www.mongodb.com/blog/post/introducing-atlas-vector-search-build-intelligent-applications-semantic-search-ai'>MongoDB</a> vector search.
|
205 |
-
<strong>Speech-to-text</strong> via <a href='https://openai.com/research/whisper'>whisper-1</a> model, <strong>text embedding</strong> via
|
206 |
-
<a href='https://openai.com/blog/new-and-improved-embedding-model'>text-embedding-ada-002</a> model, and <strong>text generation</strong> via
|
207 |
-
<a href='""" + WEB_URL + """'>gpt-4</a> model. Implementation via AI-first <a href='https://www.langchain.com/'>LangChain</a> toolkit.
|
208 |
-
Model performance evaluation via <a href='https://wandb.ai/bstraehle/openai-llm-rag/workspace'>Weights & Biases</a>."""
|
209 |
-
|
210 |
gr.close_all()
|
211 |
demo = gr.Interface(fn=invoke,
|
212 |
inputs = [gr.Textbox(label = "OpenAI API Key", value = "sk-", lines = 1),
|
|
|
30 |
MONGODB_COLLECTION = client[MONGODB_DB_NAME][MONGODB_COLLECTION_NAME]
|
31 |
MONGODB_INDEX_NAME = "default"
|
32 |
|
33 |
+
description = os.environ["DESCRIPTION"]
|
34 |
+
|
35 |
config = {
|
36 |
"chunk_overlap": 150,
|
37 |
"chunk_size": 1500,
|
|
|
185 |
wandb_trace(rag_option, prompt, prompt_template, result, completion, chain_name, status_msg, start_time_ms, end_time_ms)
|
186 |
return result
|
187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
gr.close_all()
|
189 |
demo = gr.Interface(fn=invoke,
|
190 |
inputs = [gr.Textbox(label = "OpenAI API Key", value = "sk-", lines = 1),
|