Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

No attribute 'prompt' and 'num_samples' #1003

@YeonwooSung

Description

@YeonwooSung

When running the server by python3 torchchat.py server llama3.1, I was facing with the following error:

Traceback (most recent call last):
  File "/Users/ywsung/OpenSources/torchchat/torchchat.py", line 84, in <module>
    server_main(args)
  File "/Users/ywsung/OpenSources/torchchat/server.py", line 85, in main
    gen = initialize_generator(args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ywsung/OpenSources/torchchat/server.py", line 69, in initialize_generator
    generator_args = GeneratorArgs.from_args(args)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ywsung/OpenSources/torchchat/generate.py", line 113, in from_args
    prompt=args.prompt,
           ^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'prompt'

The reason of the error seems like that the "generate config" requires prompt.
And as you could see below, the server script internally initializes the GeneratorArgs instance by calling GeneratorArgs.from_args(args):

# Add CLI Args specific to user prompted generation
# Include prompt and num_sample args when the subcommand is generate
def _add_generation_args(parser, verb: str) -> None:
    generator_parser = parser.add_argument_group(
        "Generation", "Configs for generating output based on provided prompt"
    )

    if verb == "generate":
        generator_parser.add_argument(
            "--prompt",
            type=str,
            default="Hello, my name is",
            help="Input prompt for manual output generation",
        )
        generator_parser.add_argument(
            "--num-samples",
            type=int,
            default=1,
            help="Number of samples",
        )

Also, it not only 'prompt' but also 'num_samples' is empty..

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions