Spaces:
Runtime error
Runtime error
Merge pull request #36 from HemanthSai7/main
Browse filesFiles changed (10)
- frontend/images/architecture.pngAdded
- frontend/images/backend.pngAdded
- frontend/images/backendss.pngAdded
- frontend/images/llms.pngAdded
- frontend/images/techdocs.pngAdded
- frontend/pages/3_π_Instructions.py β frontend/pages/2_π_Instructions.pyRenamed
- frontend/pages/2_π»_Demo.py β frontend/pages/3_π»_Demo.pyRenamed
- frontend/π‘_Home.py+43-20
- testing/DBQueries.py-48
- testing/test.py-92
1 unmodified line234567891011121314151617181920212223241 unmodified linefrom layouts.mainlayout import mainlayout@mainlayoutdef home_page():st.markdown("""##### Unleash the documentation dynamo that is **Techdocs**! Say goodbye to the documentation drudgery that haunts coders' dreams and embrace the effortless power of AI-driven documentation. With **Techdocs**, harness the genius of LLama2 π¦, the magic of WizardCoderLM π§ββοΈ, the versatility of Huggingface Transformers π€, and the precision of Langchain π¦ and Clarifai π€.""")with st.expander("What Can Techdocs Do for You? π",expanded=True):st.markdown("""- Boost your code quality effortlessly π.- Effortlessly generate documentation for your code π€.- Include comments, descriptions, parameters, return values, and real-life examples π.- Elevate your code's readability, maintainability, and quality π.#""")1 unmodified line2345678910111213141516171819202122232425262728293031323334353637383940414243444546471 unmodified linefrom layouts.mainlayout import mainlayout@mainlayoutdef home():st.subheader("Code documentation tool that works in your IDE like magic!")def changestate(*args):st.session_state[args[0]]=Truetab1, tab2, tab3 = st.tabs(["About our CLI πͺ", "Mechanics π οΈ", "LLMs toolkit ποΈ"])with tab1:st.markdown('### <div align="center">:green[Our CLI π§βπ»]</div>',unsafe_allow_html=True)st.markdown('##### <div align="center">:blue[Techdocs CLI] provides a simple and easy to use interface to generate documentation for your :blue[code].</div>',unsafe_allow_html=True)col1, col3, col2 = st.columns([4,0.1,2])with col1:st.image("frontend/images/techdocs.png")with col2:st.checkbox("##### User friendly commands\n β Easy to follow commands to generate documentation for your code.",value=True,key="feature1_a",on_change=changestate,args=("feature1_a",))st.checkbox("##### Your workbench at one place\n β Access all commands within our CLI. No need to search the app.",value=True,key="feature1_b",on_change=changestate,args=("feature1_b",))st.checkbox("##### Generated documentation will be directly embedded into your functions\n β No need to manually copy paste the documentation.",value=True,key="feature1_c",on_change=changestate,args=("feature1_c",))with tab2:st.markdown('## <div align="center">:green[API behind the Scenes βοΈ]</div>',unsafe_allow_html=True)st.markdown('#### <div align="center">:blue[CLI] uses the power of our API allowing you to access sophisticated :blue[LLM] tools effortlessly. This :blue[microservice] is deployed separately abstracting undelying complexities and providing lightweight web app and CLI </div>',unsafe_allow_html=True)col1, col3, col2 = st.columns([4,0.1,2])with col1:st.image("frontend/images/backendss.png")with col2:st.checkbox("##### API uses the magic of FastAPIβ‘\nβ FastAPI is a modern, fast (high-performance), web framework for building APIs with Python.",value=True,key="backend_a",on_change=changestate,args=("backend_a",))st.checkbox("##### Deployed on Huggingface Spaces π€\nβ Minimal user-percieved latency.",value=True,key="backend_b",on_change=changestate,args=("backend_b",))st.checkbox("##### Cloud Databases βοΈ\n β Powered by Microsoft Azure SQL",value=True,key="backend_c",on_change=changestate,args=("backend_c",))with tab3:st.markdown('### <div align="center">:green[Large Language Models π¦]</div>',unsafe_allow_html=True)st.markdown('#### <div align="center">Combines the power of Langchain and Clarifai</div>',unsafe_allow_html=True)col1, col3, col2 = st.columns([4,0.1,2])with col1:st.image("frontend/images/llms.png")with col2:st.checkbox('##### WizardLM-70B at its core π§ββοΈ.\nβ Uses WizardLM-70B LLM as an endpoint provided by Clarifiai.',value=True,key="llm_a",on_change=changestate,args=("llm_a",))st.checkbox("##### Application developed using Langchain π¦.\nβ LangChain is a framework for developing applications powered by language models.", value=True,key="llm_b",on_change=changestate,args=("llm_b",))st.markdown("## <div align='center'>Techdocs Architecture</div>",unsafe_allow_html=True)st.image("frontend/images/architecture.png")
8 unmodified lines9101112131415161718192021222324252627282930317 unmodified lines394041424344454647484950515253545556575859607 unmodified lines6869707172737475767778798081828384858687888 unmodified lines@classmethoddef insert_to_database(cls, table_name: str, data: Union[Tuple, List[Tuple]], cols: List[str]=None):"""This method is used to insert data into a specified table in the database.Args:table_name (str): The name of the table into which the data will be inserted.data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. It can be either a tuple or a list of tuples.cols (List[str], optional): A list of column names in the table. If not provided, the method will assume all columns are needed. Defaults to None.Raises:Exception: If the data type of 'data' is not a tuple or a list of tuples.Returns:None""""\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which the data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. It can be either a tuple or a list of tuples.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume all columns are needed. Defaults to None.\n\n Raises:\n Exception: If the data type of 'data' is not a tuple or a list of tuples.\n\n Returns:\n None\n ""\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which the data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. It can be either a tuple or a list of tuples.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume all columns are needed. Defaults to None.\n\n Raises:\n Exception: If the data type of 'data' is not a tuple or a list of tuples.\n\n Returns:\n None\n ""\n This method is used to insert data into a specified table in the database.\n\n Args:\n table_name (str): The name of the table into which the data will be inserted.\n data (Union[Tuple, List[Tuple]]): The data to be inserted into the table. It can be either a tuple or a list of tuples.\n cols (List[str], optional): A list of column names in the table. If not provided, the method will assume all columns are needed. Defaults to None.\n\n Raises:\n Exception: If the data type of 'data' is not a tuple or a list of tuples.\n\n Returns:\n None\n "con = DBConnection.get_client()cursor = con.cursor()QUERY = f"INSERT INTO {{table_name}} ({','.join(cols)}) VALUES ".format(table_name=table_name)7 unmodified lines@classmethoddef fetch_data_from_database(cls, table_name: str, cols_to_fetch: Union[str, List[str]], where_clause: str=None):"""This method fetches data from a specified table in the database based on the specified column(s) and optional WHERE clause.Args:table_name (str): The name of the table from which to fetch data.cols_to_fetch (Union[str, List[str]]): The column(s) to fetch from the table. Can be a single string or a list of strings.If a single string, it will be treated as a comma-separated list of columns.where_clause (str, optional): An optional WHERE clause to filter the data. Defaults to None.Returns:List[List[str]]: A list of lists, where each inner list represents a row of data fetched from the database.The order of the columns in the inner lists corresponds to the order specified in the cols_to_fetch parameter.Raises:None"""con = DBConnection.get_client()cursor = con.cursor()if isinstance(cols_to_fetch, str):7 unmodified lines@classmethoddef update_data_in_database(cls, table_name: str, cols_to_update: Union[str, List[str]], where_clause: str=None, new_values: Union[str, List[str]]=None):"""This method updates the data in the specified table in the database.Args:table_name (str): The name of the table to be updated.cols_to_update (Union[str, List[str]]): The column(s) to be updated. If a single string, it should end with '=%s'. If a list, it should contain strings representing the column names followed by '=%s'.where_clause (str, optional): The WHERE clause to specify the conditions for the update. Defaults to None.new_values (Union[str, List[str]], optional): The new values to be updated in the specified columns. If a single string, it should be a list of values. If a list, it should contain the new values for the columns. Defaults to None.Returns:bool: Returns True if the update is successful.Raises:Exception: Raises an exception if the database connection fails."""con = DBConnection.get_client()cursor = con.cursor()if isinstance(cols_to_update, str):8 unmodified lines910111213147 unmodified lines2223242526277 unmodified lines3536373839408 unmodified lines@classmethoddef insert_to_database(cls, table_name: str, data: Union[Tuple, List[Tuple]], cols: List[str]=None):con = DBConnection.get_client()cursor = con.cursor()QUERY = f"INSERT INTO {{table_name}} ({','.join(cols)}) VALUES ".format(table_name=table_name)7 unmodified lines@classmethoddef fetch_data_from_database(cls, table_name: str, cols_to_fetch: Union[str, List[str]], where_clause: str=None):con = DBConnection.get_client()cursor = con.cursor()if isinstance(cols_to_fetch, str):7 unmodified lines@classmethoddef update_data_in_database(cls, table_name: str, cols_to_update: Union[str, List[str]], where_clause: str=None, new_values: Union[str, List[str]]=None):con = DBConnection.get_client()cursor = con.cursor()if isinstance(cols_to_update, str):
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110def add(a, b):"""This function adds two numbers.Arguments:a (int): The first number to be added.b (int): The second number to be added.Returns:int: The sum of the two numbers."""'\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n ''\n This function adds two numbers.\n\n Arguments:\n a (int): The first number to be added.\n b (int): The second number to be added.\n\n Returns:\n int: The sum of the two numbers.\n 'return a + bdef multiply(a, b):"""This function multiplies two numbers.Args:a: A number to be multiplied.This should be a numeric value (int or float).b: Another number to be multiplied.This should be a numeric value (int or float).Returns:The product of the two numbers.This will be a numeric value (int or float), representing the result of the multiplication.Raises:None"""'\n This function multiplies two numbers.\n\n Args:\n a: A number to be multiplied.\n This should be a numeric value (int or float).\n b: Another number to be multiplied.\n This should be a numeric value (int or float).\n\n Returns:\n The product of the two numbers.\n This will be a numeric value (int or float), representing the result of the multiplication.\n\n Raises:\n None\n\n ''\n This function multiplies two numbers.\n\n Args:\n a: A number to be multiplied.\n b: Another number to be multiplied.\n\n Returns:\n The product of the two numbers.\n 'return a * bdef subtract(a, b):"""Subtracts the second number from the first.Args:a (int): The first number to be subtracted.b (int): The second number to be subtracted from the first.Returns:int: The result of the subtraction."""'\n Subtracts the second number from the first.\n\n Args:\n a (int): The first number to be subtracted.\n b (int): The second number to be subtracted from the first.\n\n Returns:\n int: The result of the subtraction.\n ''\ndef subtract(a, b):\n 'return a - bdef divide(a, b):"""This function divides the first argument by the second argument.Arguments:a (float): The first number to be divided.b (float): The second number to be divided.Raises:ValueError: If the second argument is zero, it raises a ValueError with the message 'Cannot divide by zero'.Returns:float: The result of the division of the first argument by the second argument.""""\n This function divides the first argument by the second argument.\n\n Arguments:\n a (float): The first number to be divided.\n b (float): The second number to be divided.\n\n Raises:\n ValueError: If the second argument is zero, it raises a ValueError with the message 'Cannot divide by zero'.\n\n Returns:\n float: The result of the division of the first argument by the second argument.\n ""\n This function divides the first argument by the second argument.\n\n Arguments:\n a -- The first number to be divided. It should be of type float.\n b -- The second number to be divided. It should be of type float.\n\n Raises:\n ValueError -- If the second argument is zero, it raises a ValueError with the message 'Cannot divide by zero'.\n\n Returns:\n float -- The result of the division of the first argument by the second argument.\n "if b == 0:raise ValueError('Cannot divide by zero')return a / bdef func(*args, **kwargs):"""This function searches for specified terms within the input string using a specified search type.Parameters:- input_string (str): The string to search within.- search_terms (list): A list of strings to search for within the input_string.- search_type (str, optional): Specifies how the search_terms should be searched within the input_string.Possible values: 'AND' (all search_terms must be present in the input_string), 'OR' (at least one search_term must be present in the input_string). Default is 'AND'.Returns:- search_results (list): A list of all occurrences of the search_terms within the input_string.Raises:- ValueError: If the search_type is not 'AND' or 'OR'.""""\nUsage: query(input_string, search_terms, search_type='AND')\n\nThis function searches for specified terms within the input string using a specified search type.\n\nParameters:\n- input_string (str): The string to search within.\n- search_terms (list): A list of strings to search for within the input_string.\n- search_type (str, optional): Specifies how the search_terms should be searched within the input_string.\n Possible values: 'AND' (all search_terms must be present in the input_string), 'OR' (at least one search_term must be present in the input_string). Default is 'AND'.\n\nReturns:\n- search_results (list): A list of all occurrences of the search_terms within the input_string.\n\nRaises:\n- ValueError: If the search_type is not 'AND' or 'OR'.\n""\nUsage: func(*args, **kwargs)\n\nThis function returns a wrapper function that calls the original function.\n\nParameters:\n- args (tuple): A tuple of non-keyworded arguments to pass to the function.\n- kwargs (dict): A dictionary of keyworded arguments to pass to the function.\n\nReturns:\n- wrapper (function): A new function that calls the original function with the given arguments.\n\nRaises:\n- TypeError: If the arguments passed to the wrapper function do not match the original function's signature.\n"def wrapper(*args, **kwargs):"""This function acts as a wrapper for another function, allowing it to be called with a variety of arguments.Arguments:*args (list): any number of positional arguments (default: None)**kwargs (dict): any number of keyword arguments (default: None)Returns:Whatever the wrapped function returns (default: None)Raises:Whatever exceptions the wrapped function raises (default: None)TypeError: If any argument is not of the expected type."""'\n This function performs a specific operation on the given arguments.\n\n Arguments:\n arg1 -- a string argument (default: None)\n arg2 -- an integer argument (default: None)\n arg3 -- a floating point number argument (default: None)\n arg4 -- a boolean argument (default: None)\n\n Returns:\n None\n\n Raises:\n TypeError -- If any argument is not of the expected type.\n ''\n This function acts as a wrapper for another function, allowing it to be called with a variety of arguments.\n\n Arguments:\n *args -- any number of positional arguments (default: None)\n **kwargs -- any number of keyword arguments (default: None)\n\n Returns:\n Whatever the wrapped function returns (default: None)\n\n Raises:\n Whatever exceptions the wrapped function raises (default: None)\n 'return func(*args, **kwargs)return wrapper123456789101112131415161718def add(a, b):return a + bdef multiply(a, b):return a * bdef subtract(a, b):return a - bdef divide(a, b):if b == 0:raise ValueError('Cannot divide by zero')return a / bdef func(*args, **kwargs):def wrapper(*args, **kwargs):return func(*args, **kwargs)return wrapper
frontend/images/architecture.pngAdded

frontend/images/backend.pngAdded

frontend/images/backendss.pngAdded

frontend/images/llms.pngAdded

frontend/images/techdocs.pngAdded

frontend/pages/3_π_Instructions.py β frontend/pages/2_π_Instructions.pyRenamed
frontend/pages/2_π»_Demo.py β frontend/pages/3_π»_Demo.pyRenamed
frontend/π‘_Home.py+43-20
testing/DBQueries.py-48
testing/test.py-92