mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 13:34:40 +00:00
Added the following changes to the codebase:
This commit is contained in:
+12
-13
@@ -30,20 +30,23 @@ async def _openai_call(messages, model, temperature=0.2):
|
||||
Responses API dla 4o/4.1*, fallback Chat Completions dla gpt-3.5-turbo.
|
||||
Zwraca czysty string odpowiedzi.
|
||||
"""
|
||||
logger = logging.getLogger("discord")
|
||||
|
||||
if model.startswith("gpt-3.5"):
|
||||
logger.debug("3.5")
|
||||
# legacy path – bez zmian w Twoim kodzie wyżej/niżej
|
||||
def _sync_call():
|
||||
resp = OPENAICLIENT.chat.completions.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
temperature=temperature,
|
||||
)
|
||||
return resp.choices[0].message.content.strip()
|
||||
return await asyncio.to_thread(_sync_call)
|
||||
resp = OPENAICLIENT.chat.completions.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
temperature=temperature,
|
||||
)
|
||||
result = ""
|
||||
for choice in resp.choices:
|
||||
result += choice.message.content
|
||||
return result.strip()
|
||||
|
||||
else:
|
||||
# Responses API (zalecane dla 4o/4.1*)
|
||||
def _sync_resp():
|
||||
resp = OPENAICLIENT.responses.create(
|
||||
model=model,
|
||||
temperature=temperature,
|
||||
@@ -51,7 +54,6 @@ async def _openai_call(messages, model, temperature=0.2):
|
||||
)
|
||||
# SDK zapewnia output_text dla zwykłych odpowiedzi
|
||||
return (getattr(resp, "output_text", None) or "").strip() or str(resp)
|
||||
return await asyncio.to_thread(_sync_resp)
|
||||
|
||||
|
||||
def create_vector_store():
|
||||
@@ -302,9 +304,6 @@ async def handle_response(
|
||||
result = ""
|
||||
logger.debug("Odpowiedzi")
|
||||
logger.info(response)
|
||||
logger.debug(response.choices)
|
||||
for choice in response.choices:
|
||||
result += choice.message.content
|
||||
logger.info("Sformatowane odpowiedzi")
|
||||
logger.info(result)
|
||||
temp = {"role": "assistant", "content": result}
|
||||
|
||||
Reference in New Issue
Block a user