Rename ._response_json to .response_json

This commit is contained in:
Simon Willison 2023-07-11 08:31:38 -07:00
parent 2554a06e36
commit 255f768707
2 changed files with 5 additions and 5 deletions

View file

@ -183,14 +183,14 @@ class Chat(Model):
content = chunk["choices"][0].get("delta", {}).get("content")
if content is not None:
yield content
response._response_json = combine_chunks(chunks)
response.response_json = combine_chunks(chunks)
else:
completion = openai.ChatCompletion.create(
model=prompt.model.model_id,
messages=messages,
stream=False,
)
response._response_json = completion.to_dict_recursive()
response.response_json = completion.to_dict_recursive()
yield completion.choices[0].message.content

View file

@ -81,7 +81,7 @@ class Response(ABC):
self.stream = stream
self._chunks: List[str] = []
self._done = False
self._response_json = None
self.response_json = None
self.conversation = conversation
def __iter__(self) -> Iterator[str]:
@ -112,7 +112,7 @@ class Response(ABC):
def json(self) -> Optional[Dict[str, Any]]:
self._force()
return self._response_json
return self.response_json
def duration_ms(self) -> int:
self._force()
@ -171,7 +171,7 @@ class Response(ABC):
)
response.id = row["id"]
response._prompt_json = json.loads(row["prompt_json"])
response._response_json = json.loads(row["response_json"])
response.response_json = json.loads(row["response_json"])
response._done = True
response._chunks = [row["response"]]
return response