nlztrk commited on
Commit
79d0dbc
1 Parent(s): 9d4a4de

Edited OAI model params

Browse files
Files changed (1) hide show
  1. app.py +26 -10
app.py CHANGED
@@ -23,7 +23,7 @@ class OpenAI_API:
23
  def __init__(self):
24
  self.openai_api_key = ''
25
 
26
- def single_request(self, prompt_input):
27
 
28
  openai.api_type = "azure"
29
  openai.api_base = "https://damlaopenai.openai.azure.com/"
@@ -31,15 +31,19 @@ class OpenAI_API:
31
  openai.api_key = os.getenv("API_KEY")
32
 
33
  response = openai.Completion.create(
34
- model="text-davinci-003",
35
- prompt=prompt_input,
36
- temperature=0,
37
- max_tokens=300,
38
- top_p=1,
39
- frequency_penalty=0.0,
40
- presence_penalty=0.0,
41
- stop=["\n"],
42
- )
 
 
 
 
43
 
44
  return response
45
 
@@ -140,6 +144,18 @@ def openai_response(ocr_input):
140
  resp[key] = ''
141
  return resp
142
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
  with gr.Blocks() as demo:
145
  gr.Markdown(
 
23
  def __init__(self):
24
  self.openai_api_key = ''
25
 
26
+ def single_request(self, address_text):
27
 
28
  openai.api_type = "azure"
29
  openai.api_base = "https://damlaopenai.openai.azure.com/"
 
31
  openai.api_key = os.getenv("API_KEY")
32
 
33
  response = openai.Completion.create(
34
+ engine="Davinci-003",
35
+ prompt=address_text,
36
+ temperature=0.,#9,
37
+ max_tokens=300,
38
+ top_p=1.0,
39
+ # n=1,
40
+ # logprobs=0,
41
+ # echo=False,
42
+ # stop=None,
43
+ frequency_penalty=0,
44
+ presence_penalty=0,
45
+ stop=["\n"],
46
+ best_of=1)
47
 
48
  return response
49
 
 
144
  resp[key] = ''
145
  return resp
146
 
147
+ def ner_response(ocr_input):
148
+ API_URL = "https://api-inference.huggingface.co/models/deprem-ml/deprem-ner"
149
+ headers = {"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
150
+
151
+ def query(payload):
152
+ response = requests.post(API_URL, headers=headers, json=payload)
153
+ return response.json()
154
+
155
+ output = query({
156
+ "inputs": ocr_input,
157
+ })
158
+ return output
159
 
160
  with gr.Blocks() as demo:
161
  gr.Markdown(