bstraehle commited on
Commit
1283168
1 Parent(s): a4df70d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -41,11 +41,11 @@ YOUTUBE_URL_3 = "https://www.youtube.com/watch?v=vw-KWfKwvTQ"
41
  MODEL_NAME = "gpt-4"
42
 
43
  def invoke(openai_api_key, use_rag, prompt):
44
- llm = ChatOpenAI(model_name = MODEL_NAME,
45
- openai_api_key = openai_api_key,
46
- temperature = 0)
47
- if (use_rag):
48
- try:
49
  # Document loading
50
  #docs = []
51
  # Load PDF
@@ -77,11 +77,11 @@ def invoke(openai_api_key, use_rag, prompt):
77
  return_source_documents = True)
78
  result = rag_chain({"query": prompt})
79
  result = result["result"]
80
- except Exception as e:
81
- raise gr.Error(e)
82
- else:
83
- chain = LLMChain(llm = llm, prompt = LLM_CHAIN_PROMPT)
84
- result = chain.run({"question": prompt})
85
  return result
86
 
87
  description = """<strong>Overview:</strong> Reasoning application that demonstrates a <strong>Large Language Model (LLM)</strong> with
 
41
  MODEL_NAME = "gpt-4"
42
 
43
  def invoke(openai_api_key, use_rag, prompt):
44
+ try:
45
+ llm = ChatOpenAI(model_name = MODEL_NAME,
46
+ openai_api_key = openai_api_key,
47
+ temperature = 0)
48
+ if (use_rag):
49
  # Document loading
50
  #docs = []
51
  # Load PDF
 
77
  return_source_documents = True)
78
  result = rag_chain({"query": prompt})
79
  result = result["result"]
80
+ else:
81
+ chain = LLMChain(llm = llm, prompt = LLM_CHAIN_PROMPT)
82
+ result = chain.run({"question": prompt})
83
+ except Exception as e:
84
+ raise gr.Error(e)
85
  return result
86
 
87
  description = """<strong>Overview:</strong> Reasoning application that demonstrates a <strong>Large Language Model (LLM)</strong> with