TypeError: string indices must be integers
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.5k
- Forks
- 4.8k
- PR merge metrics
- No merged PRs in 30d
Description
Use the Python openai to call the FastChat API + baichuan2-13B, then I received the "TypeError: string indices must be integers" error
The full error message:
"""
Traceback (most recent call last):
File "C:\Users\Adams\anaconda3\lib\site-packages\openai\api_requestor.py", line 413, in handle_error_response
error_data = resp["error"]
TypeError: string indices must be integers
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Programs/20230927/LLM/api_sample_test.py", line 13, in
completion = openai.Completion.create(model=model, prompt=prompt, max_tokens=64)
File "C:\Users\Adams\anaconda3\lib\site-packages\openai\api_resources\completion.py", line 25, in create
return super().create(*args, **kwargs)
File "C:\Users\Adams\anaconda3\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 155, in create
response, _, api_key = requestor.request(
File "C:\Users\Adams\anaconda3\lib\site-packages\openai\api_requestor.py", line 299, in request
resp, got_stream = self._interpret_response(result, stream)
File "C:\Users\Adams\anaconda3\lib\site-packages\openai\api_requestor.py", line 710, in _interpret_response
self._interpret_response_line(
File "C:\Users\Adams\anaconda3\lib\site-packages\openai\api_requestor.py", line 775, in _interpret_response_line
raise self.handle_error_response(
File "C:\Users\Adams\anaconda3\lib\site-packages\openai\api_requestor.py", line 415, in handle_error_response
raise error.APIError(
openai.error.APIError: Invalid response object from API: 'Internal Server Error' (HTTP response code was 500)
Process finished with exit code 1
"""
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report points to the Python openai.Completion.create call and api_requestor.py while using the FastChat API with baichuan2-13B, but names no FastChat repository file or test. Start by reproducing the request and inspect the response handling around the reported error; done would mean the failure is diagnosed and produces a correctly handled API error instead of the TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100