JayKen commited on
Commit
8beb60b
·
1 Parent(s): a7ba2fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -4,9 +4,7 @@ import openai
4
  # get API key from top-right dropdown on OpenAI website
5
  openai.api_key = "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"
6
 
7
- # first let's make it simpler to get answers
8
- def complete(prompt):
9
- # query text-davinci-003
10
  res = openai.Completion.create(
11
  engine='text-davinci-003',
12
  prompt=prompt,
@@ -15,16 +13,14 @@ def complete(prompt):
15
  top_p=1,
16
  frequency_penalty=0,
17
  presence_penalty=0,
18
- stop=None
19
- )
20
- return res['choices'][0]['text'].strip()
21
-
22
- def show(t0,query,context):
23
- if 'financial' in context:
24
- return 'no'
25
- else:
26
- prompt ="Answer the question based on the context below.\n\n"+ "Context:\n"+contexts+"\n\n"+query
27
- return complete(prompt)
28
 
29
  demo = gr.Interface(
30
  show,
 
4
  # get API key from top-right dropdown on OpenAI website
5
  openai.api_key = "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"
6
 
7
+ def show(t0,query,context):
 
 
8
  res = openai.Completion.create(
9
  engine='text-davinci-003',
10
  prompt=prompt,
 
13
  top_p=1,
14
  frequency_penalty=0,
15
  presence_penalty=0,
16
+ stop=None)
17
+
18
+ if 'financial' in context:
19
+ return 'no'
20
+ else:
21
+ prompt ="Answer the question based on the context below.\n\n"+ "Context:\n"+contexts+"\n\n"+query
22
+ return res['choices'][0]['text'].strip()
23
+
 
 
24
 
25
  demo = gr.Interface(
26
  show,