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

running into issues using the langchain on text-davinci-003 model #312

Closed
mmoya91 opened this issue Oct 2, 2023 · 4 comments
Closed

running into issues using the langchain on text-davinci-003 model #312

mmoya91 opened this issue Oct 2, 2023 · 4 comments
Labels
feat/model Feature: models third party Third-party software (integrations etc.)

Comments

@mmoya91
Copy link

mmoya91 commented Oct 2, 2023

I'm trying to use the text-davinci-003 model using the following config.cfg

[nlp]
lang = "en"
pipeline = ["llm"]

[components]

[components.llm]
factory = "llm"

[components.llm.task]
@llm_tasks = "spacy.TextCat.v3"
labels = ["COMPLIMENT", "INSULT"]

[components.llm.model]
@llm_models = "langchain.AzureOpenAI.v1"
name = "text-davinci-003"

but I'm running into

  File "/Users/mariamoya/mlplatform/lib/document_classifier/src/document_classifier/test-spacy-llm.py", line 5, in <module>
    doc = nlp("You look gorgeous!")
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/spacy/language.py", line 1047, in __call__
    error_handler(name, proc, [doc], e)
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/spacy/util.py", line 1724, in raise_error
    raise e
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/spacy/language.py", line 1042, in __call__
    doc = proc(doc, **component_cfg.get(name, {}))  # type: ignore[call-arg]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/spacy_llm/pipeline/llm.py", line 156, in __call__
    docs = self._process_docs([doc])
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/spacy_llm/pipeline/llm.py", line 210, in _process_docs
    responses_iters = tee(self._model(prompts_iters[0]), n_iters)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/spacy_llm/models/langchain/model.py", line 45, in __call__
    return self.query(self._langchain_model, prompts)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/spacy_llm/models/langchain/model.py", line 56, in query_langchain
    return [model(pr) for pr in prompts]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/spacy_llm/models/langchain/model.py", line 56, in <listcomp>
    return [model(pr) for pr in prompts]
            ^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/langchain/llms/base.py", line 786, in __call__
    self.generate(
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/langchain/llms/base.py", line 582, in generate
    output = self._generate_helper(
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/langchain/llms/base.py", line 488, in _generate_helper
    raise e
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/langchain/llms/base.py", line 475, in _generate_helper
    self._generate(
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/langchain/llms/openai.py", line 399, in _generate
    response = completion_with_retry(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/langchain/llms/openai.py", line 115, in completion_with_retry
    return _completion_with_retry(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/tenacity/__init__.py", line 314, in iter
    return fut.result()
           ^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/tenacity/__init__.py", line 382, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/langchain/llms/openai.py", line 113, in _completion_with_retry
    return llm.client.create(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/openai/api_resources/completion.py", line 25, in create
    return super().create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 155, in create
    response, _, api_key = requestor.request(
                           ^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/openai/api_requestor.py", line 299, in request
    resp, got_stream = self._interpret_response(result, stream)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/openai/api_requestor.py", line 710, in _interpret_response
    self._interpret_response_line(
  File "/Users/mariamoya/.pyenv/versions/3.11.3/envs/document_classifier/lib/python3.11/site-packages/openai/api_requestor.py", line 775, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: Resource not found

was wondering if anyone would happen to know what I might be missing?

@rmitsch
Copy link
Collaborator

rmitsch commented Oct 3, 2023

Hi @mmoya91! It's possible this is related to the known LangChain/Azure integration issues. Looking into it.

Can you connect to Azure OpenAI using your credentials with langchain directly? See here for a guide. Just to ensure that your auth details/setup works.

@rmitsch rmitsch added feat/model Feature: models third party Third-party software (integrations etc.) labels Oct 3, 2023
@rmitsch rmitsch linked a pull request Oct 5, 2023 that will close this issue
3 tasks
@rmitsch rmitsch removed a link to a pull request Oct 5, 2023
3 tasks
@rmitsch
Copy link
Collaborator

rmitsch commented Oct 5, 2023

See #311 (comment): I suspect you aren't providing the full configuration required to run langchain with Azure OpenAI. Have a look at the example I linked - if you still encounter issues, please update this thread. Otherwise I'll close this issue in a few days.

@rmitsch
Copy link
Collaborator

rmitsch commented Oct 5, 2023

Note: v0.6.0 is out and has native support for Azure OpenAI.

@mmoya91
Copy link
Author

mmoya91 commented Oct 6, 2023

perfect, thank you for the update @rmitsch!

@rmitsch rmitsch closed this as completed Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat/model Feature: models third party Third-party software (integrations etc.)
Projects
None yet
Development

No branches or pull requests

2 participants