groq / groq-python

The official Python Library for the Groq API
Apache License 2.0
353 stars 23 forks source link

Import Error with example code. #34

Closed hustshawn closed 4 months ago

hustshawn commented 4 months ago

Example code

import os

from groq import Groq

client = Groq(
    api_key=os.environ.get("GROQ_API_KEY"),
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Explain the importance of fast language models",
        }
    ],
    model="mixtral-8x7b-32768",
)

print(chat_completion.choices[0].message.content)

after pip install, and run the code, will face below error. Tested same with Python 3.8 and 3.11

ImportError: cannot import name 'Groq' from partially initialized module 'groq' (most likely due to a circular import)
gradenr commented 4 months ago

You probably put the code in a file named groq.py, which shadows the groq module. Try changing the name of your sample file and running the code again.

hustshawn commented 4 months ago

ah, you are right. Thank you.