Views
No views yet
1from pip_library_etl import PipEtl
2
3generator = PipEtl(device="cloud")1{
2 "model_name": "PipableAI/pip-library-etl-1.3b",
3 "prompt": "prompt",
4 "max_new_tokens": "400"
5}1curl -X 'POST' \
2 'https://playground.pipable.ai/infer' \
3 -H 'accept: application/json' \
4 -H 'Content-Type: application/x-www-form-urlencoded' \
5 -d 'model_name=PipableAI%2Fpip-library-etl-1.3b&prompt="YOUR PROMPT"&max_new_tokens=400'Function Call Generation : The generate_function_call method facilitates the generation of Python function calls based on provided questions and either docstrings or undocumented code. This feature can be useful for generating example function calls or for prototyping code snippets.Automated Documentation Generation : With the generate_docstring method, users can automatically generate comprehensive docstrings for Python functions. This feature aids in maintaining well-documented codebases and adhering to best practices.Module Documentation : The generate_module_docstrings method allows for generating documentation for all methods and functions within a given module or package. This capability streamlines the documentation process, especially for large codebases with numerous functions.SQL Query Generation : Users can leverage the generate_sql method to automatically generate SQL queries based on provided schemas and questions. This functionality simplifies the process of creating SQL queries, particularly for data-related tasks.pip install transformers1prompt = f"""<example_response>{--question , --query}</example_response><function_code>{code}</function_code>
2<question>Give one line description of the python code above in natural language.</question>
3<doc>"""
4
5prompt = f"""<example_response>{example of some --question: , --query}</example_response><schema>{schema with cols described}</schema>
6<question>Write a sql query to ....</question>
7<sql>"""1from transformers import AutoModelForCausalLM, AutoTokenizer
2device = "cuda"
3model = AutoModelForCausalLM.from_pretrained("PipableAI/pip-library-etl-1.3b").to(device)
4tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-library-etl-1.3b")
5prompt = f"""
6<example_response>
7--code:def divide_by_two(x: float) -> float: return x / 2
8--question:Document the python code above giving function description ,parameters and return type and example on how to call the function
9--doc:
10Description: This function divides a given number by 2.
11Parameters:
12- x (float): The input value to be divided by 2.
13Returns:
14- float: The result of x divided by 2.
15Example:
16divide_by_two(1.0)
17</example_response>
18<function_code>
19def download_file(shared_url, destination):
20 try:
21 if not shared_url.startswith("https://drive.google.com"):
22 raise ValueError("Please provde a valid google drive link.")
23 file_id = shared_url.split("/d/")[1]
24 file_id = file_id.split("/")[0]
25 url = f"https://drive.google.com/uc?id={file_id}"
26 gdown.download(url, destination, quiet=False)
27 except Exception as e:
28 print(f"Error downloading file from Google Drive as {e}")
29 raise e
30</function_code>
31<instructions>
321. In the examples while calling function use the name mentioned after `def ` in the above function_code.
332. In the generated docs use valid python type hints as per PEP 484.
34</instructions>
35<question>Document the python code above giving function description ,parameters and return type and example how to call the function.</question>
36<doc>
37"""
38inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
39outputs = model.generate(**inputs, max_new_tokens=450)
40doc = (
41 tokenizer.decode(outputs[0], skip_special_tokens=True)
42 .split("<doc>")[-1]
43 .split("</doc>")[0]
44)
45doc = (
46 doc.replace("<p>", "")
47 .replace("</p>", "")
48 .replace("<function_description>", "")
49 .replace("</function_description>", "")
50)
51print(doc)1prompt ='''<example_response>
2--code:def divide_by_two(x: float) -> float: return x / 2
3--question:Document the python code above giving function description ,parameters and return type and example on how to call the function
4--doc:
5Description: This function divides a given number by 2.
6Parameters:
7- x (float): The input value to be divided by 2.
8Returns:
9- float: The result of x divided by 2.
10Example:
11divide_by_two(1.0)
12</example_response>
13<function_code>def _plot_bounding_polygon(
14 polygons_coordinates, output_html_path="bounding_polygon_map.html"
15):
16 # Create a Folium map centered at the average coordinates of all bounding boxes
17 map_center = [
18 sum(
19 [
20 coord[0]
21 for polygon_coords in polygons_coordinates
22 for coord in polygon_coords
23 ]
24 )
25 / sum([len(polygon_coords) for polygon_coords in polygons_coordinates]),
26 sum(
27 [
28 coord[1]
29 for polygon_coords in polygons_coordinates
30 for coord in polygon_coords
31 ]
32 )
33 / sum([len(polygon_coords) for polygon_coords in polygons_coordinates]),
34 ]
35
36 my_map = folium.Map(location=map_center, zoom_start=12)
37
38 # Add each bounding polygon to the map
39 for polygon_coords in polygons_coordinates:
40 folium.Polygon(
41 locations=polygon_coords,
42 color="blue",
43 fill=True,
44 fill_color="blue",
45 fill_opacity=0.2,
46 ).add_to(my_map)
47
48 # Add bounding boxes as markers to the map
49 marker_cluster = MarkerCluster().add_to(my_map)
50
51 for polygon_coords in polygons_coordinates:
52 for coord in polygon_coords:
53 folium.Marker(
54 location=[coord[0], coord[1]], popup=f"Coordinates: {coord}"
55 ).add_to(marker_cluster)
56
57 # Add draw control to allow users to draw additional polygons
58 draw = Draw(export=True)
59 draw.add_to(my_map)
60
61 # Save the map as an HTML file
62 my_map.save(output_html_path)
63
64 return output_html_path
65 </function_code>
66 <instructions>
67 1. In the examples while calling function use the name mentioned after `def ` in the above function_code.
68 2. In the generated docs use valid python type hints as per PEP 484.
69 </instructions>
70 <question>Document the python code above giving function description ,parameters and return type and example how to call the function</question><doc>'''1 Description:This function generates a map of the bounding polygons and saves it as an HTML file.
2 Parameters:
3 - polygons_coordinates (list of lists of tuples): A list of lists of tuples representing the coordinates of the polygons. Each polygon is a list of coordinates.
4 - output_html_path (str, optional): The path where the HTML file should be saved. Defaults to "bounding_polygon_map.html".
5 Returns:
6 - str: The path to the saved HTML file.
7 Example:
8 To call the function, use the following code:
9 plot_bounding_polygon([[(0, 0), (1, 0), (1, 1), (0, 1)], [(2, 2), (3, 2), (3, 3), (2, 3)]], "my_map.html").1prompt = """Generate a simple SQL query from the schema mentioned for the following question.
2<schema>
3CREATE TABLE department (
4 Department_ID number, -- Unique identifier for the department
5 Name text, -- Name of the department
6 Creation text, -- Date of creation or establishment
7 Ranking number, -- Ranking of the department
8 Budget_in_Billions number, -- Budget of the department in billions
9 Num_Employees number -- Number of employees in the department
10);
11
12CREATE TABLE head (
13 head_ID number, -- Unique identifier for the head
14 name text, -- Name of the head
15 born_state text, -- State where the head was born
16 age number -- Age of the head
17);
18
19CREATE TABLE management (
20 department_ID number, -- Foreign key referencing Department_ID in department table
21 head_ID number, -- Foreign key referencing head_ID in head table
22 temporary_acting text -- Indicates if the head is temporarily acting
23);
24</schema>
25<question>What are the names of the heads who are born outside the California state?</question>
26<sql>
27"""SELECT head.name FROM head WHERE head.born_state <> 'California';1prompt = """Generate the SQL query for SkySQL performance schema for the following question.
2<example>
3--question: What are the top 10 most frequently used queries/statements?
4--sql: SELECT DIGEST_TEXT, COUNT(*) as frequency FROM performance_schema.events_statements_summary_by_digest GROUP BY DIGEST_TEXT ORDER BY frequency DESC LIMIT 10;
5</example>
6<schema>
7CREATE TABLE `accounts` (`USER` char(128) DEFAULT NULL -- 'The connection''s client user name for the connection, or NULL if an internal thread.',
8 `HOST` char(255) DEFAULT NULL -- 'The connection client''s host name, or NULL if an internal thread.',
9 `CURRENT_CONNECTIONS` bigint(20) NOT NULL -- 'Current connections for the account.',\n
10 `TOTAL_CONNECTIONS` bigint(20) NOT NULL -- 'Total connections for the account.'
11) ;
12</schema>
13<question>
14Tell me the number of active connections each user has.
15</question>
16<sql>
17"""SELECT USER, CURRENT_CONNECTIONS FROM accounts;1prompt = """Generate the SQL query for SkySQL performance schema for the following question.
2<example>
3--question: What are the top 10 most frequently used queries/statements?
4--sql: SELECT DIGEST_TEXT, COUNT(*) as frequency FROM performance_schema.events_statements_summary_by_digest GROUP BY DIGEST_TEXT ORDER BY frequency DESC LIMIT 10;
5</example>
6<schema>
7CREATE TABLE `file_summary_by_instance` (
8 `FILE_NAME` varchar(512) NOT NULL -- 'File name.',
9 `EVENT_NAME` varchar(128) NOT NULL -- 'Event name.',
10 `OBJECT_INSTANCE_BEGIN` bigint(20) unsigned NOT NULL -- 'Address in memory. Together with FILE_NAME and EVENT_NAME uniquely identifies a row.',
11 `COUNT_STAR` bigint(20) unsigned NOT NULL -- 'Number of summarized events',
12 `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL -- 'Total wait time of the summarized events that are timed.',
13 `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL -- 'Minimum wait time of the summarized events that are timed.',
14 `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL -- 'Average wait time of the summarized events that are timed.',
15 `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL -- 'Maximum wait time of the summarized events that are timed.',
16 `COUNT_READ` bigint(20) unsigned NOT NULL -- 'Number of all read operations, including FGETS, FGETC, FREAD, and READ.',
17 `SUM_TIMER_READ` bigint(20) unsigned NOT NULL -- 'Total wait time of all read operations that are timed.',
18 `MIN_TIMER_READ` bigint(20) unsigned NOT NULL -- 'Minimum wait time of all read operations that are timed.',
19 `AVG_TIMER_READ` bigint(20) unsigned NOT NULL -- 'Average wait time of all read operations that are timed.',
20 `MAX_TIMER_READ` bigint(20) unsigned NOT NULL -- 'Maximum wait time of all read operations that are timed.',
21 `SUM_NUMBER_OF_BYTES_READ` bigint(20) NOT NULL -- 'Bytes read by read operations.',
22 `COUNT_WRITE` bigint(20) unsigned NOT NULL -- 'Number of all write operations, including FPUTS, FPUTC, FPRINTF, VFPRINTF, FWRITE, and PWRITE.',
23 `SUM_TIMER_WRITE` bigint(20) unsigned NOT NULL -- 'Total wait time of all write operations that are timed.',
24 `MIN_TIMER_WRITE` bigint(20) unsigned NOT NULL -- 'Minimum wait time of all write operations that are timed.',
25 `AVG_TIMER_WRITE` bigint(20) unsigned NOT NULL -- 'Average wait time of all write operations that are timed.',
26 `MAX_TIMER_WRITE` bigint(20) unsigned NOT NULL -- 'Maximum wait time of all write operations that are timed.',
27 `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) NOT NULL -- 'Bytes written by write operations.',
28 `COUNT_MISC` bigint(20) unsigned NOT NULL -- 'Number of all miscellaneous operations not counted above, including CREATE, DELETE, OPEN, CLOSE, STREAM_OPEN, STREAM_CLOSE, SEEK, TELL, FLUSH, STAT, FSTAT, CHSIZE, RENAME, and SYNC.',
29 `SUM_TIMER_MISC` bigint(20) unsigned NOT NULL -- 'Total wait time of all miscellaneous operations that are timed.',
30 `MIN_TIMER_MISC` bigint(20) unsigned NOT NULL -- 'Minimum wait time of all miscellaneous operations that are timed.',
31 `AVG_TIMER_MISC` bigint(20) unsigned NOT NULL -- 'Average wait time of all miscellaneous operations that are timed.',
32 `MAX_TIMER_MISC` bigint(20) unsigned NOT NULL -- 'Maximum wait time of all miscellaneous operations that are timed.'
33 );
34</schema>
35<question>
36List out 10 names of the files with the most read and writes
37</question>
38<sql>
39"""SELECT FILE_NAME FROM file_summary_by_instance ORDER BY SUM_NUMBER_OF_BYTES_READ DESC, SUM_NUMBER_OF_BYTES_WRITE DESC LIMIT 10;1prompt = """
2Give a function call in python langugae for the following question:
3<example_response>
4--doc: Description: This function logs a curl command in debug mode.
5Parameters:
6- method (str): The HTTP method to use for the request.
7- url (str): The URL to send the request to.
8- data (dict, optional): The data to send in the request. Defaults to None.
9- headers (dict, optional): The headers to send with the request. Defaults to None.
10- level (int, optional): The log level to use for this log message. Defaults to logging.DEBUG.
11Returns:
12- None
13Example:
14log_curl_debug('GET', 'https://example.com')
15--question: log a curl PUT request for url https://web.io/
16--function_call: log_curl_debug(method='PUT', url = 'https://web.io')
17</example_response>
18<doc>
19Function Name: make_get_req()
20Description: This function is used to make a GET request.
21Parameters:
22- path (str): The path of the URL to be requested.
23- data (dict): The data to be sent in the body of the request.
24- flags (dict): The flags to be sent in the request.
25- params (dict): The parameters to be sent in the request.
26- headers (dict): The headers to be sent in the request.
27- not_json_response (bool): OPTIONAL: If set to True, the function will return the raw response content instead of trying to parse it as JSON.
28- trailing (str): OPTIONAL: For wrapping slash symbol in the end of string.
29- absolute (bool): OPTIONAL: If set to True, the function will not prefix the URL with the base URL.
30- advanced_mode (bool): OPTIONAL: If set to True, the function will return the raw response instead of trying to parse it as JSON.
31Returns:
32- Union[str, dict, list, None]: The response content as a string, a dictionary, a list, or None if the response was not successful.
33</doc>
34<instruction>
351. Strictly use named parameters mentioned in the doc to generate function calls.
362. Only return the response as python parsable string version of function call.
373. mention the 'self' parameter if required.
38</instruction>
39<question>
40Make a GET request for the URL parameter using variable_2. For the params parameter, use 'weight' as one of the keys with variable_3 as its value, and 'width' as another key with a value of 10. For the data parameter, use variable_1. Prefix the URL with the base URL, and ensure the response is in raw format.
41</question>
42<function_call>
43"""make_get_req(path='https://example.com/api/v1/users', data=variable_1, params={'weight': variable_3, 'width': 10}, headers={'Content-Type': 'application/json'}, not_json_response=True, absolute=True)1prompt = """
2Give only function call in python langugae as response for the following question:
3<example_response>
4--doc:
5Function:
6Help on function head in module pandas.core.generic:
7
8head(self, n: 'int' = 5) -> 'Self'
9Return the first `n` rows.
10
11This function returns the first `n` rows for the object based
12on position. It is useful for quickly testing if your object
13has the right type of data in it.
14
15For negative values of `n`, this function returns all rows except
16the last `|n|` rows, equivalent to ``df[:n]``.
17
18If n is larger than the number of rows, this function returns all rows.
19
20Parameters
21----------
22n : int, default 5
23Number of rows to select.
24
25Returns
26-------
27same type as caller
28The first `n` rows of the caller object.
29
30See Also
31--------
32DataFrame.tail: Returns the last `n` rows.
33
34Examples
35--------
36>>> df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
37... 'monkey', 'parrot', 'shark', 'whale', 'zebra']})
38>>> df
39animal
400 alligator
41
42--question: Get the top 5 rows with the highest Engagement_Score. Parameter Description: Use 5 as Number of rows to return ,Use variable_3 as Sorted DataFrame, Do not call any other function, Pass variable to self parameter for method calls
43--function_call: head(self=variable_3, n=5)
44</example_response>
45<doc>
46Function: sort_values
47sort_values in module pandas.core.frame:
48sort_values(self, by: 'IndexLabel', *, axis: 'Axis' = 0, ascending: 'bool | list[bool] | tuple[bool, ...]' = True, inplace: 'bool' = False, kind: 'SortKind' = 'quicksort', na_position: 'str' = 'last', ignore_index: 'bool' = False, key: 'ValueKeyFunc | None' = None) -> 'DataFrame | None'
49Sort by the values along either axis.
50Parameters
51----------
52by : str or list of str
53Name or list of names to sort by.
54
55- if `axis` is 0 or `'index'` then `by` may contain index
56levels and/or column labels.
57- if `axis` is 1 or `'columns'` then `by` may contain column
58levels and/or index labels.
59axis : "{0 or 'index', 1 or 'columns'}", default 0
60Axis to be sorted.
61ascending : bool or list of bool, default True
62Sort ascending vs. descending. Specify list for multiple sort
63orders. If this is a list of bools, must match the length of
64the
65</doc>
66<instruction>
671. Strictly use named parameters mentioned in the doc to generate function calls.
682. Only return the response as python parsable string version of function call.
693. Use the 'self' parameter if required in the function call with it's value in named keyword format.
70</instruction>
71<question>
72Using the above function, Sort the DataFrame by the Engagement_Score in descending order. Parameter Description: Use Engagement_Score as Column name to sort by ,Use False as Sort in descending order ,Use variable_1 as DataFrame to sort, Do not call any other function, Pass variable to self parameter for method calls
73</question>
74<function_call>
75"""sort_values(self=variable_1, by='Engagement_Score', ascending=False)