cloud-sean commited on
Commit
0690170
·
1 Parent(s): 1f70eef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -11,7 +11,7 @@ from langchain.llms import AzureOpenAI
11
 
12
  # os.environ["OPENAI_API_TYPE"] = openai.api_type = "azure"
13
  # os.environ["OPENAI_API_BASE"] = openai.api_base = "https://aoai-southcentral.openai.azure.com/"
14
- os.environ["OPENAI_API_KEY"] = openai.api_key = "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"
15
  # openai.api_version = "2023-03-15-preview"
16
 
17
 
@@ -27,11 +27,14 @@ class Capturing(list):
27
  sys.stdout = self._stdout
28
 
29
  def answer_question(input_file, question):
30
- llm = ChatOpenAI(model_name="gpt-4")
31
  agent = create_csv_agent(llm, input_file.name, verbose=True)
32
  question = question
33
  with Capturing() as printed_text:
34
- answer = agent.run(question)
 
 
 
35
 
36
  import re
37
  text = '\n'.join(printed_text) + '\n' + str(answer)
 
11
 
12
  # os.environ["OPENAI_API_TYPE"] = openai.api_type = "azure"
13
  # os.environ["OPENAI_API_BASE"] = openai.api_base = "https://aoai-southcentral.openai.azure.com/"
14
+ openai.api_key = "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"
15
  # openai.api_version = "2023-03-15-preview"
16
 
17
 
 
27
  sys.stdout = self._stdout
28
 
29
  def answer_question(input_file, question):
30
+ llm = ChatOpenAI(temperature=0)
31
  agent = create_csv_agent(llm, input_file.name, verbose=True)
32
  question = question
33
  with Capturing() as printed_text:
34
+ try:
35
+ answer = agent.run(question)
36
+ except Exception as e:
37
+ answer = "LLM: " + str(e)
38
 
39
  import re
40
  text = '\n'.join(printed_text) + '\n' + str(answer)