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

A blank line when Ctrl+P #62

Closed
alex285 opened this issue Oct 9, 2024 · 13 comments
Closed

A blank line when Ctrl+P #62

alex285 opened this issue Oct 9, 2024 · 13 comments
Assignees
Labels
type/bug Something is not working

Comments

@alex285
Copy link

alex285 commented Oct 9, 2024

📝 Environment

fish_ai_bug_report

Environment

Running on Fedora Linux 42 (Workstation Edition Prerelease)

Keyboard and key bindings

bind \cp _fish_ai_codify_or_explain
bind -k nul _fish_ai_autocomplete_or_fix
WARNING: Running setxkbmap against an Xwayland server
Keyboard layout: us

Dependencies

Python 3.13.0rc3
fish, version 3.7.0
fisher, version 4.4.5
git version 2.46.2

Package Version


annotated-types 0.7.0
anyio 4.6.0
azure-ai-inference 1.0.0b4
azure-core 1.31.0
binaryornot 0.4.4
cachetools 5.5.0
certifi 2024.8.30
chardet 5.2.0
charset-normalizer 3.3.2
distro 1.9.0
fish_ai 0.10.0
google-ai-generativelanguage 0.6.10
google-api-core 2.20.0
google-api-python-client 2.148.0
google-auth 2.35.0
google-auth-httplib2 0.2.0
google-generativeai 0.8.2
googleapis-common-protos 1.65.0
grpcio 1.66.2
grpcio-status 1.66.2
h11 0.14.0
httpcore 1.0.6
httplib2 0.22.0
httpx 0.27.2
hugchat 0.4.11
idna 3.10
isodate 0.7.0
iterfzf 1.4.0.54.3
jiter 0.6.1
jsonpath-python 1.0.6
mistralai 1.0.2
mypy-extensions 1.0.0
openai 1.50.2
pip 24.2
proto-plus 1.24.0
protobuf 5.28.2
pyasn1 0.6.1
pyasn1_modules 0.4.1
pydantic 2.8.2
pydantic_core 2.20.1
pyparsing 3.1.4
python-dateutil 2.9.0.post0
requests 2.32.3
requests-toolbelt 1.0.0
rsa 4.9
simple-term-menu 1.6.4
six 1.16.0
sniffio 1.3.1
tqdm 4.66.5
typing_extensions 4.12.2
typing-inspect 0.9.0
uritemplate 4.1.1
urllib3 2.2.3

Fish plugins

jorgebucaran/fisher
realiserad/fish-ai

Configuration

[fish-ai]
configuration = openai
debug = True
log = ~/log.txt

[openai]
provider = openai
model = gpt-4o-mini
organization = Personal

Functionality tests

🔥 Running functionality tests...
codify 'print the current date' -> '' (in 1 seconds)
explain 'date' -> '' (in 0 seconds)

🙉 To reproduce

Adding a comment, pressing Ctrl+P, and I just get an empty line (the comment is deleted); also, it doesn't create the log.txt file, and it doesn't make any request to OpenAI

@alex285 alex285 added the type/bug Something is not working label Oct 9, 2024
@alex285
Copy link
Author

alex285 commented Oct 9, 2024

actually there is an issue with OpenAI (error 429 on the API even if there are credits); I'm trying to sort it out, but i keep the bug open since there isn't a log file created to see the error;

@Realiserad
Copy link
Owner

Realiserad commented Oct 9, 2024

Thank you for the bug report.

It may be that this commit swallows some error message.

Can you try to roll back to an older version and try again?

fisher remove (fisher list fish-ai)
fisher install realiserad/fish-ai@d68f68e563ab47581955e602dae8fa4b73c8b4ab

Hopefully that will create a log file and then I can roll back/fix the broken commit.

@alex285
Copy link
Author

alex285 commented Oct 9, 2024

it still doesn't create the log file, but there is an error output! so i typed "hello" and pressed Ctrl+P

