Skip to content

Commit 4a30f95

Browse files
committed
Fix pytgpt. Resolves (#19)
1 parent f1e1a6f commit 4a30f95

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,4 +283,5 @@ Assume role of the LLM and give your response.*
283283

284284
- New provider - *Phind* . Resolves #18
285285
- New util command `latest`.
286-
- `phind` is the default provider - *console*
286+
- `phind` is the default provider - *console*
287+
- Fixed : `pytgpt` - (#19)

src/pytgpt/opengpt/main.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,14 @@ def ask(
139139

140140
session.headers.update(self.headers)
141141
payload = {
142-
"input": {
143-
"messages": [
144-
# self.conversation.chat_history if conversationally else "",
145-
{
146-
"content": conversation_prompt,
147-
"additional_kwargs": {},
148-
"type": "human",
149-
"example": False,
150-
},
151-
]
152-
},
142+
"input": [
143+
{
144+
"content": conversation_prompt,
145+
"additional_kwargs": {},
146+
"type": "human",
147+
"example": False,
148+
},
149+
],
153150
"assistant_id": self.assistant_id,
154151
"thread_id": "",
155152
}
@@ -174,8 +171,10 @@ def for_stream():
174171
try:
175172
modified_value = re.sub("data:", "", value)
176173
resp = json.loads(modified_value)
177-
self.last_response.update(resp)
178-
yield value if raw else resp
174+
if len(resp) == 1:
175+
continue
176+
self.last_response.update(resp[1])
177+
yield value if raw else resp[1]
179178
except json.decoder.JSONDecodeError:
180179
pass
181180
self.conversation.update_chat_history(
@@ -234,6 +233,4 @@ def get_message(self, response: dict) -> str:
234233
str: Message extracted
235234
"""
236235
assert isinstance(response, dict), "Response should be of dict data-type only"
237-
return (
238-
response["messages"][1]["content"] if "messages" in response.keys() else ""
239-
)
236+
return response["content"]

0 commit comments

Comments
 (0)