Python_library_installer / src /library_summarizer.py
mohith96's picture
Update src/library_summarizer.py
07ce0a6 verified
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