File size: 1,742 Bytes
9d12423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
07ce0a6
9d12423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
def llm_lib_summarizer_v1(import_string: str, api_key: str, model = 'openai/gpt-oss-20b'):
    '''
    import_string: All the imports made in the notebook
    api_key: Generated groq api key
    model: choose the groq model. Default is GPT OSS
    '''
    from groq import Groq

    client = Groq(api_key=api_key)
    completion = client.chat.completions.create(
        model=model,
        messages=[
            {
                "role": "user",
                "content": f'''Assume we are in the Google colab environment and I have imported the following libraries and classes: {import_string}.
                Tell me on a high level summarize the main library packages that were imported 
                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:
                sklearn.model_selection, sklearn.metrics and sklearn.* should return only sklearn.
                
                output should always look like this:
                ```json
                    'libraries':[
                        'sklearn',
                        'pandas',
                        'numpy'....
                        ]
                ```
                Make sure to return only the json and nothing else.'''
            }
            ],
        temperature=0,
        max_completion_tokens=8192,
        top_p=1,
        reasoning_effort="medium",
        stream=True,
        stop=None
        )
    response_content = ""
    for chunk in completion:
        response_content += chunk.choices[0].delta.content or ""
    response_content = response_content.split('\n')
    response_content = ''.join(response_content[1:-1])
    return response_content