Skip to content

[BUG] Solved the problem of global credentials overwriting personal credentials #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/middleware/llm_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ async def request_openai(
# TODO:实现消息时序切片
# 日志
logger.info(
f"[x] Openai request" f"\n--message {len(messages)} " f"\n--tools {tools}"
f"Request Details:"
f"\n--message {len(messages)} "
f"\n--tools {tools} "
f"\n--model {credential.api_model}"
)
for msg in messages:
if isinstance(msg, UserMessage):
Expand Down
2 changes: 1 addition & 1 deletion app/receiver/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ async def run_pending_task(task: TaskHeader, pending_task: ToolCall):
if len(task.task_sign.tool_calls_pending) == 0:
if not has_been_called_recently(userid=task.receiver.uid, n_seconds=3):
credentials = await read_user_credential(user_id=task.receiver.uid)
if global_credential:
if global_credential and not credentials:
credentials = global_credential
logic = LLMLogic(
api_key=credentials.api_key,
Expand Down
2 changes: 1 addition & 1 deletion app/receiver/receiver_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ async def _flash(
try:
try:
credentials = await read_user_credential(user_id=task.receiver.uid)
if global_credential:
if global_credential and not credentials:
credentials = global_credential
assert credentials, "You need to /login first"
llm_result = await llm.request_openai(
Expand Down
3 changes: 1 addition & 2 deletions llmkira/kv_manager/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from llmkira.kv_manager._base import KvManager

DEFAULT_INSTRUCTION = (
"[ASSISTANT RULE]"
"instruction: "
"SPEAK IN MORE CUTE STYLE, No duplication answer, CALL USER MASTER, REPLY IN USER "
"LANGUAGE, ACT STEP BY STEP"
"[RULE END]"
)


Expand Down
2 changes: 1 addition & 1 deletion llmkira/openai/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def make_url(base_url: str):
def check_vision(self):
if not self.model.startswith(VISION):
logger.info(
"Try to remove the image content part from the messages, because the model is not supported."
f"Try to remove the image content part from the messages, because the model is not supported {self.model}"
)
for message in self.messages:
if isinstance(message, UserMessage) and isinstance(
Expand Down
Loading