This commit is contained in:
parent
6b0a96cb7e
commit
d9d8552917
|
@ -20,7 +20,14 @@ class BaseOpenAIProvider(BaseProvider):
|
|||
openai.api_base = self.data["api_base"]
|
||||
|
||||
def ask(self, prompt, chat):
|
||||
chat = chat["content"]
|
||||
_chat = []
|
||||
for c in chat["content"]:
|
||||
if c["role"] == self.app.bot_name:
|
||||
role = "assistant"
|
||||
else:
|
||||
role = "user"
|
||||
_chat.append({"role": role, "content": c["content"]})
|
||||
chat = _chat
|
||||
|
||||
if self.data.get("api_key"):
|
||||
openai.api_key = self.data["api_key"]
|
||||
|
@ -30,6 +37,7 @@ class BaseOpenAIProvider(BaseProvider):
|
|||
if self.model:
|
||||
prompt = self.chunk(prompt)
|
||||
try:
|
||||
print(chat)
|
||||
response = self.chat.create(
|
||||
model=self.model,
|
||||
messages=chat,
|
||||
|
|
|
@ -77,12 +77,13 @@ class Item(Gtk.Box):
|
|||
result = ""
|
||||
is_code = False
|
||||
for line in self.content_markup:
|
||||
if "<tt></tt>`" in line.strip():
|
||||
if is_code:
|
||||
is_code = False
|
||||
else:
|
||||
is_code = True
|
||||
continue
|
||||
if isinstance(line, str):
|
||||
if "<tt></tt>`" in line.strip():
|
||||
if is_code:
|
||||
is_code = False
|
||||
else:
|
||||
is_code = True
|
||||
continue
|
||||
if is_code or not isinstance(line, str):
|
||||
label = Gtk.Label()
|
||||
label.set_use_markup(True)
|
||||
|
@ -97,7 +98,7 @@ class Item(Gtk.Box):
|
|||
self.content.append(label)
|
||||
|
||||
if not isinstance(line, str):
|
||||
result = "\n".join(line.strip())
|
||||
result = "\n".join(line)
|
||||
else:
|
||||
result = line.strip()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user