Spaces:
Runtime error
Runtime error
launch carbon
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ 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"
|
@@ -102,21 +103,19 @@ def greet(name, owner):
|
|
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}
|
@@ -128,8 +127,9 @@ res=requests.post(url,headers=headers,params=params,data=json.dumps(payload))
|
|
128 |
|
129 |
col = st.beta_columns([2, 4])
|
130 |
if col.button("Create a 'carbon' copy"):
|
131 |
-
res.
|
132 |
-
|
|
|
133 |
outputs = [gr.outputs.HTML(label="Solution")]
|
134 |
|
135 |
gr.Interface(
|
|
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
import requests
|
7 |
import json
|
8 |
+
import webbrowser
|
9 |
|
10 |
# model_name = "flax-community/gpt-code-clippy-1.3B-apps-alldata"
|
11 |
model_name = "flax-community/gpt-code-clippy-125M-apps-alldata"
|
|
|
103 |
|
104 |
|
105 |
inputs = [
|
|
|
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 |
+
gr.inputs.Textbox(lines=1, label="Your GitHub API token")
|
111 |
]
|
112 |
|
113 |
# adding carbon support
|
|
|
|
|
|
|
114 |
|
115 |
+
GITHUB_API="https://api.github.com"
|
116 |
+
API_TOKEN=gr.inputs.Textbox(label="Your GitHub API token")
|
117 |
#form a request URL
|
118 |
url=GITHUB_API+"/gists"
|
|
|
119 |
|
120 |
#print headers,parameters,payload
|
121 |
headers={'Authorization':'token %s'%API_TOKEN}
|
|
|
127 |
|
128 |
col = st.beta_columns([2, 4])
|
129 |
if col.button("Create a 'carbon' copy"):
|
130 |
+
carbon_url='https://carbon.now.sh/'+res.text.split(',')[0].split('/')[-1][:-1]
|
131 |
+
webbrowser.open_new(carbon_url)
|
132 |
+
|
133 |
outputs = [gr.outputs.HTML(label="Solution")]
|
134 |
|
135 |
gr.Interface(
|