Hi, I am new to Weaviate and followed the QuickStart steps exactly but ran into the following exception. Any help is appreciated!
Description
Implementing the QuickStart on WCD with Python gives the following exception when doing a generative search:
weaviate.exceptions.WeaviateQueryError: Query call with protocol GRPC search failed with message <AioRpcError of RPC that terminated with:
status = StatusCode.UNKNOWN
details = “connection to: OpenAI API failed with status: 400 request-id: req_4419cf1a05ed4792171000454b82a998 error: max_tokens is too large: 4097. This model supports at most 4096 completion tokens, whereas you provided 4097.”
debug_error_string = “UNKNOWN:Error received from peer {created_time:“2024-10-15T19:41:41.686614+02:00”, grpc_status:2, grpc_message:“connection to: OpenAI API failed with status: 400 request-id: req_4419cf1a05ed4792171000454b82a998 error: max_tokens is too large: 4097. This model supports at most 4096 completion tokens, whereas you provided 4097.”}”
Server Setup Information
WCS Sandbox standard
hi @Chris_Blom !!
Welcome to our community
This is a known issue that was already tackled here:
weaviate:stable/v1.25
← weaviate:modules/fix-generative-openai-default-max-tokens-and-models
opened 09:45AM - 11 Oct 24 UTC
### What's being changed:
See Slack discussion: [Link]( https://weaviate-org.… slack.com/archives/C04AT0Y52E6/p1728641537952229?thread_ts=1728635290.391309&cid=C04AT0Y52E6)
- Updated the default model for generative-openai (gpt-3.5-turbo) to reflect the maxTokens of 4096 and resolve error `max_tokens is too large: 4097. This model supports at most 4096 completion tokens, whereas you provided 4097.`
- Added gpt-4o-mini to available models list
- gpt-4o was also brought in due to being available in stable/v1.26 - can be edited if needed or merged if this is okay
Documentation change request: would be worth updating available model list here: [Available Models - openai-generative](https://weaviate.io/developers/weaviate/model-providers/openai/generative#available-models)
### Review checklist
- [ ] Documentation has been updated, if necessary. Link to changed documentation:
- [ ] Chaos pipeline run or not necessary. Link to pipeline:
- [ ] All new code is covered by tests where it is reasonable.
- [ ] Performance tests have been run or not necessary.
Uncomment the following section if this PR requires changes in related projects (e.g., documentation, client libraries).
GitHub actions will automatically create an issue in the corresponding repository for each checked box below. (See `.github/workflows/create-cross-functional-issues.yml`)
### Cross-functional impact
- [x] This change requires public documentation (weaviate-io) to be updated. Check the box to automatically create a corresponding issue.
- Does it require a change in the client libraries? If yes, please check the boxes for the affected client libraries.
- [ ] Python (weaviate-python-client)
- [ ] JavaScript/TypeScript (typescript-client)
- [ ] Go (weaviate-go-client)
- [ ] Java (java-client)
It seems there was a change in OpenAI Api
this should be a workaround, but it’s also falling into the same issue:
client.collections.delete("Test")
collection = client.collections.create(
name="Test",
vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
generative_config=wvc.config.Configure.Generative.openai(model="gpt-3.5-turbo", max_tokens=4096),
)
collection.data.insert({
"text": "something about dogs",
}
)
collection.data.insert({
"text": "something about cats",
}
)
results = collection.generate.near_text(
query="animals",
grouped_task="Create a content with {text}",
single_prompt="Translate {text} to portuguese"
)
I’ll get back here with more information as soon as I get it
ps, for now, if you only want to play around you can use the gpt-4 model, like so:
client.collections.delete("Test")
collection = client.collections.create(
name="Test",
vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
generative_config=wvc.config.Configure.Generative.openai(model="gpt-4"),
)
collection.data.insert({
"text": "something about dogs",
}
)
collection.data.insert({
"text": "something about cats",
}
)
results = collection.generate.near_text(
query="animals",
grouped_task="Create a content with {text}",
single_prompt="Translate {text} to portuguese"
)
Hi Duda, thanks for the quick reply and I’ll change to gpt-4. regards, Chris
Great! A new patch is being released to address this change in apis.
it should be released probably today.
Thanks!
1 Like