Rachel Rakov commited on
Commit
a111acc
·
1 Parent(s): a336ee3

Troubleshooting new openAI format

Browse files
Files changed (1) hide show
  1. eng_to_aslGloss_app.py +8 -4
eng_to_aslGloss_app.py CHANGED
@@ -1,13 +1,16 @@
1
  from pathlib import Path
2
  import gradio as gr
3
- import openai
4
  import os
5
  import tiktoken
 
6
 
7
 
8
  # Set secret key
9
  HF_TOKEN = os.getenv("NextStar")
10
 
 
 
11
 
12
  #Set prompt engineering paths (so globally available)
13
  inStructionPath = "intro_instructions_combine.txt"
@@ -70,8 +73,8 @@ def getGlossFromText(query):
70
 
71
  def getASLGloss(testQs):
72
  """Get ASL gloss from OpenAI using our prompt engineering"""
73
- openai.api_key = HF_TOKEN
74
- completion = openai.ChatCompletion.create(
75
  model = 'gpt-4-0125-preview',
76
  messages = [
77
  {"role": "system", "content": instruct},
@@ -83,7 +86,8 @@ def getASLGloss(testQs):
83
 
84
  temperature = 0
85
  )
86
- results = completion['choices'][0]['message']['content']
 
87
  return results
88
 
89
 
 
1
  from pathlib import Path
2
  import gradio as gr
3
+ #import openai
4
  import os
5
  import tiktoken
6
+ from openai import OpenAI
7
 
8
 
9
  # Set secret key
10
  HF_TOKEN = os.getenv("NextStar")
11
 
12
+ # Set client
13
+ client = OpenAI(HF_TOKEN)
14
 
15
  #Set prompt engineering paths (so globally available)
16
  inStructionPath = "intro_instructions_combine.txt"
 
73
 
74
  def getASLGloss(testQs):
75
  """Get ASL gloss from OpenAI using our prompt engineering"""
76
+ #openai.api_key = HF_TOKENS
77
+ completion = client.chat.completions.create(
78
  model = 'gpt-4-0125-preview',
79
  messages = [
80
  {"role": "system", "content": instruct},
 
86
 
87
  temperature = 0
88
  )
89
+ #results = completion['choices'][0]['message']['content']
90
+ results = completion.choices[0].message.content
91
  return results
92
 
93