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

TypeError: 'type' object is not subscriptable #325

Open
Souryadipstan opened this issue Sep 6, 2023 · 1 comment
Open

TypeError: 'type' object is not subscriptable #325

Souryadipstan opened this issue Sep 6, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@Souryadipstan
Copy link
Contributor

Getting this while importing OpenAIInstructionParser, TaskType


TypeError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from prompt2model.prompt_parser import OpenAIInstructionParser, TaskType
3 prompt_spec = OpenAIInstructionParser(task_type=TaskType.TEXT_GENERATION)
4 prompt_spec.parse_from_prompt(prompt)

File ~/.pyenv/versions/3.8.17/lib/python3.8/site-packages/prompt2model/prompt_parser/init.py:3
1 """Import PromptSpec classes."""
2 from prompt2model.prompt_parser.base import PromptSpec, TaskType
----> 3 from prompt2model.prompt_parser.instr_parser import OpenAIInstructionParser
4 from prompt2model.prompt_parser.mock import MockPromptSpec
6 all = (
7 "PromptSpec",
8 "TaskType",
9 "MockPromptSpec",
10 "OpenAIInstructionParser",
11 )

File ~/.pyenv/versions/3.8.17/lib/python3.8/site-packages/prompt2model/prompt_parser/instr_parser.py:15
10 from prompt2model.prompt_parser.base import PromptSpec, TaskType
12 from prompt2model.prompt_parser.instr_parser_prompt import ( # isort: split
13 construct_prompt_for_instruction_parsing,
14 )
---> 15 from prompt2model.utils import (
16 OPENAI_ERRORS,
17 ChatGPTAgent,
18 get_formatted_logger,
19 handle_openai_error,
20 )
22 logger = get_formatted_logger("PromptParser")
24 os.environ["TOKENIZERS_PARALLELISM"] = "false"

File ~/.pyenv/versions/3.8.17/lib/python3.8/site-packages/prompt2model/utils/init.py:10
3 from prompt2model.utils.openai_tools import (
4 OPENAI_ERRORS,
5 ChatGPTAgent,
6 count_tokens_from_string,
7 handle_openai_error,
8 )
9 from prompt2model.utils.rng import seed_generator
---> 10 from prompt2model.utils.tevatron_utils import encode_text, retrieve_objects
12 all = ( # noqa: F401
13 "ChatGPTAgent",
14 "encode_text",
(...)
20 "get_formatted_logger",
21 )

File ~/.pyenv/versions/3.8.17/lib/python3.8/site-packages/prompt2model/utils/tevatron_utils/init.py:3
1 """Import Tevatron utility functions."""
2 from prompt2model.utils.tevatron_utils.encode import encode_text
----> 3 from prompt2model.utils.tevatron_utils.retrieve import retrieve_objects
5 all = ("encode_text", "retrieve_objects")

File ~/.pyenv/versions/3.8.17/lib/python3.8/site-packages/prompt2model/utils/tevatron_utils/retrieve.py:11
4 import numpy as np
5 from tevatron.faiss_retriever import BaseFaissIPRetriever
8 def retrieve_objects(
9 query_vector: np.ndarray,
10 encoded_datasets_path: str,
---> 11 document_names: list[str],
12 depth: int,
13 ) -> list[tuple[str, float]]:
14 """Return a ranked list of object indices and their scores.
15
16 Args:
(...)
22 Ranked list of object names and their inner product similarity to the query.
23 """
24 assert query_vector.shape[0] == 1, "Only a single query vector is expected."

TypeError: 'type' object is not subscriptable

@neubig neubig added the bug Something isn't working label Sep 6, 2023
@neubig
Copy link
Collaborator

neubig commented Sep 6, 2023

Thank you for finding this and sending a fix @Souryadipstan !

This should have been caught through our automatic tests, but it wasn't for some reason. So I'd like to keep it open even after the original PR is merged so we can add tests.

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