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

Retrieval Question/Answering Example not working in 0.0.200 #6162

Closed
1 of 14 tasks
avi0gaur opened this issue Jun 14, 2023 · 5 comments
Closed
1 of 14 tasks

Retrieval Question/Answering Example not working in 0.0.200 #6162

avi0gaur opened this issue Jun 14, 2023 · 5 comments

Comments

@avi0gaur
Copy link

avi0gaur commented Jun 14, 2023

System Info

The problem seem to be in below code:

exception: dict is not iterable

Working version: langchain==0.0.164

usecase : https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html

Issue in below method:

def dict(self, **kwargs: Any) -> Dict:
    """Return a dictionary of the LLM."""
    starter_dict = dict(self._identifying_params)
    starter_dict["_type"] = self._llm_type
    return starter_dict

Who can help?

No response

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

https://python.langchain.com/en/latest/modules/chains/index_examples/vector_db_qa.html

Try these steps

Expected behavior

It should work as per the example.

@hwchase17
Copy link
Contributor

what LLM are you using?

@mukut03
Copy link

mukut03 commented Jun 15, 2023

I'd like to tackle this issue

@avi0gaur
Copy link
Author

avi0gaur commented Jun 26, 2023

What LLM are you using?

open AI's gpt 3.5.

LLM isn't the problem as it works fine by downgrading the langchain version to langchain==0.0.164.

I would urge anyone to run the above use case in the Colab notebook to see if you can replicate the issue.

The above-mentioned use case link is not available now. Is it resolved in any new version?

@avi0gaur
Copy link
Author

  File "/Users/avinashgaur/opt/anaconda3/envs/jarvis1/lib/python3.10/site-packages/langchain/llms/base.py", line 448, in dict
    starter_dict = dict(self._identifying_params)
TypeError: 'method' object is not iterable

llm/base.py

    def dict(self, **kwargs: Any) -> Dict:
        """Return a dictionary of the LLM."""
        starter_dict = dict(self._identifying_params)
        starter_dict["_type"] = self._llm_type
        return starter_dict

The problem is in the above piece of code.

@avi0gaur
Copy link
Author

I found the issue, I was creating a custom llm for calling the rest service.

class VicunaLLM_7(LLM):
    """Vicuna LLM."""

    @property
    def _llm_type(self) -> str:
        return "custom"

    def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
        """Call the LLM."""

        request = {
            "model": "fastchat-t5-3b-v1.0",
            "messages": [{"role": "user", "content": prompt}],
            "max_tokens": 1024
        }

        response = requests.post(URL_7, json=request)

        if response.status_code == 200:
            response.raise_for_status()
            result = response.json()['choices'][0]["message"]['content']
            print("llm response: \n", result)
            return result
        print()
        return None
    **@property** //This part is mandatory in the newer version > 0.0.164
    def _identifying_params(self) -> Mapping[str, Any]:
        """Get the identifying parameters."""
        return {
            "model": "fastchat-t5-3b-v1.0",
            "vicuna":"7B"
        }

Please raise the insightful exception.

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

3 participants