Giter Site home page Giter Site logo

Network error about chatfred HOT 16 CLOSED

chrislemke avatar chrislemke commented on July 28, 2024 1
Network error

from chatfred.

Comments (16)

cindy9923 avatar cindy9923 commented on July 28, 2024 1

I also encountered the same problem as @kraonn , I ran user.workflow.F136CC17-C621-4B37-8CBF-70F810CC658D % python3 src/text_chat.py $1 in the terminal to return the result

Traceback (most recent call last):
  File "/Users/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F136CC17-C621-4B37-8CBF-70F810CC658D/src/text_chat.py", line 8, in <module>
    from error_handling import env_value_error_if_needed, exception_response
  File "/Users/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F136CC17-C621-4B37-8CBF-70F810CC658D/src/error_handling.py", line 9, in <module>
    import openai
  File "/Users/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F136CC17-C621-4B37-8CBF-70F810CC658D/src/libs/openai/__init__.py", line 9, in <module>
    from openai.api_resources import (
  File "/Users/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F136CC17-C621-4B37-8CBF-70F810CC658D/src/libs/openai/api_resources/__init__.py", line 7, in <module>
    from openai.api_resources.embedding import Embedding  # noqa: F401
  File "/Users/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F136CC17-C621-4B37-8CBF-70F810CC658D/src/libs/openai/api_resources/embedding.py", line 7, in <module>
    from openai.datalib import numpy as np, assert_has_numpy
  File "/Users/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F136CC17-C621-4B37-8CBF-70F810CC658D/src/libs/openai/datalib.py", line 22, in <module>
    import pandas
  File "/opt/anaconda3/lib/python3.9/site-packages/pandas/__init__.py", line 22, in <module>
    from pandas.compat import is_numpy_dev as _is_numpy_dev  # pyright: ignore # noqa:F401
  File "/opt/anaconda3/lib/python3.9/site-packages/pandas/compat/__init__.py", line 17, in <module>
    from pandas._typing import F
  File "/opt/anaconda3/lib/python3.9/site-packages/pandas/_typing.py", line 79, in <module>
    ArrayLike = Union["ExtensionArray", np.ndarray]
AttributeError: module 'numpy' has no attribute 'ndarray'

from chatfred.

kraonn avatar kraonn commented on July 28, 2024 1

Neither was, I manually installed both.

Now it works fine from the terminal if I invoke the script there, but the ChatFred workflow still is returning the same "fishy internet connection" error message.

from chatfred.

kraonn avatar kraonn commented on July 28, 2024 1

SUCCESS! Seeing the actual error message made it clear that I'd somehow gotten my API key into the configuration field twice, which made it an invalid API key. Deleting my API key from the configuration and re-entering it (once) makes everything work great.

Thanks for your patient help!

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

Hey @kraonn!
Thanks for your message. I will look into it. Would be great if you check the script - as you mentioned. If you debug you can get the error message from OpenAI. That would help a lot.

from chatfred.

kraonn avatar kraonn commented on July 28, 2024

Thanks for responding. I would like to just run the script in terminal, but I cannot find where it's installed? What's the full path for the scripts that are a part of this workflow? I'm not an Alfred workflow expert so I don't know where those live.

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

You can find the scripts in the src folder. With a right-click on the Workflow, you can open it in the finder. If you are using ChatFred you are looking for the text_chat.py script. In the error_handling.py you can find your error is actually a openai.error.APIConnectionError. Here you can read more about it.

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

Hey @kraonn!
I could not reproduce your issue. Were you able to find out anything?

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

Hey @cindy9923!
Thanks for your message. Looks like there is some kind of issue with NumPy.

In the openai.datalib it says:

This module helps make data libraries like numpy and pandas optional dependencies.
The libraries add up to 130MB+, which makes it challenging to deploy applications
using this library in environments with code size constraints, like AWS Lambda.
This module serves as an import proxy and provides a few utilities for dealing with the optionality.
Since the primary use case of this library (talking to the OpenAI API) doesnโ€™t generally require data libraries,
itโ€™s safe to make them optional. The rare case when data libraries are needed in the client is handled through
assertions with instructive error messages.

It checks for those packages:

try:
    import numpy
except ImportError:
    numpy = None

try:
    import pandas
except ImportError:
    pandas = None

And raises an error if they are needed and not existing:

def assert_has_numpy():
    if not HAS_NUMPY:
        raise MissingDependencyError(NUMPY_INSTRUCTIONS)


def assert_has_pandas():
    if not HAS_PANDAS:
        raise MissingDependencyError(PANDAS_INSTRUCTIONS)

You could try either updating them or installing OpenAI's datalib: $ pip install openai[datalib]. Hope that helps!

from chatfred.

kraonn avatar kraonn commented on July 28, 2024

Still an issue for me. I installed openai but the installation command above to install the datalib dependencies fails for me, it says openai[datalib] is not found. Probably something dumb, I'm a novice with installing Python packages.

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

Could you check if you have Pandas and NumPy installed and if so which version?

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

If you are willing to debug. You could find out what error OpenAI is returning. As mentioned above you can check the exception_response function in error_handling.py maybe the original openai.error.APIConnectionError is more helpful.
`

from chatfred.

kraonn avatar kraonn commented on July 28, 2024

I'm not sure how to debug that APIConnectionError error further, everything I can find suggests that it doesn't give any more specifics about the problem. The image generation script also works perfectly if I invoke it from terminal, but not when run from the Alfred workflow.

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

Have you made any changes to the workflow's configuration? Like Maximum tokens, Temperature, etc.? If it works for you through the terminal maybe it is something wrong with the needed environment variables.

from chatfred.

kraonn avatar kraonn commented on July 28, 2024

I have not, I've only set the API key.

I rebooted into safe mode just to be sure I didn't have some network filter utility running that would be intercepting the script, but got the same behavior.

Could it be a permissions issue? Do we know what user the Alfred workflow executes under?

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

Could it be a permissions issue? Do we know what user the Alfred workflow executes under?

Nothing I know of. ๐Ÿค”

One Idea. You could exchange the make_chat_request function in the text_chat.py with this:

def make_chat_request(
    prompt: str,
    temperature: float,
    max_tokens: Optional[int],
    top_p: int,
    frequency_penalty: float,
    presence_penalty: float,
) -> Tuple[str, str]:
    handle_custom_prompts(prompt)
    messages = create_message(prompt)
    try:
        response = (
            openai.ChatCompletion.create(
                model="gpt-3.5-turbo",
                messages=messages,
                temperature=temperature,
                max_tokens=max_tokens,
                top_p=top_p,
                frequency_penalty=frequency_penalty,
                presence_penalty=presence_penalty,
            )
            .choices[0]
            .message["content"]
        )
    except Exception as exception:  # pylint: disable=broad-except
        response = exception._message # Use OpenAI error

    return prompt, response

Now it prints the original OpenAI error. Maybe this help us to figure out the problem.

from chatfred.

chrislemke avatar chrislemke commented on July 28, 2024

Great! Good to hear. Right now I am working on an error logger. So next time it should be easier to get the proper error message.

from chatfred.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.