Skip to content

partially initialized module 'openai' has no attribute 'Completion' #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shelu16 opened this issue Dec 7, 2022 · 1 comment
Closed

Comments

@shelu16
Copy link

shelu16 commented Dec 7, 2022

python gpt2.py
Traceback (most recent call last):
File "D:\EVE_NG\gpt2.py", line 2, in
import openai
File "D:\EVE_NG\openai.py", line 8, in
response = openai.Completion.create(
^^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'openai' has no attribute 'Completion' (most likely due to a circular import)

borisdayma pushed a commit to borisdayma/openai-python that referenced this issue Dec 7, 2022
@hallacy
Copy link
Collaborator

hallacy commented Dec 11, 2022

Hi @shelu16,

Can you tell me a bit more about how you've set up the openai package? We haven't heard this issue from other users and I can't reproduce this locally.

@hallacy hallacy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2022
cgayapr pushed a commit to cgayapr/openai-python that referenced this issue Dec 14, 2024
safa0 pushed a commit to safa0/openai-agents-python that referenced this issue Apr 27, 2025
This pull request introduces functionality for visualizing agent
structures using Graphviz. The changes include adding a new dependency,
implementing functions to generate and draw graphs, and adding tests for
these functions.

New functionality for visualizing agent structures:

* Added `graphviz` as a new dependency in `pyproject.toml`.
* Implemented functions in `src/agents/visualizations.py` to generate
and draw graphs for agents using Graphviz. These functions include
`get_main_graph`, `get_all_nodes`, `get_all_edges`, and `draw_graph`.

Testing the new visualization functionality:

* Added tests in `tests/test_visualizations.py` to verify the
correctness of the graph generation and drawing functions. The tests
cover `get_main_graph`, `get_all_nodes`, `get_all_edges`, and
`draw_graph`.

For example, given the following code:

```python
from agents import Agent, function_tool
from agents.visualizations import draw_graph


@function_tool
def get_weather(city: str) -> str:
    return f"The weather in {city} is sunny."


spanish_agent = Agent(
    name="Spanish agent",
    instructions="You only speak Spanish.",
)

english_agent = Agent(
    name="English agent",
    instructions="You only speak English",
)

triage_agent = Agent(
    name="Triage agent",
    instructions="Handoff to the appropriate agent based on the language of the request.",
    handoffs=[spanish_agent, english_agent],
    tools=[get_weather],
)


draw_graph(triage_agent)
```

Generates the following image:

<img width="614" alt="Screenshot 2025-03-13 at 18 36 23"
src="https://github.com/user-attachments/assets/d01fe502-6886-4efb-aaf8-c92e4524b0fe"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants