Improve search
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from django.utils import timezone
|
||||
from openai import AsyncOpenAI
|
||||
|
||||
from core.messaging import ai as ai_runner
|
||||
from core.models import AI, Manipulation, Person
|
||||
|
||||
|
||||
@@ -50,17 +50,11 @@ def generate_prompt(msg: dict, person: Person, manip: Manipulation, chat_history
|
||||
|
||||
|
||||
async def run_context_prompt(
|
||||
prompt: list[str],
|
||||
prompt: list[dict],
|
||||
ai: AI,
|
||||
):
|
||||
cast = {"api_key": ai.api_key}
|
||||
if ai.base_url is not None:
|
||||
cast["base_url"] = ai.base_url
|
||||
client = AsyncOpenAI(**cast)
|
||||
response = await client.chat.completions.create(
|
||||
model=ai.model,
|
||||
messages=prompt,
|
||||
return await ai_runner.run_prompt(
|
||||
prompt,
|
||||
ai,
|
||||
operation="analysis_context",
|
||||
)
|
||||
content = response.choices[0].message.content
|
||||
|
||||
return content
|
||||
|
||||
Reference in New Issue
Block a user