We’ve created an improved version of OpenAI Codex, our AI system that translates natural language to code, and we are releasing it through our API in private beta starting today.
The example of code for catching key press and add text:
from prompt_toolkit import prompt
from prompt_toolkit.key_binding import KeyBindings
# Define key bindings to replace text on space key press
kb = KeyBindings()
@kb.add(' ')
def _(event):
event.current_buffer.text = event.current_buffer.text + ' space :)'
event.current_buffer.cursor_position += len(event.current_buffer.text) # move coursor to the end
# Start a prompt session with key bindings
text = prompt('> ', key_bindings=kb)
print('You entered:', text)
Draft 1:
import openai
openai.api_key = "YOUR_API_KEY_HERE" # https://platform.openai.com/account/api-keys
# Example prompt
prompt = "I love Python because"
# Example completion using the GPT-3 model
response = openai.Completion.create(
engine="davinci", prompt=prompt, max_tokens=50
)
# Print the response
print(response.choices[0].text)
The example of code for catching key press and add text:
Draft 1:
Draft 2:
For community
⬇️ Please click the 👍 reaction instead of leaving a
+1
or 👍 comment