Spaces:
Runtime error
Runtime error
add dfs simpler example
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import requests as req
|
|
4 |
|
5 |
code_nl = "function for db connection"
|
6 |
|
7 |
-
# CT5_URL = "https://api-inference.huggingface.co/models/nielsr/codet5-small-code-summarization-ruby"
|
8 |
CT5_URL = "https://api-inference.huggingface.co/models/stmnk/codet5-small-code-summarization-python"
|
9 |
CT5_METHOD = 'POST'
|
10 |
API_URL = CT5_URL
|
@@ -15,6 +14,15 @@ def query(payload):
|
|
15 |
return response.json()
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
function_code = r"""
|
19 |
def write_documents(self, documents: Union[List[dict], List[Document]], index: Optional[str] = None,
|
20 |
batch_size: int = 10_000, duplicate_documents: Optional[str] = None):
|
@@ -71,7 +79,8 @@ def write_documents(self, documents: Union[List[dict], List[Document]], index: O
|
|
71 |
|
72 |
"""
|
73 |
|
74 |
-
task_code = f' Summarize Python: {function_code}'
|
|
|
75 |
|
76 |
real_docstring = r"""
|
77 |
Indexes documents for later queries in Elasticsearch.
|
@@ -108,13 +117,14 @@ def docgen_func(function_code):
|
|
108 |
return str(output)
|
109 |
|
110 |
def pygen_func(nl_code_intent):
|
111 |
-
pass # TODO: generate code PL from intent NL
|
112 |
# inputs = {'code_nl': code_nl}
|
113 |
# payload = json.dumps(inputs)
|
114 |
# prediction = req.request(CT5_METHOD, CT5_URL, data=payload)
|
115 |
# prediction = req.request(CT5_METHOD, CT5_URL, json=req_data)
|
116 |
# answer = json.loads(prediction.content.decode("utf-8"))
|
117 |
# return str(answer)
|
|
|
118 |
|
119 |
iface = gr.Interface(
|
120 |
# pygen_func,
|
|
|
4 |
|
5 |
code_nl = "function for db connection"
|
6 |
|
|
|
7 |
CT5_URL = "https://api-inference.huggingface.co/models/stmnk/codet5-small-code-summarization-python"
|
8 |
CT5_METHOD = 'POST'
|
9 |
API_URL = CT5_URL
|
|
|
14 |
return response.json()
|
15 |
|
16 |
|
17 |
+
dfs_code = r"""
|
18 |
+
def dfs(visited, graph, node): #function for dfs
|
19 |
+
if node not in visited:
|
20 |
+
print (node)
|
21 |
+
visited.add(node)
|
22 |
+
for neighbour in graph[node]:
|
23 |
+
dfs(visited, graph, neighbour)
|
24 |
+
"""
|
25 |
+
|
26 |
function_code = r"""
|
27 |
def write_documents(self, documents: Union[List[dict], List[Document]], index: Optional[str] = None,
|
28 |
batch_size: int = 10_000, duplicate_documents: Optional[str] = None):
|
|
|
79 |
|
80 |
"""
|
81 |
|
82 |
+
# task_code = f' Summarize Python: {function_code}'
|
83 |
+
task_code = f' Summarize Python: {dfs_code}'
|
84 |
|
85 |
real_docstring = r"""
|
86 |
Indexes documents for later queries in Elasticsearch.
|
|
|
117 |
return str(output)
|
118 |
|
119 |
def pygen_func(nl_code_intent):
|
120 |
+
pass # TODO: generate code PL from intent NL + search in corpus
|
121 |
# inputs = {'code_nl': code_nl}
|
122 |
# payload = json.dumps(inputs)
|
123 |
# prediction = req.request(CT5_METHOD, CT5_URL, data=payload)
|
124 |
# prediction = req.request(CT5_METHOD, CT5_URL, json=req_data)
|
125 |
# answer = json.loads(prediction.content.decode("utf-8"))
|
126 |
# return str(answer)
|
127 |
+
# CT5_URL = "https://api-inference.huggingface.co/models/nielsr/codet5-small-code-summarization-ruby"
|
128 |
|
129 |
iface = gr.Interface(
|
130 |
# pygen_func,
|