helloTraceback (most recent call last):
  File "/home/me/.fish-ai/bin/explain", line 5, in <module>
    from fish_ai.explain import explain
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/fish_ai/explain.py", line 3, in <module>
    from fish_ai import engine
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/fish_ai/engine.py", line 5, in <module>
    import google.generativeai as genai
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/generativeai/__init__.py", line 45, in <module>
    from google.generativeai import protos
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/generativeai/protos.py", line 74, in <module>
    from google.ai.generativelanguage_v1beta.types import *
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/ai/generativelanguage_v1beta/__init__.py", line 21, in <module>
    from .services.cache_service import CacheServiceAsyncClient, CacheServiceClient
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/ai/generativelanguage_v1beta/services/cache_service/__init__.py", line 16, in <module>
    from .async_client import CacheServiceAsyncClient
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/ai/generativelanguage_v1beta/services/cache_service/async_client.py", line 51, in <module>
    from google.ai.generativelanguage_v1beta.services.cache_service import pagers
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/ai/generativelanguage_v1beta/services/cache_service/pagers.py", line 27, in <module>
    from google.ai.generativelanguage_v1beta.types import cache_service, cached_content
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/ai/generativelanguage_v1beta/types/__init__.py", line 45, in <module>
    from .discuss_service import (
    ...<7 lines>...
    )
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/ai/generativelanguage_v1beta/types/discuss_service.py", line 22, in <module>
    from google.ai.generativelanguage_v1beta.types import citation, safety
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/google/ai/generativelanguage_v1beta/types/safety.py", line 222, in <module>
    class SafetySetting(proto.Message):
    ...<45 lines>...
        )
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/proto/message.py", line 279, in __new__
    file_info.generate_file_pb(new_class=cls, fallback_salt=full_name)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/.fish-ai/lib64/python3.13/site-packages/proto/_file_info.py", line 104, in generate_file_pb
    pool.Add(self.descriptor)
    ~~~~~~~~^^^^^^^^^^^^^^^^^

@Realiserad
Copy link
Owner

Realiserad commented Oct 9, 2024

I can reproduce the problem. It happens on Python 3.13. If you use Python 3.10 it will work (edit the file here to run python3.10 instead of python3).

Looks like the dependency google-generativeai is involved. I'll look into it.

@Realiserad
Copy link
Owner

Looks like Python 3.13 is not supported by google-generativeai yet.

I'll keep an eye on it and update the dependency as soon as a new version is available.

@alex285
Copy link
Author

alex285 commented Oct 9, 2024

i replaced python3 to python3.10 on ~/.config/fish/conf.d/fish-ai.fish but i still get the same error with python3.13; is there any way to fast try it without clone and build the repo?

@Realiserad
Copy link
Owner

@alex285

Remove the existing version and then install from the branch I just created with this commit.

fisher remove (fisher list fish-ai)
fisher install realiserad/fish-ai@test/supported-python-versions

@alex285
Copy link
Author

alex285 commented Oct 9, 2024

doesnt output an error, but it doesn't run either, however it creates the log file:

Codifying commandline: hello 
load_ssl_context verify=True cert=None trust_env=True http2=False
load_verify_locations cafile='/home/me/.fish-ai/lib64/python3.10/site-packages/certifi/cacert.pem'
Request options: {'method': 'post', 'url': '/chat/completions', 'files': None, 'json_data': {'messages': [{'role': 'system', 'content': 'You are a shell scripting assistant working inside a fish shell.\nThe operating system is Fedora Linux 42 (Workstation Edition Prerelease)"\n. Your output must to be shell runnable.\nYou may consult Stack Overflow and the official Fish shell\ndocumentation for answers. If you are unable to fulfill the request,\nrespond with a short message starting with "error: ".\n'}, {'role': 'system', 'content': "Respond with a fish shell command which carries out the user's\ntask. Do not explain. Only respond with a single line."}, {'role': 'user', 'content': 'List all disks on the system'}, {'role': 'assistant', 'content': 'df -h'}, {'role': 'user', 'content': 'Pull the Alpine 3 container from DockerHub'}, {'role': 'assistant', 'content': 'docker pull alpine:3'}, {'role': 'user', 'content': 'Substitute all occurrences of the string "foo" with the string "bar" in the file "docker-compose.yml"'}, {'role': 'assistant', 'content': 'sed -i "s/foo/bar/g" docker-compose.yml'}, {'role': 'user', 'content': 'hello '}], 'model': 'gpt-4o-mini', 'max_tokens': 1024, 'n': 1, 'stream': False, 'temperature': 0.2}}
Sending HTTP Request: POST https://api.openai.com/v1/chat/completions
connect_tcp.started host='api.openai.com' port=443 local_address=None timeout=5.0 socket_options=None
connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f1d68fe3760>
start_tls.started ssl_context=<ssl.SSLContext object at 0x7f1d68f27d40> server_hostname='api.openai.com' timeout=5.0
start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f1d68fe34c0>
send_request_headers.started request=<Request [b'POST']>
send_request_headers.complete
send_request_body.started request=<Request [b'POST']>
send_request_body.complete
receive_response_headers.started request=<Request [b'POST']>
receive_response_headers.complete return_value=(b'HTTP/1.1', 401, b'Unauthorized', [(b'Date', b'Wed, 09 Oct 2024 13:30:52 GMT'), (b'Content-Type', b'application/json; charset=utf-8'), (b'Content-Length', b'218'), (b'Connection', b'keep-alive'), (b'vary', b'Origin'), (b'x-request-id', b'req_b0c9ca6b2c8a5588fb67b47e36f8f54a'), (b'strict-transport-security', b'max-age=31536000; includeSubDomains; preload'), (b'CF-Cache-Status', b'DYNAMIC'), (b'Set-Cookie', b'__cf_bm=02ti73H8dpDmjKLB_shQQVnIQXzCIs4nXFmVeHkqg_E-1728480652-1.0.1.1-3YsHipK.PhdZ7UrJxtO7ZVrDRpLwJWepxzMdVHww32SEcc7jg0NwREDajiwdFLYB.mHdo2Ilg.n8FbNGtIpQ6A; path=/; expires=Wed, 09-Oct-24 14:00:52 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None'), (b'X-Content-Type-Options', b'nosniff'), (b'Set-Cookie', b'_cfuvid=NYK3ZtkvejA2ck0T3.0KjVfY7NX1R7Pp9sgmT.CGp7Q-1728480652266-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None'), (b'Server', b'cloudflare'), (b'CF-RAY', b'8cfeba4b7f27d0d4-SOF'), (b'alt-svc', b'h3=":443"; ma=86400')])
HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 401 Unauthorized"
receive_response_body.started request=<Request [b'POST']>
receive_response_body.complete
response_closed.started
response_closed.complete
HTTP Response: POST https://api.openai.com/v1/chat/completions "401 Unauthorized" Headers([('date', 'Wed, 09 Oct 2024 13:30:52 GMT'), ('content-type', 'application/json; charset=utf-8'), ('content-length', '218'), ('connection', 'keep-alive'), ('vary', 'Origin'), ('x-request-id', 'req_b0c9ca6b2c8a5588fb67b47e36f8f54a'), ('strict-transport-security', 'max-age=31536000; includeSubDomains; preload'), ('cf-cache-status', 'DYNAMIC'), ('set-cookie', '__cf_bm=02ti73H8dpDmjKLB_shQQVnIQXzCIs4nXFmVeHkqg_E-1728480652-1.0.1.1-3YsHipK.PhdZ7UrJxtO7ZVrDRpLwJWepxzMdVHww32SEcc7jg0NwREDajiwdFLYB.mHdo2Ilg.n8FbNGtIpQ6A; path=/; expires=Wed, 09-Oct-24 14:00:52 GMT; domain=.api.openai.com; HttpOnly; Secure; SameSite=None'), ('x-content-type-options', 'nosniff'), ('set-cookie', '_cfuvid=NYK3ZtkvejA2ck0T3.0KjVfY7NX1R7Pp9sgmT.CGp7Q-1728480652266-0.0.1.1-604800000; path=/; domain=.api.openai.com; HttpOnly; Secure; SameSite=None'), ('server', 'cloudflare'), ('cf-ray', '8cfeba4b7f27d0d4-SOF'), ('alt-svc', 'h3=":443"; ma=86400')])
request_id: req_b0c9ca6b2c8a5588fb67b47e36f8f54a
Encountered httpx.HTTPStatusError
Traceback (most recent call last):
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_base_client.py", line 1030, in _request
    response.raise_for_status()
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/httpx/_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://api.openai.com/v1/chat/completions'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
Not retrying
Re-raising status error
Error code: 401 - {'error': {'message': 'OpenAI-Organization header should match organization for API key', 'type': 'invalid_request_error', 'param': None, 'code': 'mismatched_organization'}}
Traceback (most recent call last):
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/fish_ai/codify.py", line 92, in codify
    response = engine.get_response(messages=get_messages(commandline))
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/fish_ai/engine.py", line 268, in get_response
    completions = get_openai_client().chat.completions.create(
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_utils/_utils.py", line 274, in wrapper
    return func(*args, **kwargs)
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/resources/chat/completions.py", line 704, in create
    return self._post(
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_base_client.py", line 1270, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_base_client.py", line 947, in request
    return self._request(
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_base_client.py", line 1051, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'OpenAI-Organization header should match organization for API key', 'type': 'invalid_request_error', 'param': None, 'code': 'mismatched_organization'}}
Error code: 401 - {'error': {'message': 'OpenAI-Organization header should match organization for API key', 'type': 'invalid_request_error', 'param': None, 'code': 'mismatched_organization'}}
Traceback (most recent call last):
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/fish_ai/codify.py", line 92, in codify
    response = engine.get_response(messages=get_messages(commandline))
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/fish_ai/engine.py", line 268, in get_response
    completions = get_openai_client().chat.completions.create(
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_utils/_utils.py", line 274, in wrapper
    return func(*args, **kwargs)
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/resources/chat/completions.py", line 704, in create
    return self._post(
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_base_client.py", line 1270, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_base_client.py", line 947, in request
    return self._request(
  File "/home/me/.fish-ai/lib64/python3.10/site-packages/openai/_base_client.py", line 1051, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'OpenAI-Organization header should match organization for API key', 'type': 'invalid_request_error', 'param': None, 'code': 'mismatched_organization'}}
close.started
close.started
close.complete
close.complete

@Realiserad
Copy link
Owner

The error is:

401 Unauthorized
OpenAI-Organization header should match organization for API key

Does this post help?

@alex285
Copy link
Author

alex285 commented Oct 9, 2024

Does this post help?

im not sure how? it says that you dont need to add an organization, but on fish-ai.ini it asks for organization

@Realiserad
Copy link
Owner

You can try to remove that line in the configuration. It's possible that the example in the README is not accurate. I would test it myself, but I do not have access to OpenAI anymore.

@alex285
Copy link
Author

alex285 commented Oct 9, 2024

You can try to remove that line in the configuration. It's possible that the example in the README is not accurate. I would test it myself, but I do not have access to OpenAI anymore.

tried already, same issue unfortunately 😟

@Realiserad
Copy link
Owner

I have made the plugin more aware of what version of Python is being used to run it. I'm now running pytest on a set of supported versions of Python, and if the plugin is installed with a different version, it will warn the user and provide instructions for how to install on a supported version.

@alex285 Please remove fish-ai once more, and install the latest one with e.g. Python 3.12 (the latest version that seems to work). Here are the commands:

fisher remove (fisher list | grep fish-ai)
set -g FISH_AI_PYTHON_VERSION 3.12
fisher install realiserad/fish-ai

If you still have issues with OpenAI, and believe that this is a problem with the plugin, feel free to open a new issue. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is not working
Projects
None yet
Development

No branches or pull requests

2 participants