CoolFace
Apppublic

B2BEnterprise/Python_library_installer

sourceHugging Faceapache-2.0updated 10mo agoView on Hugging Face
0likes
library_summarizer.py43 linesDownload Raw Back to src
1def llm_lib_summarizer_v1(import_string: str, api_key: str, model = 'openai/gpt-oss-20b'):2    '''3    import_string: All the imports made in the notebook4    api_key: Generated groq api key5    model: choose the groq model. Default is GPT OSS6    '''7    from groq import Groq8 9    client = Groq(api_key=api_key)10    completion = client.chat.completions.create(11        model=model,12        messages=[13            {14                "role": "user",15                "content": f'''Assume we are in the Google colab environment and I have imported the following libraries and classes: {import_string}.16                Tell me on a high level summarize the main library packages that were imported 17                and the other major packages that are dependant on these libraries even if they are not imported. Give the output as a json. For example:18                sklearn.model_selection, sklearn.metrics and sklearn.* should return only sklearn.19                20                output should always look like this:21                ```json22                    'libraries':[23                        'sklearn',24                        'pandas',25                        'numpy'....26                        ]27                ```28                Make sure to return only the json and nothing else.'''29            }30            ],31        temperature=0,32        max_completion_tokens=8192,33        top_p=1,34        reasoning_effort="medium",35        stream=True,36        stop=None37        )38    response_content = ""39    for chunk in completion:40        response_content += chunk.choices[0].delta.content or ""41    response_content = response_content.split('\n')42    response_content = ''.join(response_content[1:-1])43    return response_content