bstraehle commited on
Commit
e5984fd
·
verified ·
1 Parent(s): 979095d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -16,7 +16,11 @@ RAG_ADVANCED = "Advanced RAG"
16
  logging.basicConfig(stream = sys.stdout, level = logging.INFO)
17
  logging.getLogger().addHandler(logging.StreamHandler(stream = sys.stdout))
18
 
19
- def invoke(openai_api_key, prompt, rag_option):
 
 
 
 
20
  if not openai_api_key:
21
  raise gr.Error("OpenAI API Key is required.")
22
  if not prompt:
@@ -30,8 +34,15 @@ def invoke(openai_api_key, prompt, rag_option):
30
  if (RAG_INGESTION):
31
  return rag_ingestion(collection)
32
  else:
33
- retrieval_result = rag_retrieval(openai_api_key, prompt, db, collection)
34
- inference_result = rag_inference(openai_api_key, prompt, retrieval_result)
 
 
 
 
 
 
 
35
  print("###")
36
  print(inference_result)
37
  print("###")
@@ -45,6 +56,8 @@ demo = gr.Interface(
45
  fn = invoke,
46
  inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
47
  gr.Textbox(label = "Prompt", value = PROMPT, lines = 1),
 
 
48
  gr.Radio([RAG_OFF, RAG_NAIVE, RAG_ADVANCED], label = "Retrieval-Augmented Generation", value = RAG_ADVANCED)],
49
  outputs = [gr.Markdown(label = "Completion", value = os.environ["OUTPUT"], line_breaks = True, sanitize_html = False)],
50
  title = "Context-Aware Reasoning Application",
 
16
  logging.basicConfig(stream = sys.stdout, level = logging.INFO)
17
  logging.getLogger().addHandler(logging.StreamHandler(stream = sys.stdout))
18
 
19
+ def invoke(openai_api_key,
20
+ prompt,
21
+ accomodates,
22
+ bedrooms,
23
+ rag_option):
24
  if not openai_api_key:
25
  raise gr.Error("OpenAI API Key is required.")
26
  if not prompt:
 
34
  if (RAG_INGESTION):
35
  return rag_ingestion(collection)
36
  else:
37
+ retrieval_result = rag_retrieval(openai_api_key,
38
+ prompt,
39
+ accomodates,
40
+ bedrooms,
41
+ db,
42
+ collection)
43
+ inference_result = rag_inference(openai_api_key,
44
+ prompt,
45
+ retrieval_result)
46
  print("###")
47
  print(inference_result)
48
  print("###")
 
56
  fn = invoke,
57
  inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
58
  gr.Textbox(label = "Prompt", value = PROMPT, lines = 1),
59
+ gr.Number(label = "Accomodates", value = 2),
60
+ gr.Number(label = "Bedrooms", value = 1),
61
  gr.Radio([RAG_OFF, RAG_NAIVE, RAG_ADVANCED], label = "Retrieval-Augmented Generation", value = RAG_ADVANCED)],
62
  outputs = [gr.Markdown(label = "Completion", value = os.environ["OUTPUT"], line_breaks = True, sanitize_html = False)],
63
  title = "Context-Aware Reasoning Application",