avi-pipable
commited on
Commit
•
195089f
1
Parent(s):
a843da9
Update README.md
Browse files
README.md
CHANGED
@@ -86,8 +86,10 @@ print(doc)
|
|
86 |
## Examples
|
87 |
|
88 |
### markdown documentation format for api docs
|
|
|
|
|
89 |
```python
|
90 |
-
|
91 |
Method access
|
92 |
HTTP
|
93 |
JavaScript
|
@@ -216,7 +218,7 @@ Convert the above docs to markdown format.
|
|
216 |
|
217 |
prompt = f"""
|
218 |
<api_doc>
|
219 |
-
{
|
220 |
</api_doc>
|
221 |
<question>
|
222 |
{question}
|
@@ -230,8 +232,260 @@ doc = (
|
|
230 |
)
|
231 |
print(doc)
|
232 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
### Team
|
237 |
Avi Kothari, Pratham Gupta, Ritvik Aryan Kalra, Soham Acharya , Gyan Ranjan
|
|
|
86 |
## Examples
|
87 |
|
88 |
### markdown documentation format for api docs
|
89 |
+
|
90 |
+
#### Exmaple 1
|
91 |
```python
|
92 |
+
raw_docs = """
|
93 |
Method access
|
94 |
HTTP
|
95 |
JavaScript
|
|
|
218 |
|
219 |
prompt = f"""
|
220 |
<api_doc>
|
221 |
+
{raw_docs}
|
222 |
</api_doc>
|
223 |
<question>
|
224 |
{question}
|
|
|
232 |
)
|
233 |
print(doc)
|
234 |
```
|
235 |
+
#### Exmaple 2
|
236 |
+
|
237 |
+
```python
|
238 |
+
raw_docs = """
|
239 |
+
Method access
|
240 |
+
HTTP
|
241 |
+
JavaScript
|
242 |
+
Python
|
243 |
+
Java
|
244 |
+
GET
|
245 |
+
https://slack.com/api/users.list
|
246 |
+
Required scopes
|
247 |
+
Bot tokens
|
248 |
+
users:read
|
249 |
+
User tokens
|
250 |
+
users:read
|
251 |
+
Legacy bot tokens
|
252 |
+
bot
|
253 |
+
Content types
|
254 |
+
application/x-www-form-urlencoded
|
255 |
+
Rate limits
|
256 |
+
Tier 2
|
257 |
+
Arguments
|
258 |
+
Required arguments
|
259 |
+
token
|
260 |
+
token
|
261 |
+
·Required
|
262 |
+
Authentication token bearing required scopes. Tokens should be passed as an HTTP Authorization header or alternatively, as a POST parameter.
|
263 |
+
|
264 |
+
Example
|
265 |
+
xxxx-xxxxxxxxx-xxxx
|
266 |
+
Optional arguments
|
267 |
+
cursor
|
268 |
+
string
|
269 |
+
·Optional
|
270 |
+
Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first "page" of the collection. See pagination for more detail.
|
271 |
+
|
272 |
+
Example
|
273 |
+
dXNlcjpVMDYxTkZUVDI=
|
274 |
+
include_locale
|
275 |
+
boolean
|
276 |
+
·Optional
|
277 |
+
Set this to true to receive the locale for users. Defaults to false
|
278 |
+
|
279 |
+
Example
|
280 |
+
true
|
281 |
+
limit
|
282 |
+
number
|
283 |
+
·Optional
|
284 |
+
The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the users list hasn't been reached. Providing no limit value will result in Slack attempting to deliver you the entire result set. If the collection is too large you may experience limit_required or HTTP 500 errors.
|
285 |
+
|
286 |
+
Default
|
287 |
+
0
|
288 |
+
Example
|
289 |
+
20
|
290 |
+
team_id
|
291 |
+
string
|
292 |
+
·Optional
|
293 |
+
encoded team id to list users in, required if org token is used
|
294 |
+
|
295 |
+
Example
|
296 |
+
T1234567890
|
297 |
+
"""
|
298 |
+
|
299 |
+
question = """
|
300 |
+
Parse the docs to openapi json format.
|
301 |
+
"""
|
302 |
+
|
303 |
+
prompt = f"""
|
304 |
+
<api_doc>
|
305 |
+
{raw_docs}
|
306 |
+
</api_doc>
|
307 |
+
<question>
|
308 |
+
{question}
|
309 |
+
</question>
|
310 |
+
<json>
|
311 |
+
"""
|
312 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
313 |
+
outputs = model.generate(**inputs, max_new_tokens=1800)
|
314 |
+
doc = (
|
315 |
+
tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True)
|
316 |
+
)
|
317 |
+
print(doc)
|
318 |
+
```
|
319 |
+
#### Example 4
|
320 |
+
|
321 |
+
```python
|
322 |
+
docs = """
|
323 |
+
{
|
324 |
+
"openapi": "3.0.0",
|
325 |
+
"info": {
|
326 |
+
"version": "1.0.0",
|
327 |
+
"title": "Slack API",
|
328 |
+
"description": "API for Slack",
|
329 |
+
"termsOfService": "https://slack.com/terms-of-service",
|
330 |
+
"contact": {
|
331 |
+
"name": "Slack",
|
332 |
+
"url": "https://slack.com",
|
333 |
+
"email": "support@slack.com"
|
334 |
+
},
|
335 |
+
"license": {
|
336 |
+
"name": "Apache 2.0",
|
337 |
+
"url": "https://www.apache.org/licenses/LICENSE-2.0"
|
338 |
+
}
|
339 |
+
},
|
340 |
+
"servers": [
|
341 |
+
{
|
342 |
+
"url": "https://slack.com/api",
|
343 |
+
"description": "API server"
|
344 |
+
}
|
345 |
+
],
|
346 |
+
"paths": {
|
347 |
+
"/chat/postMessage": {
|
348 |
+
"post": {
|
349 |
+
"description": "Send a message to a channel or user",
|
350 |
+
"parameters": [
|
351 |
+
{
|
352 |
+
"name": "token",
|
353 |
+
"in": "query",
|
354 |
+
"required": true,
|
355 |
+
"description": "Bot token or user token",
|
356 |
+
"schema": {
|
357 |
+
"type": "string"
|
358 |
+
}
|
359 |
+
},
|
360 |
+
{
|
361 |
+
"name": "channel",
|
362 |
+
"in": "query",
|
363 |
+
"required": true,
|
364 |
+
"description": "The ID of the channel or user to send the message to",
|
365 |
+
"schema": {
|
366 |
+
"type": "string"
|
367 |
+
}
|
368 |
+
},
|
369 |
+
{
|
370 |
+
"name": "text",
|
371 |
+
"in": "query",
|
372 |
+
"required": true,
|
373 |
+
"description": "The message content",
|
374 |
+
"schema": {
|
375 |
+
"type": "string"
|
376 |
+
}
|
377 |
+
},
|
378 |
+
{
|
379 |
+
"name": "as_user",
|
380 |
+
"in": "query",
|
381 |
+
"required": false,
|
382 |
+
"description": "Pass true to post the message as the authed user instead of as a bot",
|
383 |
+
"schema": {
|
384 |
+
"type": "boolean"
|
385 |
+
}
|
386 |
+
},
|
387 |
+
{
|
388 |
+
"name": "icon_emoji",
|
389 |
+
"in": "query",
|
390 |
+
"required": false,
|
391 |
+
"description": "Emoji to use as the icon for this message",
|
392 |
+
"schema": {
|
393 |
+
"type": "string"
|
394 |
+
}
|
395 |
+
},
|
396 |
+
{
|
397 |
+
"name": "icon_url",
|
398 |
+
"in": "query",
|
399 |
+
"required": false,
|
400 |
+
"description": "URL to an image to use as the icon for this message",
|
401 |
+
"schema": {
|
402 |
+
"type": "string"
|
403 |
+
}
|
404 |
+
},
|
405 |
+
{
|
406 |
+
"name": "link_names",
|
407 |
+
"in": "query",
|
408 |
+
"required": false,
|
409 |
+
"description": "Find and link user groups. No longer supports linking individual users; use syntax shown in Mentioning Users instead",
|
410 |
+
"schema": {
|
411 |
+
"type": "boolean"
|
412 |
+
}
|
413 |
+
},
|
414 |
+
{
|
415 |
+
"name": "unfurl_links",
|
416 |
+
"in": "query",
|
417 |
+
"required": false,
|
418 |
+
"description": "Pass true to enable unfurling of primarily text-based content",
|
419 |
+
"schema": {
|
420 |
+
"type": "boolean"
|
421 |
+
}
|
422 |
+
},
|
423 |
+
{
|
424 |
+
"name": "unfurl_media",
|
425 |
+
"in": "query",
|
426 |
+
"required": false,
|
427 |
+
"description": "Pass false to disable unfurling of media content",
|
428 |
+
"schema": {
|
429 |
+
"type": "boolean"
|
430 |
+
}
|
431 |
+
},
|
432 |
+
{
|
433 |
+
"name": "username",
|
434 |
+
"in": "query",
|
435 |
+
"required": false,
|
436 |
+
"description": "Set your bot's user name",
|
437 |
+
"schema": {
|
438 |
+
"type": "string"
|
439 |
+
}
|
440 |
+
}
|
441 |
+
],
|
442 |
+
"responses": {
|
443 |
+
"200": {
|
444 |
+
"description": "OK",
|
445 |
+
"schema": {
|
446 |
+
"type": "string"
|
447 |
+
}
|
448 |
+
}
|
449 |
+
}
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
}
|
454 |
|
455 |
|
456 |
+
instructions = f"""
|
457 |
+
- Use base url: "https://slack.com/api"
|
458 |
+
- Use above api docs.
|
459 |
+
- Use and import requests library.
|
460 |
+
- strictly show the reponse in code.
|
461 |
+
"""
|
462 |
+
|
463 |
+
question = """
|
464 |
+
Send message 'Hi, please do check the https://pipable.ai', to channel '@general'.
|
465 |
+
Use token as 'xoxb-123123123123-12312312312312-XxxxxxXXxxxx'
|
466 |
+
""""
|
467 |
|
468 |
+
prompt = f"""
|
469 |
+
<docs>
|
470 |
+
{docs}
|
471 |
+
</docs>
|
472 |
+
<instructions>
|
473 |
+
{instructions}
|
474 |
+
</instructions>
|
475 |
+
<question>
|
476 |
+
Write a python code for question:
|
477 |
+
{question}
|
478 |
+
</question>
|
479 |
+
<python_code>
|
480 |
+
"""
|
481 |
+
|
482 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
483 |
+
outputs = model.generate(**inputs, max_new_tokens=500)
|
484 |
+
code = (
|
485 |
+
tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True)
|
486 |
+
)
|
487 |
+
print(code)
|
488 |
+
|
489 |
+
```
|
490 |
### Team
|
491 |
Avi Kothari, Pratham Gupta, Ritvik Aryan Kalra, Soham Acharya , Gyan Ranjan
|