File size: 1,905 Bytes
825dc04
 
 
c32f8d1
825dc04
 
 
4a9c624
825dc04
 
c32f8d1
 
 
86bb3dc
 
 
 
 
 
 
 
 
 
c32f8d1
86bb3dc
 
 
 
 
 
 
 
 
825dc04
 
 
6a2f664
9efb673
31df063
843d855
 
5fd94ea
 
e349be7
4d56776
e349be7
4d56776
e349be7
4d56776
d62c156
 
 
a926c23
 
06b15ba
 
c32f8d1
06b15ba
1fcfd36
 
825dc04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import openai
import numpy as np
import os
import json
import gradio as gr
 
openai.api_key = os.environ["api_key"]
engine = "code-davinci-002"


def happytt(temperature,max_tokens,text,stop):
  try:
    s = json.loads(stop)
    response = openai.Completion.create(
      engine=engine,
      prompt=text,
      temperature=temperature,
      max_tokens=max_tokens,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0,
      stop=s
    )
  except json.JSONDecodeError:
    response = openai.Completion.create(
      engine=engine,
      prompt=text,
      temperature=temperature,
      max_tokens=max_tokens,
      top_p=1,
      frequency_penalty=0,
      presence_penalty=0
    )

  return response.choices[0].text


title = "OpenAI Codex"
description = '''OpenAI Codex is an artificial intelligence model developed by OpenAI. 
It parses natural language and generates code in response. 
It is used to power GitHub Copilot, a programming autocompletion 
tool developed for  Code generation.

Try following prompts and tweak temperatures  in following links -

https://www.pragnakalp.com/experimenting-with-openai-codex/

https://betterprogramming.pub/i-beta-tested-openais-codex-and-the-results-are-spooky-good-e282a1874c79

https://beta.openai.com/examples?category=code

Built by  [mohammed arsalan](https://www.linkedin.com/in/sallu-mandya/)'''
 
 
iface = gr.Interface( happytt,[ gr.Slider(0, 1, step=0.1),gr.Slider(150, 4000, step=1),
                               gr.Textbox(type='str',   
                                                 label="input prompt"),
                               gr.Textbox(type='str',   
                                                 label="list of tokens, when to finish generating",
                                                 placeholder='["<code>", "import"]')],"text", title = title, description = description )
iface.launch(debug=True)