Spaces:
Runtime error
Runtime error
added box for gh api token
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
|
|
3 |
from rich.console import Console
|
4 |
from rich.syntax import Syntax
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
6 |
|
7 |
# model_name = "flax-community/gpt-code-clippy-1.3B-apps-alldata"
|
8 |
model_name = "flax-community/gpt-code-clippy-125M-apps-alldata"
|
@@ -15,9 +17,19 @@ console = Console(record=True)
|
|
15 |
|
16 |
def format_input(question, starter_code=""):
|
17 |
answer_type = (
|
18 |
-
"\
|
|
|
|
|
|
|
|
|
19 |
)
|
20 |
-
return f"\
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
|
23 |
def format_outputs(text):
|
@@ -90,12 +102,34 @@ def greet(name, owner):
|
|
90 |
|
91 |
|
92 |
inputs = [
|
|
|
93 |
gr.inputs.Textbox(placeholder="Define a problem here...", lines=7),
|
94 |
gr.inputs.Textbox(placeholder="Provide optional starter code...", lines=3),
|
95 |
gr.inputs.Slider(0.5, 1.5, 0.1, default=0.8, label="Temperature"),
|
96 |
gr.inputs.Slider(1, 4, 1, default=1, label="Beam size"),
|
97 |
]
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
outputs = [gr.outputs.HTML(label="Solution")]
|
100 |
|
101 |
gr.Interface(
|
|
|
3 |
from rich.console import Console
|
4 |
from rich.syntax import Syntax
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
+
import requests
|
7 |
+
import json
|
8 |
|
9 |
# model_name = "flax-community/gpt-code-clippy-1.3B-apps-alldata"
|
10 |
model_name = "flax-community/gpt-code-clippy-125M-apps-alldata"
|
|
|
17 |
|
18 |
def format_input(question, starter_code=""):
|
19 |
answer_type = (
|
20 |
+
"\
|
21 |
+
Use Call-Based format\
|
22 |
+
" if starter_code else "\
|
23 |
+
Use Standard Input format\
|
24 |
+
"
|
25 |
)
|
26 |
+
return f"\
|
27 |
+
QUESTION:\
|
28 |
+
{question}\
|
29 |
+
{starter_code}\
|
30 |
+
{answer_type}\
|
31 |
+
ANSWER:\
|
32 |
+
"
|
33 |
|
34 |
|
35 |
def format_outputs(text):
|
|
|
102 |
|
103 |
|
104 |
inputs = [
|
105 |
+
gr.inputs.Textbox(lines=1, label="Your GitHub API token"),
|
106 |
gr.inputs.Textbox(placeholder="Define a problem here...", lines=7),
|
107 |
gr.inputs.Textbox(placeholder="Provide optional starter code...", lines=3),
|
108 |
gr.inputs.Slider(0.5, 1.5, 0.1, default=0.8, label="Temperature"),
|
109 |
gr.inputs.Slider(1, 4, 1, default=1, label="Beam size"),
|
110 |
]
|
111 |
|
112 |
+
# adding carbon support
|
113 |
+
```
|
114 |
+
GITHUB_API="https://api.github.com"
|
115 |
+
API_TOKEN='your_token_goes_here'
|
116 |
+
|
117 |
+
#form a request URL
|
118 |
+
url=GITHUB_API+"/gists"
|
119 |
+
print ("Request URL: %s"%url)
|
120 |
+
|
121 |
+
#print headers,parameters,payload
|
122 |
+
headers={'Authorization':'token %s'%API_TOKEN}
|
123 |
+
params={'scope':'gist'}
|
124 |
+
payload={inputs}
|
125 |
+
|
126 |
+
res=requests.post(url,headers=headers,params=params,data=json.dumps(payload))
|
127 |
+
|
128 |
+
|
129 |
+
col = st.beta_columns([2, 4])
|
130 |
+
if col.button("Create a 'carbon' copy"):
|
131 |
+
res.url
|
132 |
+
```
|
133 |
outputs = [gr.outputs.HTML(label="Solution")]
|
134 |
|
135 |
gr.Interface(
|