Skip to content
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

[Bug]: Error When Running the Program from the Command Line #1105

Open
suhaib0edu opened this issue Oct 6, 2024 · 1 comment
Open

[Bug]: Error When Running the Program from the Command Line #1105

suhaib0edu opened this issue Oct 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@suhaib0edu
Copy link

Version

Command-line (Python) version

Operating System

Ubuntu Linux

What happened?

Error When Running the Program

When trying to run the program using the following command:

$ python3 main.py

I received the following message:

[Pythagora] What is the project name?
> UIchatGPT
[Spec Writer] Describe your app in as much detail as possible
  [example]: Start an example project
  [import]: Import an existing project
 
#### **Integration with Third-Party Services:**
1. **OpenAI API:** The program integrates with the OpenAI API to call the artificial intelligence model and send/receive data.
2. **Authentication Using API Key:** The program requires setting the user's API key to access OpenAI services.
 
### Summary
This program is a simple yet effective application for chatting with ChatGPT, providing users with an easy and quick way to interact with the artificial intelligence model through an interactive interface.
[Spec Writer] Checking the complexity of the prompt ...

[Pythagora] Stopping Pythagora due to error:

File core/cli/main.py, line 38, in run_project
    success = await orca.run()
File core/agents/orchestrator.py, line 78, in run
    response = await agent.run()
File core/agents/spec_writer.py, line 37, in run
    return await self.initialize_spec()
File core/agents/spec_writer.py, line 74, in initialize_spec
    self.next_state.specification = self.current_state.specification.clone()
File core/db/models/specification.py, line 55, in clone
    complexity=self.complexity,
MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place? (Background on this error at: https://sqlalche.me/e/20/xd2s)

Error Details

It seems that the MissingGreenlet error indicates that there is an attempt to call an asynchronous function (await_only()) in an unexpected place, which may result from not calling greenlet_spawn in the correct context.

Note: I was working on the program through the command line only.

Request for Help

Can you help me identify the cause of this error and how to fix it? Thank you in advance for any assistance!

@suhaib0edu suhaib0edu added the bug Something isn't working label Oct 6, 2024
@donpablonows
Copy link

donpablonows commented Dec 2, 2024

core/db/models/specification.py

from copy import deepcopy
from typing import TYPE_CHECKING, Optional, List, Dict, Any

from sqlalchemy import delete, distinct, select, JSON
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, mapped_column, relationship

from core.db.models import Base

if TYPE_CHECKING:
    from core.db.models import ProjectState


class Complexity:
    """Estimate of the project or feature complexity."""

    SIMPLE = "simple"
    MODERATE = "moderate"
    HARD = "hard"


class Specification(Base):
    __tablename__ = "specifications"

    # ID and parent FKs
    id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)

    # Attributes
    original_description: Mapped[Optional[str]] = mapped_column(nullable=True)
    description: Mapped[str] = mapped_column(default="")
    template_summary: Mapped[Optional[str]] = mapped_column(nullable=True)
    architecture: Mapped[str] = mapped_column(default="")
    
    # Use JSON type for complex nested structures
    system_dependencies: Mapped[List[Dict[str, Any]]] = mapped_column(JSON, default=list)
    package_dependencies: Mapped[List[Dict[str, Any]]] = mapped_column(JSON, default=list)
    
    # Use JSON type for templates
    templates: Mapped[Optional[Dict[str, Any]]] = mapped_column(JSON, nullable=True)

    # Set a default value for complexity
    complexity: Mapped[str] = mapped_column(default=Complexity.HARD)
    example_project: Mapped[Optional[str]] = mapped_column(nullable=True)

    # Relationships
    project_states: Mapped[List["ProjectState"]] = relationship(back_populates="specification", lazy="raise")

    def clone(self) -> "Specification":
        """
        Clone the specification.
        """
        clone = Specification(
            original_description=self.original_description,
            description=self.description,
            template_summary=self.template_summary,
            architecture=self.architecture,
            system_dependencies=deepcopy(self.system_dependencies) if self.system_dependencies else [],
            package_dependencies=deepcopy(self.package_dependencies) if self.package_dependencies else [],
            templates=deepcopy(self.templates) if self.templates else None,
            complexity=self.complexity,
            example_project=self.example_project,
        )
        return clone

    @classmethod
    async def delete_orphans(cls, session: AsyncSession):
        """
        Delete Specification objects that are not referenced by any ProjectState object.

        :param session: The database session.
        """
        from core.db.models import ProjectState

        await session.execute(
            delete(Specification).where(~Specification.id.in_(select(distinct(ProjectState.specification_id))))
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants