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

No match data because no search succeeded #430

Open
Charlescad opened this issue Oct 16, 2024 · 8 comments
Open

No match data because no search succeeded #430

Charlescad opened this issue Oct 16, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@Charlescad
Copy link

Bug Description

Hello, when i throw gptel-send i receive this error:

Debugger entered--Lisp error: (error "No match data, because no search succeeded")
#f(compiled-function (backend info) #<bytecode -0x3b6bfcdf811e44b>)
(nil (:token "d3e321dc4e0079fc4d4bf0d656aaa9c9"
:backend #s(gptel-gemini
:name "Gemini"
:host "generativelanguage.googleapis.com"
:header nil
:protocol "https"
:stream t
:endpoint "/v1beta/models"
:key "SECRET"
:models (gemini-pro gemini-1.5-flash gemini-1.5-pro-latest)
:url #f(compiled-function () #<bytecode -0x12021f2cddcb5cce>)
:curl-args nil)
:parser #f(compiled-function (backend info) #<bytecode -0x3b6bfcdf811e44b>)
:callback gptel-curl--stream-insert-response
:transformer nil
:data (:contents [(
:role "user"
:parts [(:text "You are a large language model living in Emacs and...") (:text "my test")])]
:safetySettings [(:category "HARM_CATEGORY_HARASSMENT" :threshold "BLOCK_NONE")
(:category "HARM_CATEGORY_SEXUALLY_EXPLICIT" :threshold "BLOCK_NONE")
(:category "HARM_CATEGORY_DANGEROUS_CONTENT" :threshold "BLOCK_NONE")
(:category "HARM_CATEGORY_HATE_SPEECH" :threshold "BLOCK_NONE")]
:generationConfig (:temperature 1.0))
:buffer #<buffer Gemini>
:position #<marker at 8 in Gemini>
:http-status "200"
:status "HTTP/1.1 200 Connection established"))

gptel-curl--stream-filter(# "(d3e321dc4e0079fc4d4bf0d656aaa9c9 . 125)")

I installed it via

Backend

None

Steps to Reproduce

  1. Install
    package-install gpt-el

  2. Setup with gemini
    (gptel-make-gemini "Gemini" :key "YOUR_GEMINI_API_KEY" :stream t)
    (setq
    gptel-model 'gemini-pro
    gptel-backend (gptel-make-gemini "Gemini"
    :key "YOUR_GEMINI_API_KEY"
    :stream t))

  3. write "my test"

  4. gptel-send

Additional Context

Emacs 28.2 installed on windows via msys2
curl on msys2

Log Information

No response

Backtrace

Debugger entered--Lisp error: (error "No match data, because no search succeeded")
#f(compiled-function (backend info) #<bytecode -0x3b6bfcdf811e44b>)
(nil (:token "d3e321dc4e0079fc4d4bf0d656aaa9c9"
	     :backend #s(gptel-gemini
			 :name "Gemini"
			 :host "generativelanguage.googleapis.com"
			 :header nil
			 :protocol "https"
			 :stream t
			 :endpoint "/v1beta/models"
			 :key "SECRET"
			 :models (gemini-pro gemini-1\.5-flash gemini-1\.5-pro-latest)
			 :url #f(compiled-function () #<bytecode -0x12021f2cddcb5cce>)
			 :curl-args nil)
	     :parser #f(compiled-function (backend info) #<bytecode -0x3b6bfcdf811e44b>)
	     :callback gptel-curl--stream-insert-response
	     :transformer nil
	     :data (:contents [(
				:role "user"
				      :parts [(:text "You are a large language model living in Emacs and...") (:text "my test")])]
			      :safetySettings [(:category "HARM_CATEGORY_HARASSMENT" :threshold "BLOCK_NONE")
					       (:category "HARM_CATEGORY_SEXUALLY_EXPLICIT" :threshold "BLOCK_NONE")
					       (:category "HARM_CATEGORY_DANGEROUS_CONTENT" :threshold "BLOCK_NONE")
					       (:category "HARM_CATEGORY_HATE_SPEECH" :threshold "BLOCK_NONE")]
			      :generationConfig (:temperature 1.0))
	     :buffer #<buffer *Gemini*>
	     :position #<marker at 8 in *Gemini*>
	     :http-status "200"
	     :status "HTTP/1.1 200 Connection established"))

gptel-curl--stream-filter(#<process gptel-curl> "(d3e321dc4e0079fc4d4bf0d656aaa9c9 . 125)")
@Charlescad Charlescad added the bug Something isn't working label Oct 16, 2024
@karthink
Copy link
Owner

It will help to look at the response. Can you log it and add it here?

@Charlescad
Copy link
Author

I lcopy / pasted there what I receive in Message, is it what you meant?

Send your query with C-c RET! Querying Gemini... error in process filter: string-trim: Wrong type argument: stringp, nil error in process filter: Wrong type argument: stringp, nil

@karthink
Copy link
Owner

No, I meant:

  1. Turn on logging with (setq gptel-log-level 'info)
  2. Use gptel and produce this error
  3. Check the *gptel-log* buffer
  4. Remove your API key from the log, if it's present, and paste the result here

@Charlescad
Copy link
Author

Charlescad commented Oct 22, 2024

Hello Karthink,

Sorry for the delay. I will try to be more responsive.
Here is the content of gptel-log.

Could it come from the fact that in windows, curl does not accept single quote?

For instance

curl \ -H 'Content-Type: application/json' \ -d '{"contents":[{"parts":[{"text":"Explain how AI works"}]}]}' \ -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=YOUR_API_KEY'
becomes

curl -k -H "Content-Type: application/json" -d "{\"contents\":[{\"parts\":[{\"text\":\"Explain how AI works\"}]}]}" -X POST https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=YOUR_API_KEY

{
"gptel": "request body",
"timestamp": "2024-10-22 11:57:46"
}
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "another test\nhello world"
}
]
}
],
"safetySettings": [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_NONE"
}
],
"system_instruction": {
"parts": {
"text": "You are a large language model living in Emacs and a helpful assistant. Respond concisely."
}
},
"generationConfig": {
"temperature": 1.0
}
}
{
"gptel": "response body",
"timestamp": "2024-10-22 11:57:47"
}

[
{
"candidates": [
{
"content": {
"parts": [
{
"text": "Hello world! "
}
],
"role": "model"
},
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 25,
"candidatesTokenCount": 3,
"totalTokenCount": 28
},
"modelVersion": "gemini-1.5-flash"
},
{
"candidates": [
{
"content": {
"parts": [
{
"text": "\360\237\214\216 I'm here to help. What can I do for you? \n"
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 25,
"candidatesTokenCount": 19,
"totalTokenCount": 44
},
"modelVersion": "gemini-1.5-flash"
}
]

@karthink
Copy link
Owner

Could it come from the fact that in windows, curl does not accept single quote?

We don't use the shell to invoke Curl so this isn't an issue.

"text": "\360\237\214\216 I'm here to help. What can I do for you? \n"

I see some encoding issues in the response but nothing that should cause the request to fail.

  1. Have you customized gptel's hooks in any way? gptel-pre-response-hook, gptel-post-response-functions etc
  2. Does it work if you don't use Curl? Run (setq gptel-use-curl nil)

@Charlescad
Copy link
Author

When I C-h v gptel-pre-response-hook i get:
`gptel-pre-response-hook is a variable defined in ‘gptel.el’.

Its value is nil`

On question 2 (setq gptel-use-curl nil) the good news is that it responds something in the log, the bad news is that i still get an error
string-trim: Wrong type argument: stringp, nil

Good news in bold: we get a response

{
"gptel": "request body",
"timestamp": "2024-10-24 09:55:35"
}
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Another test\nHow does AI work?"
}
]
}
],
"safetySettings": [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_NONE"
}
],
"system_instruction": {
"parts": {
"text": "You are a large language model living in Emacs and a helpful assistant. Respond concisely."
}
},
"generationConfig": {
"temperature": 1.0
}
}
{
"gptel": "response body",
"timestamp": "2024-10-24 09:55:37"
}

[
{
"candidates": [
{
"content": {
"parts": [
{
"text": "AI"
}
],
"role": "model"
},
"index": 0
}
],
"usageMetadata": {
"promptTokenCount": 28,
"candidatesTokenCount": 1,
"totalTokenCount": 29
},
"modelVersion": "gemini-1.5-pro-001"
},
{
"candidates": [
{
"content": {
"parts": [
{
"text": " simulates intelligence with algorithms trained on data to recognize patterns, make predictions, and perform"
}
],
"role": "model"
},
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 28,
"candidatesTokenCount": 18,
"totalTokenCount": 46
},
"modelVersion": "gemini-1.5-pro-001"
},
{
"candidates": [
{
"content": {
"parts": [
{
"text": " tasks. \n"
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 28,
"candidatesTokenCount": 20,
"totalTokenCount": 48
},
"modelVersion": "gemini-1.5-pro-001"
}
]

Bad news backtrace (I dropped all lines on certificates and replaced key by SECRET.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-trim-right(nil nil)
string-trim(nil)
gptel--url-parse-response(#s(gptel-gemini
:name "Gemini"
:host "generativelanguage.googleapis.com"
:header nil
:protocol "https"
:stream t
:endpoint "/v1beta/models"
:key "SECRET"
:models (gemini-pro gemini-1.5-flash gemini-1.5-pro-latest)
:url #f(compiled-function () #<bytecode -0x1201be732a20858e>)
:curl-args nil) #<buffer http generativelanguage.googleapis.com:443-830395>)
#f(compiled-function (_) #<bytecode 0x196a0d04fd876665>)
url-http-activate-callback()
url-http-content-length-after-change-function(1455 1510 55)
url-http-generic-filter(# "\242K\201\20Cy]\nl\275g\26g\4\1\233\372\20\337\4\207\370\7(\215\346\254\321\2345hs\26\0\0\0\377\377\212\5\0\0\0\377\377\3\0H\3620...")

@karthink
Copy link
Owner

string-trim: Wrong type argument: stringp, nil

Could you produce a backtrace? Run M-x toggle-debug-on-error and produce the error.

@Charlescad
Copy link
Author

Yes, many thanks
I dropped info concerning certificates & API key

Debugger entered--Lisp error: (wrong-type-argument stringp nil) string-trim-right(nil nil) string-trim(nil) gptel--url-parse-response(#s(gptel-gemini :name "Gemini" :host "generativelanguage.googleapis.com" :header nil :protocol "https" :stream t :endpoint "/v1beta/models" :key "SECRET" :models (gemini-pro gemini-1\.5-flash gemini-1\.5-pro-latest) :url #f(compiled-function () #<bytecode -0x120510d2b4b1144e>) :curl-args nil) #<buffer *http generativelanguage.googleapis.com:443*-434827>) #f(compiled-function (_) #<bytecode -0x51dc706b3bab69f>)((:peer (:certificates () :certificate () :key-exchange "ECDHE-RSA" :protocol "TLS1.2" :cipher "AES-256-GCM" :mac "AEAD" :encrypt-then-mac nil :safe-renegotiation t))) url-http-activate-callback() url-http-content-length-after-change-function(846 863 17) url-http-generic-filter(#<process generativelanguage.googleapis.com> "\212\5\0\0\0\377\377\3\0c\366o-\232\5\0\0")

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