Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -18,34 +18,27 @@ from wandb.sdk.data_types.trace_tree import Trace
|
|
18 |
|
19 |
_ = load_dotenv(find_dotenv())
|
20 |
|
21 |
-
WANDB_API_KEY = os.environ["WANDB_API_KEY"]
|
22 |
-
|
23 |
-
DESCRIPTION = os.environ["DESCRIPTION"]
|
24 |
-
|
25 |
-
MONGODB_ATLAS_CLUSTER_URI = os.environ["MONGODB_ATLAS_CLUSTER_URI"]
|
26 |
-
MONGODB_DB_NAME = "langchain_db"
|
27 |
-
MONGODB_COLLECTION_NAME = "gpt-4"
|
28 |
-
MONGODB_INDEX_NAME = "default"
|
29 |
-
|
30 |
-
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 "Thanks for using the 🧠 app - Bernd" at the end of the answer. """
|
31 |
-
|
32 |
-
llm_template = "Answer the question at the end. " + template + "Question: {question} Helpful Answer: "
|
33 |
-
rag_template = "Use the following pieces of context to answer the question at the end. " + template + "{context}. Question: {question} Helpful Answer: "
|
34 |
-
|
35 |
-
LLM_CHAIN_PROMPT = PromptTemplate(input_variables = ["question"], template = llm_template)
|
36 |
-
RAG_CHAIN_PROMPT = PromptTemplate(input_variables = ["context", "question"], template = rag_template)
|
37 |
-
|
38 |
-
CHROMA_DIR = "/data/chroma"
|
39 |
-
YOUTUBE_DIR = "/data/youtube"
|
40 |
-
|
41 |
PDF_URL = "https://arxiv.org/pdf/2303.08774.pdf"
|
42 |
WEB_URL = "https://openai.com/research/gpt-4"
|
43 |
YOUTUBE_URL_1 = "https://www.youtube.com/watch?v=--khbXchTeE"
|
44 |
YOUTUBE_URL_2 = "https://www.youtube.com/watch?v=hdhZwyf24mE"
|
45 |
YOUTUBE_URL_3 = "https://www.youtube.com/watch?v=vw-KWfKwvTQ"
|
46 |
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
RAG_MONGODB = "MongoDB"
|
50 |
|
51 |
client = MongoClient(MONGODB_ATLAS_CLUSTER_URI)
|
@@ -155,7 +148,7 @@ def wandb_trace(rag_option, prompt, completion, result, generation_info, llm_out
|
|
155 |
end_time_ms = end_time_ms
|
156 |
)
|
157 |
|
158 |
-
trace.log("
|
159 |
wandb.finish()
|
160 |
|
161 |
def invoke(openai_api_key, rag_option, prompt):
|
@@ -219,5 +212,5 @@ demo = gr.Interface(fn=invoke,
|
|
219 |
],
|
220 |
outputs = [gr.Textbox(label = "Completion", lines = 1)],
|
221 |
title = "Generative AI - LLM & RAG",
|
222 |
-
description = DESCRIPTION)
|
223 |
demo.launch()
|
|
|
18 |
|
19 |
_ = load_dotenv(find_dotenv())
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
PDF_URL = "https://arxiv.org/pdf/2303.08774.pdf"
|
22 |
WEB_URL = "https://openai.com/research/gpt-4"
|
23 |
YOUTUBE_URL_1 = "https://www.youtube.com/watch?v=--khbXchTeE"
|
24 |
YOUTUBE_URL_2 = "https://www.youtube.com/watch?v=hdhZwyf24mE"
|
25 |
YOUTUBE_URL_3 = "https://www.youtube.com/watch?v=vw-KWfKwvTQ"
|
26 |
|
27 |
+
YOUTUBE_DIR = "/data/youtube"
|
28 |
+
CHROMA_DIR = "/data/chroma"
|
29 |
+
|
30 |
+
MONGODB_ATLAS_CLUSTER_URI = os.environ["MONGODB_ATLAS_CLUSTER_URI"]
|
31 |
+
MONGODB_DB_NAME = "langchain_db"
|
32 |
+
MONGODB_COLLECTION_NAME = "gpt-4"
|
33 |
+
MONGODB_INDEX_NAME = "default"
|
34 |
+
|
35 |
+
LLM_CHAIN_PROMPT = PromptTemplate(input_variables = ["question"], template = os.environ["LLM_TEMPLATE"])
|
36 |
+
RAG_CHAIN_PROMPT = PromptTemplate(input_variables = ["context", "question"], template = os.environ["RAG_TEMPLATE"])
|
37 |
+
|
38 |
+
WANDB_API_KEY = os.environ["WANDB_API_KEY"]
|
39 |
+
|
40 |
+
RAG_OFF = "Off"
|
41 |
+
RAG_CHROMA = "Chroma"
|
42 |
RAG_MONGODB = "MongoDB"
|
43 |
|
44 |
client = MongoClient(MONGODB_ATLAS_CLUSTER_URI)
|
|
|
148 |
end_time_ms = end_time_ms
|
149 |
)
|
150 |
|
151 |
+
trace.log("evaluation")
|
152 |
wandb.finish()
|
153 |
|
154 |
def invoke(openai_api_key, rag_option, prompt):
|
|
|
212 |
],
|
213 |
outputs = [gr.Textbox(label = "Completion", lines = 1)],
|
214 |
title = "Generative AI - LLM & RAG",
|
215 |
+
description = os.environ["DESCRIPTION"])
|
216 |
demo.launch()
|