bstraehle commited on
Commit
4873e9b
1 Parent(s): 5b7aea8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -23
app.py CHANGED
@@ -54,7 +54,8 @@ def invoke(openai_api_key, prompt, rag_option):
54
  else:
55
  completion, chain, callback = llm_chain(config, prompt)
56
 
57
- if (completion.generations[0] != None and completion.generations[0][0] != None):
 
58
  result = completion.generations[0][0].text
59
  except Exception as e:
60
  err_msg = e
@@ -63,32 +64,34 @@ def invoke(openai_api_key, prompt, rag_option):
63
  finally:
64
  end_time_ms = round(time.time() * 1000)
65
 
66
- trace_wandb(config,
67
- rag_option,
68
- prompt,
69
- completion,
70
- result,
71
- callback,
72
- err_msg,
73
- start_time_ms,
74
- end_time_ms)
 
75
 
76
  return result
77
 
78
  gr.close_all()
79
 
80
- demo = gr.Interface(fn = invoke,
81
- inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
82
- gr.Textbox(label = "Prompt", value = "What are GPT-4's media capabilities in 5 emojis and 1 sentence?", lines = 1),
83
- gr.Radio([RAG_OFF, RAG_LANGCHAIN, RAG_LLAMAINDEX], label = "Retrieval-Augmented Generation", value = RAG_LANGCHAIN)],
84
- outputs = [gr.Textbox(label = "Completion", lines = 1)],
85
- title = "Context-Aware Reasoning Application",
86
- description = os.environ["DESCRIPTION"],
87
- examples = [["", "What are GPT-4's media capabilities in 5 emojis and 1 sentence?", RAG_LANGCHAIN],
88
- ["", "List GPT-4's exam scores and benchmark results.", RAG_LANGCHAIN],
89
- ["", "Compare GPT-4 to GPT-3.5 in markdown table format.", RAG_LANGCHAIN],
90
- ["", "Write a Python program that calls the GPT-4 API.", RAG_LANGCHAIN],
91
- ["", "What is the GPT-4 API's cost and rate limit? Answer in English, Arabic, Chinese, Hindi, and Russian in JSON format.", RAG_LANGCHAIN]],
92
- cache_examples = False)
 
93
 
94
  demo.launch()
 
54
  else:
55
  completion, chain, callback = llm_chain(config, prompt)
56
 
57
+ if (completion.generations[0] != None and
58
+ completion.generations[0][0] != None):
59
  result = completion.generations[0][0].text
60
  except Exception as e:
61
  err_msg = e
 
64
  finally:
65
  end_time_ms = round(time.time() * 1000)
66
 
67
+ trace_wandb(
68
+ config,
69
+ rag_option,
70
+ prompt,
71
+ completion,
72
+ result,
73
+ callback,
74
+ err_msg,
75
+ start_time_ms,
76
+ end_time_ms)
77
 
78
  return result
79
 
80
  gr.close_all()
81
 
82
+ demo = gr.Interface(
83
+ fn = invoke,
84
+ inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
85
+ gr.Textbox(label = "Prompt", value = "What are GPT-4's media capabilities in 5 emojis and 1 sentence?", lines = 1),
86
+ gr.Radio([RAG_OFF, RAG_LANGCHAIN, RAG_LLAMAINDEX], label = "Retrieval-Augmented Generation", value = RAG_LANGCHAIN)],
87
+ outputs = [gr.Textbox(label = "Completion", lines = 1)],
88
+ title = "Context-Aware Reasoning Application",
89
+ description = os.environ["DESCRIPTION"],
90
+ examples = [["", "What are GPT-4's media capabilities in 5 emojis and 1 sentence?", RAG_LANGCHAIN],
91
+ ["", "List GPT-4's exam scores and benchmark results.", RAG_LANGCHAIN],
92
+ ["", "Compare GPT-4 to GPT-3.5 in markdown table format.", RAG_LANGCHAIN],
93
+ ["", "Write a Python program that calls the GPT-4 API.", RAG_LANGCHAIN],
94
+ ["", "What is the GPT-4 API's cost and rate limit? Answer in English, Arabic, Chinese, Hindi, and Russian in JSON format.", RAG_LANGCHAIN]],
95
+ cache_examples = False)
96
 
97
  demo.launch()